public class MaskedHashableStateFactory extends SimpleHashableStateFactory
HashableState instances in which the hash code and equality
of the states ignores either ObjectInstance belonging to
specific ObjectClass or value assignments for specific Attributes.
You can specify which attributes and object classes to ignore through an attribute name mask and an object class name
mask. There are a variety of methods for manipulating the masks.
SimpleHashableStateFactory, which means it can be toggled to
to be object identifier/name independent or dependent and can be set to use HashableState
instances that hash their hash code or not. See the SimpleHashableStateFactory
class documentation for more information on those features.SimpleHashableStateFactory.AttClass, SimpleHashableStateFactory.SimpleCachedHashableState, SimpleHashableStateFactory.SimpleHashableState, SimpleHashableStateFactory.SimpleHashableStateInterface| Modifier and Type | Field and Description |
|---|---|
protected java.util.Set<java.lang.String> |
maskedAttributes |
protected java.util.Set<java.lang.String> |
maskedObjectClasses |
identifierIndependent, useCached| Constructor and Description |
|---|
MaskedHashableStateFactory()
Default constructor: object identifier independent, no hash code caching, and no object class or attribute masks.
|
MaskedHashableStateFactory(boolean identifierIndependent)
Initializes with no hash code caching and no object class or attribute masks.
|
MaskedHashableStateFactory(boolean identifierIndependent,
boolean useCached)
Initializes with no object class or attribute masks.
|
MaskedHashableStateFactory(boolean identifierIndependent,
boolean useCached,
boolean maskNamesAreForAttributes,
java.lang.String... masks)
Initializes with a specified attribute or object class mask.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAttributeMasks(java.lang.String... masks)
Adds masks for
Attributes |
void |
addObjectClassMasks(java.lang.String... masks)
Adds masks for
ObjectClasss |
void |
clearAllAttributeMasks()
Clears all
Attribute masks. |
void |
clearAllObjectClassMasks()
Clears all
ObjectClass masks. |
protected int |
computeHashCode(ObjectInstance o)
Computes the hash code for an individual
ObjectInstance. |
protected int |
computeHashCode(State s)
Computes the hash code for the input state.
|
java.util.Set<java.lang.String> |
getMaskedAttributes() |
java.util.Set<java.lang.String> |
getMaskedObjectClasses() |
protected boolean |
identifierDependentEquals(State s1,
State s2)
Evaluates whether two states are equal when equality depends on object identifiers/names being equal.
|
protected boolean |
identifierIndependentEquals(State s1,
State s2)
Evaluates whether two states are equal when equality is independent of object identifiers/names being equal
|
protected boolean |
objectValuesEqual(ObjectInstance o1,
ObjectInstance o2)
Evaluates whether the values of two
ObjectInstances are equal. |
void |
removeAttributeMasks(java.lang.String... masks)
Removes
Attribute masks. |
void |
removeObjectClassMasks(java.lang.String... masks)
Removes
ObjectClass masks. |
appendHashcodeForValue, getAttClass, hashState, objectIdentifierIndependent, statesEqual, valuesEqualprotected java.util.Set<java.lang.String> maskedAttributes
protected java.util.Set<java.lang.String> maskedObjectClasses
public MaskedHashableStateFactory()
public MaskedHashableStateFactory(boolean identifierIndependent)
identifierIndependent - if true then state evaluations are object identifier independent; if false then dependent.public MaskedHashableStateFactory(boolean identifierIndependent,
boolean useCached)
identifierIndependent - if true then state evaluations are object identifier independent; if false then dependent.useCached - if true then the hash code for each produced HashableState will be cached; if false then they will not be cached.public MaskedHashableStateFactory(boolean identifierIndependent,
boolean useCached,
boolean maskNamesAreForAttributes,
java.lang.String... masks)
identifierIndependent - if true then state evaluations are object identifier independent; if false then dependent.useCached - if true then the hash code for each produced HashableState will be cached; if false then they will not be cached.maskNamesAreForAttributes - whether the specified masks are masks for attributes or object classes. True for attributes, false for object classes.masks - the names of the Attributes or ObjectClass that will be masks (ignored from state hashing and equality checks)public void addAttributeMasks(java.lang.String... masks)
Attributesmasks - the names of the Attributes to mask.public void addObjectClassMasks(java.lang.String... masks)
ObjectClasssmasks - the names of the ObjectClasss to mask.public void removeAttributeMasks(java.lang.String... masks)
Attribute masks.masks - the names of the Attributes that will no longer be masked.public void removeObjectClassMasks(java.lang.String... masks)
ObjectClass masks.masks - the names of the ObjectClasss that will no longer be masked.public void clearAllAttributeMasks()
Attribute masks.public void clearAllObjectClassMasks()
ObjectClass masks.public java.util.Set<java.lang.String> getMaskedAttributes()
public java.util.Set<java.lang.String> getMaskedObjectClasses()
protected int computeHashCode(State s)
SimpleHashableStateFactorycomputeHashCode in class SimpleHashableStateFactorys - the input state for which a hash code is to be computedprotected int computeHashCode(ObjectInstance o)
SimpleHashableStateFactoryObjectInstance.computeHashCode in class SimpleHashableStateFactoryo - the ObjectInstance whose hash code will be computed.ObjectInstance.protected boolean identifierIndependentEquals(State s1, State s2)
SimpleHashableStateFactoryidentifierIndependentEquals in class SimpleHashableStateFactorys1 - the first State to compares2 - the second State to compareprotected boolean identifierDependentEquals(State s1, State s2)
SimpleHashableStateFactoryidentifierDependentEquals in class SimpleHashableStateFactorys1 - the first State to compares2 - the second State to compareprotected boolean objectValuesEqual(ObjectInstance o1, ObjectInstance o2)
SimpleHashableStateFactoryObjectInstances are equal.objectValuesEqual in class SimpleHashableStateFactoryo1 - the first ObjectInstance to compareo2 - the second ObjectInstance to compare