|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.progeeks.tool.gen.BaseDataGenerator
org.progeeks.tool.gen.ConditionalGenerator
public class ConditionalGenerator
A DataGenerator
that selects a sub-generator to generate data based on a set of
conditions. The generator takes a map where both the keys and the values are DataGenerators. The
DataGenerator.isDataValid(Object, DataGeneratorContext)
method of the key DataGenerators
is called on the interestProperty
property from the proper object in the passed
context (or the object itself if interestProperty
is not set). If
isDataValid
returns true, then the
DataGenerator.generateData(DataGeneratorContext)
method of the value DataGenerator is
invoked. A default generator can be set if no conditions match.
Field Summary | |
---|---|
protected static Log |
log
|
Fields inherited from class org.progeeks.tool.gen.BaseDataGenerator |
---|
allowNull, nullPercentage |
Constructor Summary | |
---|---|
ConditionalGenerator()
|
Method Summary | |
---|---|
protected java.lang.Object |
generateRealData(DataGeneratorContext context)
Iterate over the keys in the conditionCheckers. |
java.util.Map |
getConditionCheckers()
|
DataGenerator |
getDefaultGenerator()
|
int |
getInterestLevel()
|
java.lang.String |
getInterestProperty()
|
protected java.lang.Object |
getReferenceObject(DataGeneratorContext context)
Gets the appropriate reference from the context, and gets the value for the interestProperty if there is one. |
void |
setConditionCheckers(java.util.Map conditionCheckers)
|
void |
setDefaultGenerator(DataGenerator defaultGenerator)
Generator to be invoked if none of the conditions evaluate to true. |
void |
setInterestLevel(int interestLevel)
The level in the passed context to use as the reference for the conditionCheckers. |
void |
setInterestProperty(java.lang.String interestProperty)
The property within the referenced object that is to be evaluated by the conditionCheckers. |
protected boolean |
testData(java.lang.Object testItem,
DataGeneratorContext context)
Uses the same process as generateRealData for moving through the
conditionCheckers and then invokes isDataValid on the value generator
associated with whatever conditionChecker was matched. |
Methods inherited from class org.progeeks.tool.gen.BaseDataGenerator |
---|
generateData, getAllowNull, getDataClass, getDataClazz, getEnforceResolvable, getNullPercentage, isDataValid, setAllowNull, setDataClass, setEnforceResolvable, setNullPercentage |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Log log
Constructor Detail |
---|
public ConditionalGenerator()
Method Detail |
---|
protected java.lang.Object generateRealData(DataGeneratorContext context)
generateRealData
in class BaseDataGenerator
protected boolean testData(java.lang.Object testItem, DataGeneratorContext context)
generateRealData
for moving through the
conditionCheckers and then invokes isDataValid
on the value generator
associated with whatever conditionChecker was matched.
testData
in class BaseDataGenerator
protected java.lang.Object getReferenceObject(DataGeneratorContext context)
context
- public java.util.Map getConditionCheckers()
public int getInterestLevel()
public java.lang.String getInterestProperty()
public void setConditionCheckers(java.util.Map conditionCheckers)
conditionCheckers
- The conditionCheckers to set. Should be a LinkedHashMap or other
implementation with a logical order of iteration through the keys.public void setInterestLevel(int interestLevel)
interestLevel
- The interestLevel to set.public void setInterestProperty(java.lang.String interestProperty)
ComplexObjectGenerator
with sub-generators that evaluate
different properties.
interestProperty
- The interestProperty to set.public DataGenerator getDefaultGenerator()
public void setDefaultGenerator(DataGenerator defaultGenerator)
defaultGenerator
- The defaultGenerator to set.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |