net.sf.adatagenerator.modifiers
Class RandomPairModifier<T,P extends ModifiablePair<T>>

java.lang.Object
  extended by net.sf.adatagenerator.modifiers.RandomPairModifier<T,P>
All Implemented Interfaces:
Comparable<NamedInstance>, NamedInstance, PairModifier<T,P>

public class RandomPairModifier<T,P extends ModifiablePair<T>>
extends Object
implements PairModifier<T,P>


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.sf.adatagenerator.api.PairModifier
PairModifier.ModificationResult
 
Field Summary
static int DEFAULT_MAX_CHANGES
           
static int DEFAULT_MIN_CHANGES
           
static int LOWEST_ALLOWED_CHANGES
           
 
Constructor Summary
RandomPairModifier(FrequencyBasedList<BeanModifier<T>> beanModifiers)
           
RandomPairModifier(FrequencyBasedList<BeanModifier<T>> beanModifiers, int minChangesPerBean, int maxChangesPerBean)
           
RandomPairModifier(String name, String context, FrequencyBasedList<BeanModifier<T>> beanModifiers, int minChangesPerBean, int maxChangesPerBean)
           
 
Method Summary
 int compareContexts(NamedInstance namedInstance)
          Compares the context of this instance to the context of another instance using the context comparator of this instance.
 int compareTo(NamedInstance namedInstance)
          Compares this instance to another instance using the comparator of this instance.
protected  Iterable<BeanModifier<T>> getBeanModifiers()
           
 String getContext()
          The context in which this instance is named.
 Comparator<String> getContextComparator()
           
protected  int getDelta()
           
protected  int getMaxChangesPerBean()
           
protected  int getMinChangesPerBean()
           
 String getName()
          Implementing classes should return a name that will be comparable within some context
protected  NamedInstance getNameDelegate()
           
 Comparator<NamedInstance> getNamedInstanceComparator()
           
protected  Random getRandom()
           
 P modifyPair(P target)
          Modifies the target and updates its current status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOWEST_ALLOWED_CHANGES

public static final int LOWEST_ALLOWED_CHANGES
See Also:
Constant Field Values

DEFAULT_MIN_CHANGES

public static final int DEFAULT_MIN_CHANGES
See Also:
Constant Field Values

DEFAULT_MAX_CHANGES

public static final int DEFAULT_MAX_CHANGES
See Also:
Constant Field Values
Constructor Detail

RandomPairModifier

public RandomPairModifier(FrequencyBasedList<BeanModifier<T>> beanModifiers)
Parameters:
minChangesPerBean - inclusive
maxChangesPerBean - inclusive

RandomPairModifier

public RandomPairModifier(FrequencyBasedList<BeanModifier<T>> beanModifiers,
                          int minChangesPerBean,
                          int maxChangesPerBean)
Parameters:
minChangesPerBean - inclusive
maxChangesPerBean - inclusive

RandomPairModifier

public RandomPairModifier(String name,
                          String context,
                          FrequencyBasedList<BeanModifier<T>> beanModifiers,
                          int minChangesPerBean,
                          int maxChangesPerBean)
Parameters:
minChangesPerBean - inclusive
maxChangesPerBean - inclusive
Method Detail

getRandom

protected Random getRandom()

getNameDelegate

protected NamedInstance getNameDelegate()

getBeanModifiers

protected Iterable<BeanModifier<T>> getBeanModifiers()

getMinChangesPerBean

protected int getMinChangesPerBean()

getMaxChangesPerBean

protected int getMaxChangesPerBean()

getDelta

protected int getDelta()

modifyPair

public P modifyPair(P target)
                                       throws ModificationException
Description copied from interface: PairModifier
Modifies the target and updates its current status.

Specified by:
modifyPair in interface PairModifier<T,P extends ModifiablePair<T>>
Parameters:
target - the object to modify
Returns:
the modified target (or a modified copy of the target)
Throws:
ModificationException - if modification fails

getName

public String getName()
Description copied from interface: NamedInstance
Implementing classes should return a name that will be comparable within some context

Specified by:
getName in interface NamedInstance
Returns:
a value that identifies an instance in some context. This parameter may be null for an anonymous instance, but if it is non-null, the value will be a trimmed String

getContext

public String getContext()
Description copied from interface: NamedInstance
The context in which this instance is named. If another instance has different context from this instance, then implementing classes should ensure that NamedInstance.compareTo(NamedInstance) returns the same (non-zero) value that is the result of comparing the contexts.

Specified by:
getContext in interface NamedInstance
Returns:
may be null if the context is implicit and well understood, and trimmed otherwise

compareContexts

public int compareContexts(NamedInstance namedInstance)
Description copied from interface: NamedInstance
Compares the context of this instance to the context of another instance using the context comparator of this instance.

Specified by:
compareContexts in interface NamedInstance

getContextComparator

public Comparator<String> getContextComparator()
Specified by:
getContextComparator in interface NamedInstance

compareTo

public int compareTo(NamedInstance namedInstance)
Description copied from interface: NamedInstance
Compares this instance to another instance using the comparator of this instance.

Specified by:
compareTo in interface Comparable<NamedInstance>
Specified by:
compareTo in interface NamedInstance

getNamedInstanceComparator

public Comparator<NamedInstance> getNamedInstanceComparator()
Specified by:
getNamedInstanceComparator in interface NamedInstance


Copyright © 2011-2012. All Rights Reserved.