public class GeneratorRepository extends Object implements Generators
| Constructor and Description |
|---|
GeneratorRepository(SourceOfRandomness random) |
| Modifier and Type | Method and Description |
|---|---|
<U> Generator<U> |
constructor(Class<U> type,
Class<?>... argumentTypes)
Gives a generator that can produce an instance of the type described
by a constructor of a given type that accepts the given types of
arguments.
|
Generator<?> |
field(Class<?> type,
String fieldName)
Gives a generator that can produce an instance of the type described
by the field with the given name and containing type.
|
Generator<?> |
field(Field field)
Gives a generator that can produce instances of the type of the
given reflected field.
|
<U> Generator<U> |
fieldsOf(Class<U> type)
Gives a generator that can produce an instance of the given type
by reflecting the class's fields on up its class hierarchy and
generating random values for them.
|
Generator<?> |
generatorFor(ParameterTypeContext parameter) |
<T extends Generator<?>> |
make(Class<T> genType,
Generator<?>... components)
Makes a new generator of the given type, provides it with access to
other available generators,
configures it with any configuration annotations present on the
generator type, and supplies it any
component generators it needs.
|
<T> Generator<T> |
oneOf(Class<? extends T> first,
Class<? extends T>... rest)
Gives a generator that can produce instances of one of a given set of
related types on every generation.
|
<T> Generator<T> |
oneOf(Generator<? extends T> first,
Generator<? extends T>... rest)
Gives a generator that can produce instances of one of a given set of
related types on every generation.
|
Generator<?> |
parameter(Parameter parameter)
Gives a generator that can produce instances of the type of the
given reflected method parameter.
|
Generator<?> |
produceGenerator(ParameterTypeContext parameter) |
GeneratorRepository |
register(Generator<?> source) |
GeneratorRepository |
register(Iterable<Generator<?>> source) |
<T> Generator<T> |
type(Class<T> type,
Class<?>... componentTypes)
Gives a generator that can produce values of the given type,
parameterized by the given "component" types.
|
Generators |
withRandom(SourceOfRandomness other)
Makes a generator access point just like the receiver, but which
uses the given source of randomness for making random choices.
|
public GeneratorRepository(SourceOfRandomness random)
public GeneratorRepository register(Generator<?> source)
public GeneratorRepository register(Iterable<Generator<?>> source)
public Generator<?> field(Class<?> type, String fieldName)
GeneratorsGives a generator that can produce an instance of the type described by the field with the given name and containing type.
If the field is marked with an annotation that influences the generation of a given kind of value, that annotation will be applied to the resulting generator's values.
field in interface Generatorstype - containing type for a fieldfieldName - name of a fieldpublic <U> Generator<U> constructor(Class<U> type, Class<?>... argumentTypes)
GeneratorsGives a generator that can produce an instance of the type described by a constructor of a given type that accepts the given types of arguments. It will generate values for the parameters of the given constructor, and then invoke the constructor.
If the constructor's parameters are marked with annotations that influence the generation of a given kind of value, those annotations will be applied to the generators that will produce values to be used as arguments to the constructor.
constructor in interface GeneratorsU - type of objects produced by the resulting generatortype - containing type for a constructorargumentTypes - types of arguments to the constructorpublic <U> Generator<U> fieldsOf(Class<U> type)
GeneratorsGives a generator that can produce an instance of the given type by reflecting the class's fields on up its class hierarchy and generating random values for them.
The given type must have an accessible zero-arg constructor.
If a field of the given type is marked with an annotation that influences the generation of a given kind of value, that annotation will be applied to the generation of values for that field.
fieldsOf in interface GeneratorsU - type of objects produced by the resulting generatortype - a typepublic <T> Generator<T> type(Class<T> type, Class<?>... componentTypes)
GeneratorsGives a generator that can produce values of the given type, parameterized by the given "component" types.
type in interface GeneratorsT - type of objects produced by the resulting generatortype - a typecomponentTypes - types for the "components" of the type, if anyComponentizedGeneratorpublic Generator<?> parameter(Parameter parameter)
GeneratorsGives a generator that can produce instances of the type of the given reflected method parameter.
If the parameter is marked with an annotation that influences the generation of its value, that annotation will be applied to the generation of values for that parameter's type.
parameter in interface Generatorsparameter - a reflected method parameterpublic Generator<?> field(Field field)
GeneratorsGives a generator that can produce instances of the type of the given reflected field.
If the field is marked with an annotation that influences the generation of its value, that annotation will be applied to the generation of values for that field's type.
field in interface Generatorsfield - a reflected field@SafeVarargs public final <T> Generator<T> oneOf(Class<? extends T> first, Class<? extends T>... rest)
GeneratorsGives a generator that can produce instances of one of a given set of related types on every generation.
On each generation, one of the available generators that can produce one of the named types will be chosen with (approximately) equal probability.
oneOf in interface GeneratorsT - type of objects produced by the resulting generatorfirst - first type of generated valuerest - other (related) types of generated values@SafeVarargs public final <T> Generator<T> oneOf(Generator<? extends T> first, Generator<? extends T>... rest)
GeneratorsGives a generator that can produce instances of one of a given set of related types on every generation.
On each generation, one of the given generators will be called upon with (approximately) equal probability.
oneOf in interface GeneratorsT - type of objects produced by the resulting generatorfirst - first generatorrest - other generatorspublic final <T extends Generator<?>> T make(Class<T> genType, Generator<?>... components)
GeneratorsMakes a new generator of the given type, provides it with access to other available generators, configures it with any configuration annotations present on the generator type, and supplies it any component generators it needs.
make in interface GeneratorsT - type of objects produced by the resulting generatorgenType - type of generator to createcomponents - any generators for components of the typeComponentizedGeneratorpublic final Generators withRandom(SourceOfRandomness other)
GeneratorsMakes a generator access point just like the receiver, but which uses the given source of randomness for making random choices.
Intended for use by junit-quickcheck.
withRandom in interface Generatorsother - a source of randomnesspublic Generator<?> produceGenerator(ParameterTypeContext parameter)
public Generator<?> generatorFor(ParameterTypeContext parameter)
Copyright © 2019. All rights reserved.