Package org.instancio.generator
Interface ValueSpec<T>
- Type Parameters:
T
- type of value
- All Superinterfaces:
GeneratorSpec<T>
- All Known Subinterfaces:
BigDecimalSpec
,BigIntegerSpec
,BooleanSpec
,ByteSpec
,CharacterSpec
,DoubleSpec
,FilePathSpec<T>
,FileSpec
,FloatSpec
,InstantSpec
,IntegerSpec
,LocalDateSpec
,LocalDateTimeSpec
,LocalTimeSpec
,LongSpec
,LoremIpsumSpec
,NumberSpec<T>
,OffsetDateTimeSpec
,OffsetTimeSpec
,OneOfArraySpec<T>
,OneOfCollectionSpec<T>
,PathSpec
,ShortSpec
,StringSpec
,TemporalSpec<T>
,URISpec
,URLSpec
,UUIDStringSpec
,YearMonthSpec
,YearSpec
,ZonedDateTimeSpec
- All Known Implementing Classes:
BigDecimalGenerator
,BigIntegerGenerator
,BooleanGenerator
,ByteGenerator
,CharacterGenerator
,DoubleGenerator
,FileGenerator
,FloatGenerator
,InstantGenerator
,IntegerGenerator
,LocalDateGenerator
,LocalDateTimeGenerator
,LocalTimeGenerator
,LongGenerator
,LoremIpsumGenerator
,OffsetDateTimeGenerator
,OffsetTimeGenerator
,OneOfArrayGenerator
,OneOfCollectionGenerator
,PathGenerator
,ShortGenerator
,StringGenerator
,TextPatternGenerator
,URIGenerator
,URLGenerator
,UUIDStringGenerator
,YearGenerator
,YearMonthGenerator
,ZonedDateTimeGenerator
A spec for generating simple value types, such as strings, numbers,
dates, and so on.
Provides support for the shorthand API:
String s = Instancio.string().length(10).prefix("foo").get();
- Since:
- 2.6.0
-
Method Summary
-
Method Details
-
get
Generates a single value.- Returns:
- a random value
- Since:
- 2.6.0
-
list
Generates a list of values of specified size.- Parameters:
size
- of the list to generate- Returns:
- a list of random values
- Since:
- 2.6.0
-
stream
Returns an infiniteStream
of values.Since the stream is infinite,
Stream.limit(long)
must be called to avoid an infinite loop.- Returns:
- an infinite stream of values
- Since:
- 2.6.0
-
map
Maps the generated value using the specified function.- Type Parameters:
R
- result type- Parameters:
fn
- mapping function- Returns:
- the result of the mapping function
- Since:
- 2.6.0
-
toModel
Returns the spec as aModel
.Example:
Model<String> stringModel = Gen.string().length(10).digits().toModel(); String result = Instancio.create(stringModel);
- Returns:
- spec as a model
- Since:
- 2.6.0
-