Enum NativeSeedType
- All Implemented Interfaces:
Serializable
,Comparable<NativeSeedType>
,java.lang.constant.Constable
The native seed type. Contains values for all native seed types and methods
to convert supported seed types to the native seed type.
Valid native seed types are:
Integer
Long
int[]
long[]
Valid types for seed conversion are:
Integer
(orint
)Long
(orlong
)int[]
long[]
byte[]
- Since:
- 1.3
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe seed type isInteger
.The seed type isint[]
.The seed type isLong
.The seed type islong[]
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
Define the number of bytes required to represent the native seed.private static final int
Maximum length of the seed array (for creating array seeds).private final Class
<?> Define the class type of the native seed.private static final String
Error message for unrecognised seed types. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
NativeSeedType
(Class<?> type, int bytes) Instantiates a new native seed type. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Object
convert
(byte[] seed, int size) Convert the inputbyte[]
seed to the native seed type.protected abstract Object
convert
(int[] seed, int size) Convert the inputint[]
seed to the native seed type.protected abstract Object
convert
(long[] seed, int size) Convert the inputlong[]
seed to the native seed type.protected abstract Object
Convert the inputInteger
seed to the native seed type.protected abstract Object
Convert the inputLong
seed to the native seed type.convertSeed
(Object seed, int size) Converts the input seed from any of the supported seed types to the native seed type.static byte[]
convertSeedToBytes
(Object seed) Converts the input seed from any of the supported seed types to bytes.createSeed
(int size) Creates the seed.abstract Object
createSeed
(int size, int from, int to) Creates the seed.int
getBytes()
Gets the number of bytes required to represent the native seed type.Class
<?> getType()
Gets the class type of the native seed.private static String
Create an unrecognised seed message.static NativeSeedType
Returns the enum constant of this type with the specified name.static NativeSeedType[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
INT
The seed type isInteger
. -
LONG
The seed type isLong
. -
INT_ARRAY
The seed type isint[]
. -
LONG_ARRAY
The seed type islong[]
.
-
-
Field Details
-
UNRECOGNISED_SEED
Error message for unrecognised seed types.- See Also:
-
RANDOM_SEED_ARRAY_SIZE
private static final int RANDOM_SEED_ARRAY_SIZEMaximum length of the seed array (for creating array seeds).- See Also:
-
type
Define the class type of the native seed. -
bytes
private final int bytesDefine the number of bytes required to represent the native seed. If the type is an array then this represents the size of a single value of the type.
-
-
Constructor Details
-
NativeSeedType
Instantiates a new native seed type.- Parameters:
type
- Define the class type of the native seed.bytes
- Define the number of bytes required to represent the native seed.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException
- if the argument is null
-
getType
Gets the class type of the native seed.- Returns:
- the type
-
getBytes
public int getBytes()Gets the number of bytes required to represent the native seed type. If the type is an array then this represents the size of a single value of the type.- Returns:
- the number of bytes
-
createSeed
Creates the seed. The output seed type is determined by the native seed type. If the output is an array the required size of the array can be specified.- Parameters:
size
- The size of the seed (array types only).- Returns:
- the seed
-
createSeed
Creates the seed. The output seed type is determined by the native seed type. If the output is an array the required size of the array can be specified and a sub-range that must not be all-zero.- Parameters:
size
- The size of the seed (array types only).from
- The start of the not all-zero sub-range (inclusive; array types only).to
- The end of the not all-zero sub-range (exclusive; array types only).- Returns:
- the seed
- Throws:
IndexOutOfBoundsException
- if the sub-range is out of bounds- Since:
- 1.5
-
convertSeed
Converts the input seed from any of the supported seed types to the native seed type. If the output is an array the required size of the array can be specified.- Parameters:
seed
- Input seed.size
- The size of the output seed (array types only).- Returns:
- the native seed.
- Throws:
UnsupportedOperationException
- if theseed
type is invalid.
-
convert
Convert the inputInteger
seed to the native seed type.- Parameters:
seed
- Input seed.size
- The size of the output seed (array types only).- Returns:
- the native seed.
-
convert
Convert the inputLong
seed to the native seed type.- Parameters:
seed
- Input seed.size
- The size of the output seed (array types only).- Returns:
- the native seed.
-
convert
Convert the inputint[]
seed to the native seed type.- Parameters:
seed
- Input seed.size
- The size of the output seed (array types only).- Returns:
- the native seed.
-
convert
Convert the inputlong[]
seed to the native seed type.- Parameters:
seed
- Input seed.size
- The size of the output seed (array types only).- Returns:
- the native seed.
-
convert
Convert the inputbyte[]
seed to the native seed type.- Parameters:
seed
- Input seed.size
- The size of the output seed (array types only).- Returns:
- the native seed.
-
convertSeedToBytes
Converts the input seed from any of the supported seed types to bytes.- Parameters:
seed
- Input seed.- Returns:
- the seed bytes.
- Throws:
UnsupportedOperationException
- if theseed
type is invalid.
-
unrecognisedSeedMessage
Create an unrecognised seed message. This will add the class type of the seed.- Parameters:
seed
- the seed- Returns:
- the message
-