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.
|
void |
cacheMemoizedObject(AttributeMetadata attributeMetadata,
Object instance)
Saves object in memoization cache
|
void |
clearMemoizationCache()
Clears memoization cache
|
Boolean |
getBoolean(AttributeMetadata attributeMetadata)
It returns a boolean/Boolean value.
|
Byte |
getByte(AttributeMetadata attributeMetadata)
It returns a byte/Byte value.
|
Byte |
getByteInRange(byte minValue,
byte maxValue,
AttributeMetadata attributeMetadata)
It returns a byte/Byte within min and max value (included).
|
Character |
getCharacter(AttributeMetadata attributeMetadata)
It returns a char/Character value.
|
Character |
getCharacterInRange(char minValue,
char maxValue,
AttributeMetadata attributeMetadata)
It returns a char/Character value between min and max value (included).
|
Double |
getDouble(AttributeMetadata attributeMetadata)
It returns a double/Double value
|
Double |
getDoubleInRange(double minValue,
double maxValue,
AttributeMetadata attributeMetadata)
It returns a double/Double value between min and max value (included).
|
Float |
getFloat(AttributeMetadata attributeMetadata)
It returns a float/Float value.
|
Float |
getFloatInRange(float minValue,
float maxValue,
AttributeMetadata attributeMetadata)
It returns a float/Float value between min and max value (included).
|
Integer |
getInteger(AttributeMetadata attributeMetadata)
It returns an int/Integer value.
|
int |
getIntegerInRange(int minValue,
int maxValue,
AttributeMetadata attributeMetadata)
It returns an int/Integer value between min and max value (included).
|
Long |
getLong(AttributeMetadata attributeMetadata)
It returns a long/Long value.
|
Long |
getLongInRange(long minValue,
long maxValue,
AttributeMetadata attributeMetadata)
It returns a long/Long value between min and max value (included).
|
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.
|
Short |
getShort(AttributeMetadata attributeMetadata)
It returns a short/Short value.
|
Short |
getShortInRange(short minValue,
short maxValue,
AttributeMetadata attributeMetadata)
It returns a short/Short value between min and max value (included).
|
<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.
|
String |
getStringOfLength(int length,
AttributeMetadata attributeMetadata)
It returns a String of
length characters. |
String |
getStringValue(AttributeMetadata attributeMetadata)
It returns a string 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
|
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 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 bindingBoolean getBoolean(AttributeMetadata attributeMetadata)
attributeMetadata - attribute metadata for instance to be fetchedByte getByte(AttributeMetadata attributeMetadata)
attributeMetadata - attribute metadata for instance to be fetchedByte getByteInRange(byte minValue, byte maxValue, AttributeMetadata attributeMetadata)
minValue - The minimum value for the returned valuemaxValue - The maximum value for the returned valueattributeMetadata - attribute metadata for instance to be fetchedCharacter getCharacter(AttributeMetadata attributeMetadata)
attributeMetadata - attribute metadata for instance to be fetchedCharacter getCharacterInRange(char minValue, char maxValue, AttributeMetadata attributeMetadata)
minValue - The minimum value for the returned valuemaxValue - The maximum value for the returned valueattributeMetadata - attribute metadata for instance to be fetchedDouble getDouble(AttributeMetadata attributeMetadata)
attributeMetadata - attribute metadata for instance to be fetchedDouble getDoubleInRange(double minValue, double maxValue, AttributeMetadata attributeMetadata)
minValue - The minimum value for the returned valuemaxValue - The maximum value for the returned valueattributeMetadata - attribute metadata for instance to be fetchedFloat getFloat(AttributeMetadata attributeMetadata)
attributeMetadata - attribute metadata for instance to be fetchedFloat getFloatInRange(float minValue, float maxValue, AttributeMetadata attributeMetadata)
minValue - The minimum value for the returned valuemaxValue - The maximum value for the returned valueattributeMetadata - attribute metadata for instance to be fetchedInteger getInteger(AttributeMetadata attributeMetadata)
attributeMetadata - attribute metadata for instance to be fetchedint getIntegerInRange(int minValue,
int maxValue,
AttributeMetadata attributeMetadata)
minValue - The minimum value for the returned valuemaxValue - The maximum value for the returned valueattributeMetadata - attribute metadata for instance to be fetchedLong getLong(AttributeMetadata attributeMetadata)
attributeMetadata - attribute metadata for instance to be fetchedLong getLongInRange(long minValue, long maxValue, AttributeMetadata attributeMetadata)
minValue - The minimum value for the returned valuemaxValue - The maximum value for the returned valueattributeMetadata - attribute metadata for instance to be fetchedShort getShort(AttributeMetadata attributeMetadata)
attributeMetadata - attribute metadata for instance to be fetchedShort getShortInRange(short minValue, short maxValue, AttributeMetadata attributeMetadata)
minValue - The minimum value for the returned valuemaxValue - The maximum value for the returned valueattributeMetadata - attribute metadata for instance to be fetchedString getStringValue(AttributeMetadata attributeMetadata)
attributeMetadata - attribute metadata for instance to be fetchedString getStringOfLength(int length, AttributeMetadata attributeMetadata)
length characters.length - The number of characters required in the returned StringattributeMetadata - attribute metadata for instance to be fetchedlength charactersint 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 constructors<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 © 2015. All rights reserved.