Class LongID

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Comparable<java.lang.Object>, ID

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

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

      Constructors 
      Modifier Constructor Description
      protected LongID​(long l)
      Constructs a new LongID object based on an Long object created from the specified long.
      protected LongID​(java.lang.Long l)
      Constructs a new LongID object from the specified integer.
      protected LongID​(java.lang.String s)
      Creates a new LongID 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
      java.lang.Object clone()
      Returns a copy of this LongID object.
      int compareTo​(java.lang.Object o)
      Imposes a natural ordering on LongID objects which is based on the natural ordering of the underlying integers.
      static LongID create​(int i)
      Creates an ID with the specified value.
      static LongID create​(long l)
      Creates an ID with the specified value.
      static LongID create​(java.lang.Long o)
      Returns a (possibly) new StringID object.
      static LongID create​(java.lang.String s)
      Creates an id with the integer represented by s.
      boolean equals​(java.lang.Object o)
      Indicates whether this LongID object is equal to some other object.
      int hashCode()
      Returns a hash code for this object.
      long longValue()
      Returns the value of this LongID 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 long id
        The Long object this id is based on.
    • Constructor Detail

      • LongID

        protected LongID​(java.lang.Long l)
        Constructs a new LongID object from the specified integer.
      • LongID

        protected LongID​(long l)
        Constructs a new LongID object based on an Long object created from the specified long.
      • LongID

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

      • create

        public static LongID create​(java.lang.Long o)
        Returns a (possibly) new StringID object.
        Throws:
        java.lang.NullPointerException - If o==null
      • create

        public static LongID create​(java.lang.String s)
        Creates an id with the integer represented by s.
      • create

        public static LongID create​(int i)
        Creates an ID with the specified value.
      • create

        public static LongID create​(long l)
        Creates an ID with the specified value.
      • 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.
      • longValue

        public long longValue()
        Returns the value of this LongID as an int.
      • equals

        public boolean equals​(java.lang.Object o)
        Indicates whether this LongID 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 LongID and the numerical values of this and the specified object are equal.
      • compareTo

        public int compareTo​(java.lang.Object o)
        Imposes a natural ordering on LongID 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
      • 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 Long object.
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Returns a copy of this LongID object.
        Specified by:
        clone in interface ID
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException - DOCUMENT-ME