Class UncachedInteger
java.lang.Object
java.lang.Number
org.soliscode.test.util.UncachedInteger
- All Implemented Interfaces:
Serializable
,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 Summary
ConstructorsConstructorDescriptionCreate and instance ofUncachedInteger
with the value zero.UncachedInteger
(int i) Create and instance ofUncachedInteger
with a specific value.Create a copy of anUncachedInteger
object. -
Method Summary
Modifier and TypeMethodDescriptionint
Compares twoUncachedInteger
objects numerically.double
Returns the value of thisUncachedInteger
as andouble
.boolean
Compares this object to the specified object.float
Returns the value of thisUncachedInteger
as anfloat
.int
hashCode()
Returns a hash code for thisUncachedInteger
.int
intValue()
Returns the value of thisUncachedInteger
as anint
.static Iterable
<UncachedInteger> iterableOf
(int... values) Creates aIterable
ofUncachedInteger
values based upon a list of integer constants.static List
<UncachedInteger> listOf
(int... values) Creates aList
ofUncachedInteger
values based upon a list of integer constants.long
Returns the value of thisUncachedInteger
as anlong
.toString()
Returns aString
object representing thisUncachedInteger
's value.static UncachedInteger
valueOf
(int i) Creates an instance ofUncachedInteger
with the specified value.Methods inherited from class java.lang.Number
byteValue, shortValue
-
Constructor Details
-
UncachedInteger
public UncachedInteger()Create and instance ofUncachedInteger
with the value zero. -
UncachedInteger
public UncachedInteger(int i) Create and instance ofUncachedInteger
with a specific value.- Parameters:
i
- The value of the integer.
-
UncachedInteger
Create a copy of anUncachedInteger
object.- Parameters:
i
- The integer to copy.
-
-
Method Details
-
intValue
-
longValue
-
floatValue
public float floatValue()Returns the value of thisUncachedInteger
as anfloat
.- Specified by:
floatValue
in classNumber
-
doubleValue
public double doubleValue()Returns the value of thisUncachedInteger
as andouble
.- Specified by:
doubleValue
in classNumber
-
toString
Returns aString
object representing thisUncachedInteger
'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 theInteger.toString(int)
method. -
equals
Compares this object to the specified object. The result istrue
if and only if the argument is notnull
and is anUncachedInteger
object that contains the sameint
value as this object. -
hashCode
-
compareTo
Compares twoUncachedInteger
objects numerically.- Specified by:
compareTo
in interfaceComparable<UncachedInteger>
- Parameters:
o
- theUncachedInteger
to be compared.- Returns:
- the value
0
if thisUncachedInteger
is equal to the argumentInteger
; a value less than0
if thisUncachedInteger
is numerically less than the argumentUncachedInteger
; and a value greater than0
if thisInteger
is numerically greater than the argumentInteger
(signed comparison).
-
valueOf
Creates an instance ofUncachedInteger
with the specified value. This is the analog of theInteger.valueOf(int)
method, but this method does not ever return a cached value, insuring each instance ofUncachedInteger
is a unique instance.- Parameters:
i
- the integer value.- Returns:
- A unique instance of the
UncachedInteger
class.
-
listOf
Creates aList
ofUncachedInteger
values based upon a list of integer constants.- Parameters:
values
- The integer values.- Returns:
- a list of
UncachedInteger
values.
-
iterableOf
Creates aIterable
ofUncachedInteger
values based upon a list of integer constants.- Parameters:
values
- The integer values.- Returns:
- an iterable of
UncachedInteger
values.
-