Package org.geotools.api.util
Class UnlimitedInteger
-
- All Implemented Interfaces:
Serializable
,Comparable<UnlimitedInteger>
public final class UnlimitedInteger extends Number implements Comparable<UnlimitedInteger>
An integer with associated infinite flag. This implementation usesInteger.MAX_VALUE
as a sentinel value for positive infinity. This approach is consistent with J2SECollection.size()
contract. For consistency,Integer.MIN_VALUE
is a sentinal value for negative infinity.- Since:
- GeoAPI 2.1
- Author:
- Jody Garnett (Refractions Research), Martin Desruisseaux (IRD)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_VALUE
A constant holding the maximum finite value aUnlimitedInteger
can have.static int
MIN_VALUE
A constant holding the minimum finite value aUnlimitedInteger
can have.static UnlimitedInteger
NEGATIVE_INFINITY
A constant holding the negative infinity.static UnlimitedInteger
POSITIVE_INFINITY
A constant holding the positive infinity.
-
Constructor Summary
Constructors Constructor Description UnlimitedInteger(int value)
Constructs a newly allocatedUnlimitedInteger
object that represents the specifiedint
value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(UnlimitedInteger other)
Compares twoUnlimitedInteger
objects numerically.double
doubleValue()
Returns the value of thisUnlimitedInteger
as adouble
.boolean
equals(Object object)
Compares this number with the specified object for equality.float
floatValue()
Returns the value of thisUnlimitedInteger
as afloat
.int
hashCode()
Returns a hash code for this integer.int
intValue()
Returns the value of thisUnlimitedInteger
as anint
.boolean
isInfinite()
Returnstrue
if this integer represents a positive or negative infinity.long
longValue()
Returns the value of thisUnlimitedInteger
as along
.String
toString()
Returns a string representation of this number.-
Methods inherited from class Number
byteValue, shortValue
-
-
-
-
Field Detail
-
NEGATIVE_INFINITY
public static final UnlimitedInteger NEGATIVE_INFINITY
A constant holding the negative infinity.
-
POSITIVE_INFINITY
public static final UnlimitedInteger POSITIVE_INFINITY
A constant holding the positive infinity.
-
MIN_VALUE
public static final int MIN_VALUE
A constant holding the minimum finite value aUnlimitedInteger
can have.- See Also:
- Constant Field Values
-
MAX_VALUE
public static final int MAX_VALUE
A constant holding the maximum finite value aUnlimitedInteger
can have.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UnlimitedInteger
public UnlimitedInteger(int value)
Constructs a newly allocatedUnlimitedInteger
object that represents the specifiedint
value.Integer.MAX_VALUE
andMIN_VALUE
maps to positive and negative infinities respectively.
-
-
Method Detail
-
isInfinite
public boolean isInfinite()
Returnstrue
if this integer represents a positive or negative infinity.
-
intValue
public int intValue()
Returns the value of thisUnlimitedInteger
as anint
. Positive and negative infinities map toInteger.MAX_VALUE
andMIN_VALUE
respectively.
-
longValue
public long longValue()
Returns the value of thisUnlimitedInteger
as along
. Positive and negative infinities map toLong.MAX_VALUE
andMIN_VALUE
respectively.
-
floatValue
public float floatValue()
Returns the value of thisUnlimitedInteger
as afloat
. Positive and negative infinities map toFloat.POSITIVE_INFINITY
andNEGATIVE_INFINITY
respectively.- Specified by:
floatValue
in classNumber
-
doubleValue
public double doubleValue()
Returns the value of thisUnlimitedInteger
as adouble
. Positive and negative infinities map toDouble.POSITIVE_INFINITY
andNEGATIVE_INFINITY
respectively.- Specified by:
doubleValue
in classNumber
-
toString
public String toString()
Returns a string representation of this number.
-
hashCode
public int hashCode()
Returns a hash code for this integer.
-
equals
public boolean equals(Object object)
Compares this number with the specified object for equality.
-
compareTo
public int compareTo(UnlimitedInteger other)
Compares twoUnlimitedInteger
objects numerically.- Specified by:
compareTo
in interfaceComparable<UnlimitedInteger>
- Parameters:
other
- the unlimited integer to be compared.- Returns:
0
if thisUnlimitedInteger
is equal to the given value,-1
if thisUnlimitedInteger
is numerically less than the given value, and+1
if thisUnlimitedInteger
is numerically greater than the given value,
-
-