Class UncachedInteger

java.lang.Object
java.lang.Number
org.soliscode.test.util.UncachedInteger
All Implemented Interfaces:
Serializable, Comparable<UncachedInteger>

public class UncachedInteger extends Number implements Comparable<UncachedInteger>
An integer class that does not use cached values. This class is used for testing methods that match by object identity where the test needs to create multiple objects with the same value but different identities.
Since:
1.0.0
Author:
evanbergstrom
See Also:
  • Constructor Details

    • UncachedInteger

      public UncachedInteger()
      Create and instance of UncachedInteger with the value zero.
    • UncachedInteger

      public UncachedInteger(int i)
      Create and instance of UncachedInteger with a specific value.
      Parameters:
      i - The value of the integer.
    • UncachedInteger

      public UncachedInteger(UncachedInteger i)
      Create a copy of an UncachedInteger object.
      Parameters:
      i - The integer to copy.
  • Method Details

    • intValue

      public int intValue()
      Returns the value of this UncachedInteger as an int.
      Specified by:
      intValue in class Number
    • longValue

      public long longValue()
      Returns the value of this UncachedInteger as an long.
      Specified by:
      longValue in class Number
    • floatValue

      public float floatValue()
      Returns the value of this UncachedInteger as an float.
      Specified by:
      floatValue in class Number
    • doubleValue

      public double doubleValue()
      Returns the value of this UncachedInteger as an double.
      Specified by:
      doubleValue in class Number
    • toString

      public String toString()
      Returns a String object representing this UncachedInteger's value. The value is converted to signed decimal representation and returned as a string, exactly as if the integer value were given as an argument to the Integer.toString(int) method.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the value of this object in base 10.
    • equals

      public boolean equals(Object obj)
      Compares this object to the specified object. The result is true if and only if the argument is not null and is an UncachedInteger object that contains the same int value as this object.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare with.
      Returns:
      true if the objects are the same false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code for this UncachedInteger.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this object, equal to the primitive int value represented by this UncachedInteger object.
    • compareTo

      public int compareTo(UncachedInteger o)
      Compares two UncachedInteger objects numerically.
      Specified by:
      compareTo in interface Comparable<UncachedInteger>
      Parameters:
      o - the UncachedInteger to be compared.
      Returns:
      the value 0 if this UncachedInteger is equal to the argument Integer; a value less than 0 if this UncachedInteger is numerically less than the argument UncachedInteger; and a value greater than 0 if this Integer is numerically greater than the argument Integer (signed comparison).
    • valueOf

      public static UncachedInteger valueOf(int i)
      Creates an instance of UncachedInteger with the specified value. This is the analog of the Integer.valueOf(int) method, but this method does not ever return a cached value, insuring each instance of UncachedInteger is a unique instance.
      Parameters:
      i - the integer value.
      Returns:
      A unique instance of the UncachedInteger class.
    • listOf

      public static List<UncachedInteger> listOf(int... values)
      Creates a List of UncachedInteger values based upon a list of integer constants.
      Parameters:
      values - The integer values.
      Returns:
      a list of UncachedInteger values.
    • iterableOf

      public static Iterable<UncachedInteger> iterableOf(int... values)
      Creates a Iterable of UncachedInteger values based upon a list of integer constants.
      Parameters:
      values - The integer values.
      Returns:
      an iterable of UncachedInteger values.