public class RandomObjectFactory
extends java.lang.Object
| Constructor and Description |
|---|
RandomObjectFactory() |
| Modifier and Type | Method and Description |
|---|---|
static de.alpharogroup.random.enums.RandomAlgorithm |
newRandomAlgorithm()
Factory method for create a new random
RandomAlgorithm object |
static java.lang.Byte[] |
newRandomByteObjects(int length)
Factory method for create a new random
Byte object array |
static java.lang.Float |
newRandomFloat(int afterComma,
int beforeComma)
Factory method for create a new random
Float object |
static <T> T |
newRandomObject(@NonNull java.lang.Class<T> cls,
java.lang.String... ignoreFieldNames)
Factory method for create a new random object of the given
Class. |
static java.lang.Object |
newRandomValue(java.lang.reflect.Field field)
Factory method for create a new random value for the given
field |
static <T> T |
setRandomValues(@NonNull java.lang.Class<T> cls,
T instance,
java.lang.String... ignoreFieldNames)
Sets the random values to the fields of the given instance
|
public static de.alpharogroup.random.enums.RandomAlgorithm newRandomAlgorithm()
RandomAlgorithm objectpublic static java.lang.Float newRandomFloat(int afterComma,
int beforeComma)
Float objectafterComma - How many decimal places after the commabeforeComma - How many decimal places before the commaFloat objectpublic static java.lang.Byte[] newRandomByteObjects(int length)
Byte object arraylength - the length.public static <T> T newRandomObject(@NonNull
@NonNull java.lang.Class<T> cls,
java.lang.String... ignoreFieldNames)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException,
java.lang.NoSuchFieldException
Class.T - the generic typecls - the classignoreFieldNames - an optional array with the field names that shell be ignoredjava.lang.IllegalAccessException - is thrown if the class or its default constructor is not accessible.java.lang.InstantiationException - is thrown if this Class represents an abstract class, an interface, an
array class, a primitive type, or void; or if the class has no default
constructor; or if the instantiation fails for some other reason.java.lang.NoSuchFieldException - is thrown if no such field existspublic static <T> T setRandomValues(@NonNull
@NonNull java.lang.Class<T> cls,
@NonNull
T instance,
java.lang.String... ignoreFieldNames)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException,
java.lang.NoSuchFieldException
T - the generic typecls - the clsinstance - the instance to set random valuesignoreFieldNames - the ignore field namesjava.lang.IllegalAccessException - is thrown if the class or its default constructor is not accessible.java.lang.InstantiationException - is thrown if this Class represents an abstract class, an interface, an
array class, a primitive type, or void; or if the class has no default
constructor; or if the instantiation fails for some other reason.java.lang.NoSuchFieldException - is thrown if no such field existspublic static java.lang.Object newRandomValue(java.lang.reflect.Field field)
throws java.lang.IllegalAccessException,
java.lang.InstantiationException,
java.lang.NoSuchFieldException
fieldfield - the fieldjava.lang.IllegalAccessException - is thrown if the class or its default constructor is not accessible.java.lang.InstantiationException - is thrown if this Class represents an abstract class, an interface, an
array class, a primitive type, or void; or if the class has no default
constructor; or if the instantiation fails for some other reason.java.lang.NoSuchFieldException - is thrown if no such field exists