Package dev.orne.test.rnd
Interface Generator
- All Known Subinterfaces:
ParameterizableGenerator
,TypedGenerator<T>
,TypedParameterizableGenerator<T>
- All Known Implementing Classes:
AbstractGenerator
,AbstractParameterizableGenerator
,AbstractPrimitiveGenerator
,AbstractTypedGenerator
,AbstractTypedParameterizableGenerator
,AnnotatedMethodGenerator
,ArrayGenerator
,BigDecimalGenerator
,BigIntegerGenerator
,BooleanGenerator
,ByteGenerator
,CalendarGenerator
,CharacterGenerator
,CharsetGenerator
,ChronologyGenerator
,ClockGenerator
,ConstructorGenerator
,CurrencyGenerator
,DateGenerator
,DoubleGenerator
,DurationGenerator
,EnumGenerator
,ExecutableGenerator
,FactoryMethodGenerator
,FileGenerator
,FloatGenerator
,Generators.MissingGenerator
,InstantGenerator
,IntegerGenerator
,ListGenerator
,LocalDateGenerator
,LocalDateTimeGenerator
,LocaleGenerator
,LocalTimeGenerator
,LongGenerator
,MapGenerator
,MonthDayGenerator
,OffsetDateTimeGenerator
,OffsetTimeGenerator
,PathGenerator
,PeriodGenerator
,SetGenerator
,ShortGenerator
,StringGenerator
,TimeZoneGenerator
,URIGenerator
,URLGenerator
,UUIDGenerator
,YearGenerator
,YearMonthGenerator
,ZonedDateTimeGenerator
,ZoneIdGenerator
,ZoneOffsetGenerator
@API(status=STABLE,
since="0.1")
public interface Generator
Interface for random value generators.
- Since:
- 0.1
- Version:
- 1.0, 2021-03
- Author:
- (w) Iker Hernaez
-
Method Summary
Modifier and TypeMethodDescriptiondefault @NotNull ParameterizableGenerator
Returns this generator as a parameterizable generator.<T> T
defaultValue
(@NotNull Class<T> type) Returns the default value for the specified type.default int
Returns the priority of this generator.<T> T
nullableDefaultValue
(@NotNull Class<T> type) Returns the default value for the specified type allowingnull
values.<T> T
nullableRandomValue
(@NotNull Class<T> type) Returns a random value of the specified type allowingnull
values.<T> T
randomValue
(@NotNull Class<T> type) Returns a random value of the specified type.boolean
Checks if values of the specified type can be generated by this instance.
-
Method Details
-
supports
Checks if values of the specified type can be generated by this instance.- Parameters:
type
- The type to check.- Returns:
- If values of the specified type can be generated.
-
defaultValue
Returns the default value for the specified type.- Type Parameters:
T
- The requested value type.- Parameters:
type
- The requested value type.- Returns:
- The default value for the specified type.
- Throws:
UnsupportedValueTypeException
- If the specified type is not supported.GenerationException
- If an error occurs generating the value
-
nullableDefaultValue
Returns the default value for the specified type allowingnull
values.This method should return
null
except for native types.- Type Parameters:
T
- The requested value type.- Parameters:
type
- The requested value type.- Returns:
- The nullable default value for the specified type.
- Throws:
UnsupportedValueTypeException
- If the specified type is not supported.GenerationException
- If an error occurs generating the value
-
randomValue
Returns a random value of the specified type.- Type Parameters:
T
- The requested value type.- Parameters:
type
- The requested value type.- Returns:
- A random value for the specified type.
- Throws:
UnsupportedValueTypeException
- If the specified type is not supported.GenerationException
- If an error occurs generating the value
-
nullableRandomValue
Returns a random value of the specified type allowingnull
values.The returned value has a probability of be
null
except for native types. If notnull
behaves asrandomValue()
.- Type Parameters:
T
- The requested value type.- Parameters:
type
- The requested value type.- Returns:
- A random nullable value for the specified type.
- Throws:
UnsupportedValueTypeException
- If the specified type is not supported.GenerationException
- If an error occurs generating the value- See Also:
-
getPriority
default int getPriority()Returns the priority of this generator.- Returns:
- The priority of this generator
-
asParameterizable
Returns this generator as a parameterizable generator.If the generator is not parameterizable throws an exception.
- Returns:
- This generator as a parameterizable generator.
- Throws:
GeneratorNotParameterizableException
- If the generator is not parameterizable.
-