com.nbsaas.boot.no.rest.generator.RandomGenerator Maven / Gradle / Ivy
The newest version!
package com.nbsaas.boot.no.rest.generator;
import com.nbsaas.boot.no.ext.apis.Generator;
import java.util.Random;
// 随机生成器实现
public class RandomGenerator implements Generator {
private int length;
public RandomGenerator(int length) {
this.length = length;
}
@Override
public String generate() {
Random random = new Random();
StringBuilder randomPart = new StringBuilder();
for (int i = 0; i < length; i++) {
randomPart.append(random.nextInt(10));
}
return randomPart.toString();
}
}