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 ParameterizableGeneratorReturns this generator as a parameterizable generator.<T> TdefaultValue(@NotNull Class<T> type) Returns the default value for the specified type.default intReturns the priority of this generator.<T> TnullableDefaultValue(@NotNull Class<T> type) Returns the default value for the specified type allowingnullvalues.<T> TnullableRandomValue(@NotNull Class<T> type) Returns a random value of the specified type allowingnullvalues.<T> TrandomValue(@NotNull Class<T> type) Returns a random value of the specified type.booleanChecks 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 allowingnullvalues.This method should return
nullexcept 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 allowingnullvalues.The returned value has a probability of be
nullexcept for native types. If notnullbehaves 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.
-