public class BeanBuilder<T> extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> BeanBuilder<T> |
anEmptyInstanceOf(Class<T> type)
Return an instance of a
BeanBuilder for the given type which is populated with empty objects but
collections, maps, etc which have empty objects. |
static <T> BeanBuilder<T> |
anEmptyInstanceOf(Class<T> type,
String rootName)
Return an instance of a
BeanBuilder for the given type which is populated with empty objects but
collections, maps, etc which have empty objects. |
static <T> BeanBuilder<T> |
anInstanceOf(Class<T> type)
Return an instance of a
BeanBuilder for the given type which can then be populated with values either
manually or automatically. |
static <T> BeanBuilder<T> |
anInstanceOf(Class<T> type,
String rootName)
Return an instance of a
BeanBuilder for the given type which can then be populated with values either
manually or automatically. |
static <T> BeanBuilder<T> |
aRandomInstanceOf(Class<T> type)
Return an instance of a
BeanBuilder for the given type which is populated with random values. |
static <T> BeanBuilder<T> |
aRandomInstanceOf(Class<T> type,
String rootName)
Return an instance of a
BeanBuilder for the given type which is populated with random values. |
T |
build()
Build the configured instance.
|
BeanBuilder<T> |
collectionSizeForPathOf(String path,
int size)
Configure the builder to set the size of a collection for a path to within a given range.
|
BeanBuilder<T> |
collectionSizeForPropertyOf(String property,
int size)
Configure the builder to set the size of a collection at a path.
|
BeanBuilder<T> |
collectionSizeOf(int size)
Configure the builder to set the size of a collections.
|
BeanBuilder<T> |
collectionSizeRangeForPathOf(String path,
int min,
int max)
Configure the builder to set the size of a collection at a path to within a given range.
|
BeanBuilder<T> |
collectionSizeRangeForPropertyOf(String property,
int min,
int max)
Configure the builder to set the size of a collection at a path to within a given range.
|
BeanBuilder<T> |
collectionSizeRangeOf(int min,
int max)
Configure the builder to set the size of a collections to within a given range.
|
BeanBuilder<T> |
excludePath(String path)
Configure the builder to exclude the given path from being populated.
|
BeanBuilder<T> |
excludeProperty(String propertyName)
Configure the builder to exclude the given property from being populated.
|
<X> BeanBuilder<T> |
factory(Class<X> type,
ValueFactory<X> factory)
Configure the builder to populate any properties of the given type with a value created by the supplied value
factory.
|
BeanBuilder<T> |
path(String path,
Object value)
Configure the builder to populate the given path with the supplied value.
|
BeanBuilder<T> |
path(String path,
ValueFactory<?> factory)
Configure the builder to populate the given path with a value created by the supplied value factory.
|
BeanBuilder<T> |
property(String propertyName,
Object value)
Configure the builder to populate the given property with the supplied value.
|
BeanBuilder<T> |
property(String propertyName,
ValueFactory<?> factory)
Configure the builder to populate the given property with a value created by the supplied value factory.
|
<X> BeanBuilder<T> |
subtype(Class<X> supertype,
Class<? extends X>... subtypes)
Configure the builder to use any of of a particular subtype when instantiating a super type.
|
<X> BeanBuilder<T> |
subtype(Class<X> supertype,
Class<? extends X> subtype)
Configure the builder to use a particular subtype when instantiating a super type.
|
<V> BeanBuilder<T> |
with(Class<V> type,
ValueFactory<V> factory)
Configure the builder to populate any properties of the given type with a value created by the supplied value
factory.
|
BeanBuilder<T> |
with(String propertyOrPathName,
Object value)
Configure the builder to populate the given property or path with the supplied value.
|
BeanBuilder<T> |
with(String propertyOrPathName,
ValueFactory<?> factory)
Configure the builder to populate the given property or path with a value created by the supplied value factory.
|
public static <T> BeanBuilder<T> anInstanceOf(Class<T> type)
BeanBuilder for the given type which can then be populated with values either
manually or automatically. For example:
Person aPerson = BeanBuilder.anInstanceOf(Person.class)
.path("person.firstName", "Bob")
.build()
type - the type to return the BeanBuilder forpublic static <T> BeanBuilder<T> anInstanceOf(Class<T> type, String rootName)
BeanBuilder for the given type which can then be populated with values either
manually or automatically. For example:
Person aPerson = BeanBuilder.anInstanceOf(Person.class, "instance")
.path("instance.firstName", "Bob")
.build()
type - the type to return the BeanBuilder forrootName - the name give to the root entity when referencing pathspublic static <T> BeanBuilder<T> anEmptyInstanceOf(Class<T> type)
BeanBuilder for the given type which is populated with empty objects but
collections, maps, etc which have empty objects. For example:
Person aPerson = BeanBuilder.anEmptyInstanceOf(Person.class).path("person.firstName", "Bob").build();
type - the type to return the BeanBuilder forpublic static <T> BeanBuilder<T> anEmptyInstanceOf(Class<T> type, String rootName)
BeanBuilder for the given type which is populated with empty objects but
collections, maps, etc which have empty objects. For example:
Person aPerson = BeanBuilder.anEmptyInstanceOf(Person.class, "instance")
.path("instance.firstName", "Bob")
.build()
type - the type to return the BeanBuilder forrootName - the name give to the root entity when referencing pathspublic static <T> BeanBuilder<T> aRandomInstanceOf(Class<T> type)
BeanBuilder for the given type which is populated with random values. For
example:
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.path("person.firstName", "Bob")
.build()
type - the type to return the BeanBuilder forpublic static <T> BeanBuilder<T> aRandomInstanceOf(Class<T> type, String rootName)
BeanBuilder for the given type which is populated with random values. For
example:
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class,"instance")
.path("instance.firstName", "Bob")
.build()
type - the type to return the BeanBuilder forpublic BeanBuilder<T> with(String propertyOrPathName, Object value)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.with("firstName", "Bob")
.build()
propertyOrPathName - the property or path name to set the value onvalue - the value to assign the property or pathpublic <V> BeanBuilder<T> with(Class<V> type, ValueFactory<V> factory)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.with(Date.class, ValueFactories.oneOf(APR(5,1975), APR(5,1985)))
.build()
type - the type of property to use the factory forfactory - the factory to use to create the valuepublic BeanBuilder<T> with(String propertyOrPathName, ValueFactory<?> factory)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.with("firstName", ValueFactories.oneOf("Bob", "Alice"))
.build()
propertyOrPathName - the property or path name to set the value onfactory - the factory to use to create the valuepublic BeanBuilder<T> property(String propertyName, Object value)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.property("firstName", "Bob")
.build()
propertyName - the property to set the value onvalue - the value to assign the propertypublic BeanBuilder<T> property(String propertyName, ValueFactory<?> factory)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.property("firstName", ValueFactories.oneOf("Bob", "Alice"))
.build()
propertyName - the property to set the value onfactory - the factory to use to create the valuepublic <X> BeanBuilder<T> factory(Class<X> type, ValueFactory<X> factory)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.factory(Date.class, ValueFactories.oneOf(APR(5,1975), APR(5,1985)))
.build()
type - the type of property to use the factory forfactory - the factory to use to create the valuepublic BeanBuilder<T> excludeProperty(String propertyName)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.excludeProperty("firstName")
.build()
propertyName - the property to excludepublic BeanBuilder<T> path(String path, Object value)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.path("person.firstName", "Bob")
.build()
path - the path to set the value onvalue - the value to assign the pathpublic BeanBuilder<T> path(String path, ValueFactory<?> factory)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.path("person.firstName", ValueFactories.oneOf("Bob", "Alice"))
.build()
path - the path to set the value onfactory - the factory to use to create the valuepublic BeanBuilder<T> excludePath(String path)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.excludeProperty("person.firstName")
.build()
path - the path to excludepublic BeanBuilder<T> collectionSizeOf(int size)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.collectionSizeOf(5)
.build()
size - the size to create the collectionspublic BeanBuilder<T> collectionSizeRangeOf(int min, int max)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.collectionSizeRangeOf(2,10)
.build()
min - the minimum size to create the collectionsmax - the maximum size to create the collectionspublic BeanBuilder<T> collectionSizeRangeForPropertyOf(String property, int min, int max)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.collectionSizeRangeForPropertyOf("sublings", 1,3)
.build()
property - the name of the property to limit the collection size ofmin - the minimum size to create the collectionsmax - the maximum size to create the collectionspublic BeanBuilder<T> collectionSizeForPropertyOf(String property, int size)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.collectionSizeForPropertyOf("sublings", 3)
.build()
property - the name of the property to limit the collection size ofsize - the size to create the collectionpublic BeanBuilder<T> collectionSizeForPathOf(String path, int size)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.collectionSizeForPathOf("person.sublings", 1, 3)
.build()
path - the path to limit the collection size ofsize - the size to create the collectionpublic BeanBuilder<T> collectionSizeRangeForPathOf(String path, int min, int max)
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.collectionSizeRangeForPathOf("person.siblings", 1,3)
.build()
path - the name of the path to limit the collection size ofmin - the minimum size to create the collectionmax - the maximum size to create the collectionpublic <X> BeanBuilder<T> subtype(Class<X> supertype, Class<? extends X> subtype)
ShapeSorter aSorter = BeanBuilder.aRandomInstanceOf(ShapeSorter.class)
.subtype(Shape.class, Square.class)
.build()
supertype - the type of the super typesubtype - the subtype to use when instantiating the super typepublic <X> BeanBuilder<T> subtype(Class<X> supertype, Class<? extends X>... subtypes)
ShapeSorter aSorter = BeanBuilder.aRandomInstanceOf(ShapeSorter.class)
.subtype(Shape.class, Square.class, Circle.class, Triangle.class)
.build()
supertype - the type of the super typesubtypes - the subtypes to pick from when instantiating the super typepublic T build()
Person aPerson = BeanBuilder.aRandomInstanceOf(Person.class)
.path("person.firstName", "Bob")
.path("person.age", oneOf(25,35))
.build()
Copyright © 2018. All rights reserved.