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 Attribute
s.
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
Attribute s |
void |
addObjectClassMasks(java.lang.String... masks)
Adds masks for
ObjectClass s |
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
ObjectInstance s 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, valuesEqual
protected 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 Attribute
s or ObjectClass
that will be masks (ignored from state hashing and equality checks)public void addAttributeMasks(java.lang.String... masks)
Attribute
smasks
- the names of the Attribute
s to mask.public void addObjectClassMasks(java.lang.String... masks)
ObjectClass
smasks
- the names of the ObjectClass
s to mask.public void removeAttributeMasks(java.lang.String... masks)
Attribute
masks.masks
- the names of the Attribute
s that will no longer be masked.public void removeObjectClassMasks(java.lang.String... masks)
ObjectClass
masks.masks
- the names of the ObjectClass
s 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)
SimpleHashableStateFactory
computeHashCode
in class SimpleHashableStateFactory
s
- the input state for which a hash code is to be computedprotected int computeHashCode(ObjectInstance o)
SimpleHashableStateFactory
ObjectInstance
.computeHashCode
in class SimpleHashableStateFactory
o
- the ObjectInstance
whose hash code will be computed.ObjectInstance
.protected boolean identifierIndependentEquals(State s1, State s2)
SimpleHashableStateFactory
identifierIndependentEquals
in class SimpleHashableStateFactory
s1
- the first State
to compares2
- the second State
to compareprotected boolean identifierDependentEquals(State s1, State s2)
SimpleHashableStateFactory
identifierDependentEquals
in class SimpleHashableStateFactory
s1
- the first State
to compares2
- the second State
to compareprotected boolean objectValuesEqual(ObjectInstance o1, ObjectInstance o2)
SimpleHashableStateFactory
ObjectInstance
s are equal.objectValuesEqual
in class SimpleHashableStateFactory
o1
- the first ObjectInstance
to compareo2
- the second ObjectInstance
to compare