From 01acb3fe31c0b4f533c7759cd70a0c75fb8192ec Mon Sep 17 00:00:00 2001 From: 20220016 <17777770016@qq.com> Date: Thu, 11 Jul 2024 19:09:48 +0800 Subject: [PATCH] ADD file via upload --- RandomFunction.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 RandomFunction.java diff --git a/RandomFunction.java b/RandomFunction.java new file mode 100644 index 0000000..f46b1ee --- /dev/null +++ b/RandomFunction.java @@ -0,0 +1,26 @@ +package com.sen.api.functions; + +import com.sen.api.utils.RandomUtil; + +public class RandomFunction implements Function { + + @Override + public String execute(String[] args) { + int len = args.length; + int length = 6;// 默认为6 + boolean flag = false;// 默认为false + if (len > 0) {// 第一个参数字符串长度 + length = Integer.valueOf(args[0]); + } + if (len > 1) {// 第二个参数是否纯字符串 + flag = Boolean.valueOf(args[1]); + } + return RandomUtil.getRandom(length, flag); + } + + @Override + public String getReferenceKey() { + return "random"; + } + +}