Class GeneratorContext<Context extends GeneratorContext<Context>>
- java.lang.Object
-
- net.morimekta.providence.testing.generator.GeneratorContext<Context>
-
- Direct Known Subclasses:
SimpleGeneratorContext
public abstract class GeneratorContext<Context extends GeneratorContext<Context>> extends java.lang.Object
Context for generating messages with information related to each other. Also contains references to basic options affecting the generation like the random generator, and default max collection size.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
GeneratorContext(GeneratorBase base)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Generator<Context,T>
generatorFor(net.morimekta.providence.descriptor.PDeclaredDescriptor<T> descriptor)
Get the default generator for the given type.<T> Generator<Context,T>
generatorFor(net.morimekta.providence.descriptor.PDescriptor descriptor)
Get the default generator for the given type.double
getDefaultFillRate()
int
getDefaultMaxCollectionSize()
io.codearte.jfairy.Fairy
getFairy()
java.util.Random
getRandom()
int
nextDefaultCollectionSize()
Convenience method to get the next collection size based on the default max collection size.
-
-
-
Constructor Detail
-
GeneratorContext
protected GeneratorContext(GeneratorBase base)
-
-
Method Detail
-
getFairy
@Nonnull public io.codearte.jfairy.Fairy getFairy()
- Returns:
- The current fairy instance.
-
getRandom
@Nonnull public java.util.Random getRandom()
- Returns:
- The current random instance.
-
getDefaultMaxCollectionSize
public int getDefaultMaxCollectionSize()
- Returns:
- The default max collection size.
-
getDefaultFillRate
public double getDefaultFillRate()
- Returns:
- The current default fill rate.
-
generatorFor
public <T> Generator<Context,T> generatorFor(@Nonnull net.morimekta.providence.descriptor.PDeclaredDescriptor<T> descriptor)
Get the default generator for the given type.- Type Parameters:
T
- The instance type.- Parameters:
descriptor
- The type descriptor.- Returns:
- The generator.
-
generatorFor
public <T> Generator<Context,T> generatorFor(@Nonnull net.morimekta.providence.descriptor.PDescriptor descriptor)
Get the default generator for the given type.- Type Parameters:
T
- The instance type.- Parameters:
descriptor
- The type descriptor.- Returns:
- The generator.
-
nextDefaultCollectionSize
public int nextDefaultCollectionSize()
Convenience method to get the next collection size based on the default max collection size.- Returns:
- The next collection size.
-
-