public interface DataProviderStrategy
PODAM is a tool to fill POJOs with data. There are different requirements
when it comes to which data POJOs should be filled with. The default strategy
adopted by PODAM is to fill POJOs with random data. However other
requirements might dictate to assign deterministic data using sequences, or
other predictable sources of data. In order to do so, clients of PODAM will
have to provide an implementation of this interface and pass it to the
constructor of the PodamFactoryImpl class.
| Modifier and Type | Interface and Description |
|---|---|
static class |
DataProviderStrategy.Order
Specifies how to sort constructors
|
| Modifier and Type | Method and Description |
|---|---|
<T> DataProviderStrategy |
addOrReplaceSpecific(Class<T> abstractClass,
Class<? extends T> specificClass)
Bind an interface/abstract class to a specific implementation.
|
<T> DataProviderStrategy |
addOrReplaceTypeManufacturer(Class<? extends T> type,
TypeManufacturer<T> typeManufacturer)
Registers @TypeManufacturer implementation, which will be used to
instantiate objects of a specified type.
|
void |
cacheMemoizedObject(AttributeMetadata attributeMetadata,
Object instance)
Saves object in memoization cache
|
void |
clearMemoizationCache()
Clears memoization cache
|
Class<?> |
getFactoryClass(Class<?> nonInstantiatableClass)
Resolves factory classes for abstract classes and interfaces.
|
int |
getMaxDepth(Class<?> type)
Returns how many times it is allowed to PODAM to create an instance
of the same class in a recursive hierarchy
|
Object |
getMemoizedObject(AttributeMetadata attributeMetadata)
Obtains object from memoization cache
|
int |
getNumberOfCollectionElements(Class<?> type)
Returns the number of default collection elements.
|
<T> Class<? extends T> |
getSpecificClass(Class<T> nonInstantiatableClass)
Resolves abstract classes and interfaces.
|
Class<AttributeStrategy<?>> |
getStrategyForAnnotation(Class<? extends Annotation> annotationClass)
Finds attribute strategies for annotations.
|
<T> T |
getTypeValue(AttributeMetadata attributeMetadata,
Map<String,Type> genericTypesArgumentsMap,
Class<T> pojoType)
Obtains a type value
|
boolean |
isMemoizationEnabled()
Returns whether the memoization setting is enabled.
|
<T> DataProviderStrategy |
removeSpecific(Class<T> abstractClass)
Remove binding of an interface/abstract class to a specific
implementation
|
<T> DataProviderStrategy |
removeTypeManufacturer(Class<T> type)
Remove binding of a class type to a specific
implementation of type manufacturer
|
void |
setDefaultNumberOfCollectionElements(int newNumberOfCollectionElements)
Sets the new default number of default collection elements.
|
void |
setMemoization(boolean isMemoizationEnabled)
Sets whether memoization is enabled
|
void |
sort(Constructor<?>[] constructors,
DataProviderStrategy.Order order)
Rearranges POJO's constructors in order they will be tried to
produce the POJO.
|
void |
sort(Method[] methods,
DataProviderStrategy.Order order)
Rearranges POJO's methods in order they will be tried to
produce the POJO.
|
<T> DataProviderStrategy addOrReplaceTypeManufacturer(Class<? extends T> type, TypeManufacturer<T> typeManufacturer)
T - type of objects to be produced by the manufacturertype - the specific class type the specified manufacturer
will instantiate.typeManufacturer - type manufacturer implementation to be registered<T> DataProviderStrategy removeTypeManufacturer(Class<T> type)
T - type of objects to be produced by the manufacturertype - the specific class type to remove binding<T> T getTypeValue(AttributeMetadata attributeMetadata, Map<String,Type> genericTypesArgumentsMap, Class<T> pojoType)
T - type of returned objectattributeMetadata - The AttributeMetadata informationgenericTypesArgumentsMap - The generic attribute type argument typespojoType - The class of the requested type<T> DataProviderStrategy addOrReplaceSpecific(Class<T> abstractClass, Class<? extends T> specificClass)
T - return typeabstractClass - the interface/abstract class to bindspecificClass - the specific class implementing or extending
abstractClass.<T> DataProviderStrategy removeSpecific(Class<T> abstractClass)
T - return typeabstractClass - the interface/abstract class to remove bindingint getNumberOfCollectionElements(Class<?> type)
Implementations of this interface need to provide this value.
type - Type of collection's elementsvoid setDefaultNumberOfCollectionElements(int newNumberOfCollectionElements)
newNumberOfCollectionElements - The new number of collection elements.int getMaxDepth(Class<?> type)
Implementations of this interface need to provide this value.
type - Type of POJO to be createdboolean isMemoizationEnabled()
Implementations of this interface need to provide this value.
void setMemoization(boolean isMemoizationEnabled)
isMemoizationEnabled - whether memoization is enabledObject getMemoizedObject(AttributeMetadata attributeMetadata)
attributeMetadata - attribute metadata for instance to be fetchedvoid cacheMemoizedObject(AttributeMetadata attributeMetadata, Object instance)
attributeMetadata - attribute metadata for instance being memoizedinstance - object instance to save in memoization cachevoid clearMemoizationCache()
void sort(Constructor<?>[] constructors, DataProviderStrategy.Order order)
constructors - Array of POJO's constructorsorder - DataProviderStrategy.Order how to sort constructorsvoid sort(Method[] methods, DataProviderStrategy.Order order)
methods - Array of POJO's methodsorder - DataProviderStrategy.Order how to sort constructorsClass<?> getFactoryClass(Class<?> nonInstantiatableClass)
Should return factory class type, which can be used to instantiate an abstract class type or interface.
nonInstantiatableClass - Abstract class type or interfacenonInstantiatableClass.<T> Class<? extends T> getSpecificClass(Class<T> nonInstantiatableClass)
Should return specific class type, which can be instantiated and assigned to abstract class type or interface.
T - The type of class being resolvednonInstantiatableClass - Abstract class type or interfacenonInstantiatableClass.Class<AttributeStrategy<?>> getStrategyForAnnotation(Class<? extends Annotation> annotationClass)
Searches for mapping between annotations and attribute strategies, which will be used then for populating fields or constructor parameters.
annotationClass - Annotation class to inspectCopyright © 2016. All rights reserved.