Class SequenceNumber

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<SequenceNumber>

    public class SequenceNumber
    extends java.lang.Number
    implements java.lang.Comparable<SequenceNumber>
    A mutable sequence that represents an unsigned integer type underneath
    See Also:
    Serialized Form
    • Constructor Detail

      • SequenceNumber

        public SequenceNumber​(int startValue)
        Create a new sequence starting at the given value.
        Parameters:
        startValue - The starting value of this unsigned integer sequence
    • Method Detail

      • increment

        public SequenceNumber increment()
        Add one to the sequence value.
        Returns:
        this sequence.
      • decrement

        public SequenceNumber decrement()
        Subtract one to the sequence value.
        Returns:
        this sequence.
      • getAndIncrement

        public SequenceNumber getAndIncrement()
        Add one to the sequence value.
        Returns:
        this sequence value prior to the increment.
      • getAndDecrement

        public SequenceNumber getAndDecrement()
        Subtract one to the sequence value.
        Returns:
        this sequence value prior to the decrement.
      • intValue

        public int intValue()
        Specified by:
        intValue in class java.lang.Number
      • longValue

        public long longValue()
        Specified by:
        longValue in class java.lang.Number
      • floatValue

        public float floatValue()
        Specified by:
        floatValue in class java.lang.Number
      • doubleValue

        public double doubleValue()
        Specified by:
        doubleValue in class java.lang.Number
      • compareTo

        public int compareTo​(java.lang.Number other)
        Compares the sequence number value to the Number given. This method returns 0 if the tracked id is equal to the value provided, value less than 0 if the tracked id is less than the provided value; and a value greater than 0 if the tracked id is larger than the value provided.
        Parameters:
        other - The Number to compare the current sequence number with.
        Returns:
        the result of comparing the current sequence number to the provided number.
      • compareTo

        public int compareTo​(int other)
        Compares the sequence number value to the primitive Integer given. This method returns 0 if the tracked id is equal to the value provided, value less than 0 if the tracked id is less than the provided value; and a value greater than 0 if the tracked id is larger than the value provided.
        Parameters:
        other - The Number to compare the current sequence number with.
        Returns:
        the result of comparing the current sequence number to the provided number.
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • equals

        public boolean equals​(int other)
        Performs an unsigned comparison between the current sequence number and the integer value passed.
        Parameters:
        other - The value to compare to the currently sequence number.
        Returns:
        true if the currently sequence value matches the integer value provided.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object