gov.sandia.cognition.framework
Class AbstractSemanticIdentifier

java.lang.Object
  extended by gov.sandia.cognition.framework.AbstractSemanticIdentifier
All Implemented Interfaces:
SemanticIdentifier, Serializable, Comparable<SemanticIdentifier>
Direct Known Subclasses:
DefaultSemanticIdentifier

public abstract class AbstractSemanticIdentifier
extends Object
implements SemanticIdentifier

The AbstractSemanticIdentifier class implements the basic methods that are needed for a SemanticIdentifier to provide a good speed improvement. In particular, it makes use of the getIdentifier method to use the identifier in the hashCode and equals fuctions in order to make them fast.

Since:
1.0
Author:
Justin Basilico
See Also:
Serialized Form

Constructor Summary
protected AbstractSemanticIdentifier()
          Creates a new instance of AbstractSemanticIdentifier
 
Method Summary
 int compareTo(SemanticIdentifier o)
          
 boolean equals(Object other)
          Determines if this identifier is equal to another Object.
 boolean equals(SemanticIdentifier other)
          Determines if this identifier is equal to the given one by comparing the identifier number only.
 int hashCode()
          Computes the hash-code for the SemanticIdentifier, which should be equal to a call to getIdentifier.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.framework.SemanticIdentifier
getIdentifier, getLabel
 

Constructor Detail

AbstractSemanticIdentifier

protected AbstractSemanticIdentifier()
Creates a new instance of AbstractSemanticIdentifier

Method Detail

hashCode

public int hashCode()
Computes the hash-code for the SemanticIdentifier, which should be equal to a call to getIdentifier.

Specified by:
hashCode in interface SemanticIdentifier
Overrides:
hashCode in class Object
Returns:
The hash code of the identifier, which is the identifier number.

compareTo

public int compareTo(SemanticIdentifier o)

Specified by:
compareTo in interface SemanticIdentifier
Specified by:
compareTo in interface Comparable<SemanticIdentifier>
Parameters:
o -
Returns:

equals

public boolean equals(Object other)
Determines if this identifier is equal to another Object. If that Object is a SemanticIdentifier then the two are equal if the identifier numbers are the same.

Specified by:
equals in interface SemanticIdentifier
Overrides:
equals in class Object
Parameters:
other - The Object to test equality with.
Returns:
True if this is equal to the given Object.

equals

public boolean equals(SemanticIdentifier other)
Determines if this identifier is equal to the given one by comparing the identifier number only. This comparison is invalid if the two labels come from different models.

Specified by:
equals in interface SemanticIdentifier
Parameters:
other - The other SemanticIdentifier to compare to.
Returns:
True if the two semantic identifiers are equal.