Package com.globalmentor.model
Class DefaultComparableIDNamed<I,N extends java.lang.Comparable<N>>
- java.lang.Object
-
- com.globalmentor.model.DefaultNamed<N>
-
- com.globalmentor.model.DefaultComparableNamed<N>
-
- com.globalmentor.model.DefaultComparableIDNamed<I,N>
-
public class DefaultComparableIDNamed<I,N extends java.lang.Comparable<N>> extends DefaultComparableNamed<N> implements IDed<I>, java.lang.Comparable<Named<N>>
A default implementation of an IDed and named object comparable by name. This implementation does not allow anull
name. Note: Because this class considers equality by ID and order by name, this class has a natural ordering that is inconsistent with equals.- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description DefaultComparableIDNamed(I id, N name)
Constructor specifying the ID and name.
-
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()
java.lang.String
toString()
-
Methods inherited from class com.globalmentor.model.DefaultComparableNamed
compareTo
-
Methods inherited from class com.globalmentor.model.DefaultNamed
getName
-
-
-
-
Method Detail
-
getID
public I getID()
-
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 classDefaultNamed<N extends java.lang.Comparable<N>>
- Returns:
- A hashcode value from the ID.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classDefaultNamed<N extends java.lang.Comparable<N>>
- Returns:
- A string representation of this object in the format "objectinfo: [ID]".
-
-