io.javarig.generator.primitive.ByteGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-random-generator Show documentation
Show all versions of java-random-generator Show documentation
This project aims to provide a random instances generator for any class in java, it iterates through setters of an empty object and sets the fields values (using Java reflection api) randomly
The newest version!
package io.javarig.generator.primitive;
import io.javarig.RandomInstanceGenerator;
import io.javarig.generator.TypeGenerator;
import java.lang.reflect.Type;
public class ByteGenerator extends TypeGenerator {
public ByteGenerator(Type type, RandomInstanceGenerator randomInstanceGenerator) {
super(type, randomInstanceGenerator);
}
@Override
public Byte generate() {
byte[] bytes = new byte[1];
getRandom().nextBytes(bytes);
return bytes[0];
}
}