Package com.globalmentor.model
Class DefaultIDed<I>
- java.lang.Object
-
- com.globalmentor.model.DefaultIDed<I>
-
- All Implemented Interfaces:
IDed<I>
- Direct Known Subclasses:
AbstractPrincipal
,DefaultIDNamed
public class DefaultIDed<I> extends java.lang.Object implements IDed<I>
A default implementation of a uniquely identified object. This class is useful to serve as a base class to other classes that are identified by an ID. It provides equality checking based upon the ID.This implementation provides the capability to provide automatic conversion of the ID when the ID is set, such as converting to lowercase.
- Author:
- Garret Wilson
- See Also:
Object.equals(java.lang.Object)
-
-
Constructor Summary
Constructors Constructor Description DefaultIDed(I id)
Constructor specifying the ID.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object object)
Considers another object equal if the other object is anIDed
with the same ID.I
getID()
int
hashCode()
protected void
setID(I id)
Sets the identifier of the object.java.lang.String
toString()
-
-
-
Constructor Detail
-
DefaultIDed
public DefaultIDed(I id)
Constructor specifying the ID.- Parameters:
id
- The ID of the object.
-
-
Method Detail
-
getID
public I getID()
-
setID
protected void setID(I id)
Sets the identifier of the object.- Parameters:
id
- The identifier, preferably unique, of the object; ornull
if the object has no ID.
-
equals
public boolean equals(java.lang.Object object)
Considers another object equal if the other object is anIDed
with the same ID.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- A hashcode value from the ID.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of this object in the format "objectinfo: [ID]".
-
-