Class IntegerID

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Comparable<java.lang.Object>, ID
    Direct Known Subclasses:
    EntityID

    public class IntegerID
    extends java.lang.Object
    implements ID
    A class establishing the uniqueness property through an integer. This class assumes the representation of integers to be decimal in all cases.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int id
      The Integer object this id is based on.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected IntegerID​(int i)
      Constructs a new IntegerID object based on an Integer object created from the specified int.
      protected IntegerID​(java.lang.String s)
      Creates a new IntegerID object by parsing the specified string for a decimal integer.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      IntegerID clone()
      Returns a copy of this IntegerID object.
      int compareTo​(java.lang.Object o)
      Imposes a natural ordering on IntegerID objects which is based on the natural ordering of the underlying integers.
      static IntegerID create​(int o)
      Returns a (possibly) new IntegerID object.
      static IntegerID create​(java.lang.String str)
      Creates a (possibly) new IntegerID object by parsing the specified string for a decimal integer.
      boolean equals​(java.lang.Object o)
      Indicates whether this IntegerID object is equal to some other object.
      int hashCode()
      Returns a hash code for this object.
      int intValue()
      Returns the value of this IntegerID as an int.
      java.lang.String toString()
      Returns a string representation of the underlying integer.
      java.lang.String toString​(java.lang.String delim)
      Returns a string representation of the underlying integer.
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • id

        protected final int id
        The Integer object this id is based on.
    • Constructor Detail

      • IntegerID

        protected IntegerID​(int i)
        Constructs a new IntegerID object based on an Integer object created from the specified int.
      • IntegerID

        protected IntegerID​(java.lang.String s)
        Creates a new IntegerID object by parsing the specified string for a decimal integer.
    • Method Detail

      • create

        public static IntegerID create​(int o)
        Returns a (possibly) new IntegerID object.
      • create

        public static IntegerID create​(java.lang.String str)
        Creates a (possibly) new IntegerID object by parsing the specified string for a decimal integer.
      • toString

        public java.lang.String toString()
        Returns a string representation of the underlying integer.
        Specified by:
        toString in interface ID
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String representation of the ID formatted in a user friendly manner.
      • toString

        public java.lang.String toString​(java.lang.String delim)
        Returns a string representation of the underlying integer.
        Specified by:
        toString in interface ID
        Returns:
        a String representation of the ID formatted in a user friendly manner.
      • intValue

        public int intValue()
        Returns the value of this IntegerID as an int.
      • equals

        public boolean equals​(java.lang.Object o)
        Indicates whether this IntegerID object is equal to some other object.
        Specified by:
        equals in interface ID
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - the reference object with which to compare.
        Returns:
        true, if o is an instance of class IntegerID and the numerical values of this and the specified object are equal.
        See Also:
        Object.equals(java.lang.Object)
      • compareTo

        public int compareTo​(java.lang.Object o)
        Imposes a natural ordering on IntegerID objects which is based on the natural ordering of the underlying integers.
        Specified by:
        compareTo in interface java.lang.Comparable<java.lang.Object>
        Specified by:
        compareTo in interface ID
        See Also:
        ID.compareTo(java.lang.Object)
      • hashCode

        public int hashCode()
        Returns a hash code for this object.
        Specified by:
        hashCode in interface ID
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        a hash code value based on the hash code returned by the underlying Integer object.
      • clone

        public IntegerID clone()
        Returns a copy of this IntegerID object.
        Specified by:
        clone in interface ID
        Overrides:
        clone in class java.lang.Object