Class PeriodGenerator
java.lang.Object
org.instancio.internal.generator.AbstractGenerator<Period>
org.instancio.internal.generator.time.PeriodGenerator
- All Implemented Interfaces:
Generator<Period>,GeneratorSpec<Period>,NullableGeneratorSpec<Period>,PeriodGeneratorSpec,PeriodSpec,ValueSpec<Period>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the public API method name of the generator spec.days(int min, int max) Generate number ofPerioddays in the given range.months(int min, int max) Generate number ofPeriodmonths in the given range.nullable()Indicates thatnullvalue can be generated.protected PeriodtryGenerateNonNull(Random random) Makes the best effort to return a non-null value.years(int min, int max) Generate number ofPeriodyears in the given range.Methods inherited from class org.instancio.internal.generator.AbstractGenerator
generate, getContext, hints, isNullable, nullable
-
Constructor Details
-
PeriodGenerator
public PeriodGenerator() -
PeriodGenerator
-
-
Method Details
-
apiMethod
Description copied from class:AbstractGeneratorReturns the public API method name of the generator spec. The returned name is used for reporting validation errors.- Specified by:
apiMethodin classAbstractGenerator<Period>- Returns:
- spec name if defined, or
nullotherwise
-
days
Description copied from interface:PeriodGeneratorSpecGenerate number ofPerioddays in the given range.- Specified by:
daysin interfacePeriodGeneratorSpec- Specified by:
daysin interfacePeriodSpec- Parameters:
min- minimum number of days (inclusive)max- maximum number of days (inclusive)- Returns:
- spec builder
-
months
Description copied from interface:PeriodGeneratorSpecGenerate number ofPeriodmonths in the given range.- Specified by:
monthsin interfacePeriodGeneratorSpec- Specified by:
monthsin interfacePeriodSpec- Parameters:
min- minimum number of months (inclusive)max- maximum number of months (inclusive)- Returns:
- spec builder
-
years
Description copied from interface:PeriodGeneratorSpecGenerate number ofPeriodyears in the given range.- Specified by:
yearsin interfacePeriodGeneratorSpec- Specified by:
yearsin interfacePeriodSpec- Parameters:
min- minimum number of years (inclusive)max- maximum number of years (inclusive)- Returns:
- spec builder
-
nullable
Description copied from interface:NullableGeneratorSpecIndicates thatnullvalue can be generated.- Specified by:
nullablein interfaceNullableGeneratorSpec<Period>- Specified by:
nullablein interfaceValueSpec<Period>- Overrides:
nullablein classAbstractGenerator<Period>- Returns:
- spec builder
-
tryGenerateNonNull
Description copied from class:AbstractGeneratorMakes the best effort to return a non-null value. However, in certain cases this method will produce anull.- Specified by:
tryGenerateNonNullin classAbstractGenerator<Period>- Parameters:
random- for generating the value- Returns:
- generated value, either a null or non-null
-