Package de.cuioss.test.generator.impl
Enum Class PrimitiveArrayGenerators
- All Implemented Interfaces:
Serializable,Comparable<PrimitiveArrayGenerators>,Constable
Provides generators for arrays of all Java primitive types.
Each generator creates arrays of random length (1-128 elements) with random values
appropriate for the primitive type.
Available generators:
BOOLEAN- boolean[] arrays with random true/false valuesBYTE- byte[] arrays with random byte valuesCHAR- char[] arrays with random character valuesSHORT- short[] arrays with random short valuesINTEGER- int[] arrays with random integer valuesLONG- long[] arrays with random long valuesFLOAT- float[] arrays with random float valuesDOUBLE- double[] arrays with random double values
Example usage:
// Generate arrays of different primitive types boolean[] booleans = (boolean[]) PrimitiveArrayGenerators.BOOLEAN.next(); int[] integers = (int[]) PrimitiveArrayGenerators.INTEGER.next(); // Get a generator for a specific primitive type var generator = PrimitiveArrayGenerators.resolveForType(int.class); int[] moreIntegers = (int[]) generator.next();
Implementation notes:
- All generators are thread-safe
- Array size is randomly chosen between 1 and 128 elements
- Values are generated using the corresponding primitive generators from
Generators
- Author:
- Oliver Wolff
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionabstract Class<?> getType()abstract Objectnext()static PrimitiveArrayGeneratorsresolveForType(Class<?> primitiveType) Returns aPrimitiveArrayGeneratorsfor the given primitive type.static PrimitiveArrayGeneratorsReturns the enum constant of this class with the specified name.static PrimitiveArrayGenerators[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
BOOLEAN
Provides booleans -
BYTE
Provides bytes -
CHAR
Provides chars -
SHORT
Provides shorts -
INTEGER
Provides integers -
LONG
Provides longs -
FLOAT
Provides floats -
DOUBLE
Provides doubles
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
next
- Returns:
- an primitive array of the configured type, with the sizes 1-128
-
getType
- Returns:
- the type of the primitive
-
resolveForType
Returns aPrimitiveArrayGeneratorsfor the given primitive type.- Parameters:
primitiveType- must not be null and a primitive type.- Returns:
- the found
PrimitiveArrayGeneratorsor throws anIllegalStateExceptionif none could be found
-