Package org.apache.qpid.protonj2.types
Class UnsignedInteger
- java.lang.Object
-
- java.lang.Number
-
- org.apache.qpid.protonj2.types.UnsignedInteger
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<UnsignedInteger>
public final class UnsignedInteger extends java.lang.Number implements java.lang.Comparable<UnsignedInteger>
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static UnsignedIntegerMAX_VALUEstatic UnsignedIntegerONEstatic UnsignedIntegerZERO
-
Constructor Summary
Constructors Constructor Description UnsignedInteger(int underlying)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UnsignedIntegeradd(UnsignedInteger value)Adds the value of the givenUnsignedIntegerto this instance and return a newUnsignedIntegerinstance that represents the newly computed value.static intcompare(int left, int right)Compares two integer values numerically treating the values as unsigned.static intcompare(long left, long right)Compares two long values numerically treating the values as unsigned.intcompareTo(int value)Compares the give integer value to this unsigned integer numerically treating the given value as unsigned.intcompareTo(long value)Compares the give long value to this unsigned integer numerically treating the given value as unsigned.intcompareTo(UnsignedInteger value)doubledoubleValue()booleanequals(java.lang.Object o)floatfloatValue()inthashCode()intintValue()longlongValue()UnsignedIntegersubtract(UnsignedInteger value)Subtract the value of the givenUnsignedIntegerfrom this instance and return a newUnsignedIntegerinstance that represents the newly computed value.java.lang.StringtoString()static longtoUnsignedLong(int value)Returns alongthat represents the unsigned view of the givenintvalue.static UnsignedIntegervalueOf(int value)Returns an UnsignedInteger instance representing the specified int value.static UnsignedIntegervalueOf(long value)Returns an UnsignedInteger instance representing the specified long value.static UnsignedIntegervalueOf(java.lang.String value)Returns anUnsignedIntegerinstance representing the specifiedStringvalue.
-
-
-
Field Detail
-
ZERO
public static final UnsignedInteger ZERO
-
ONE
public static final UnsignedInteger ONE
-
MAX_VALUE
public static final UnsignedInteger MAX_VALUE
-
-
Method Detail
-
intValue
public int intValue()
- Specified by:
intValuein classjava.lang.Number
-
longValue
public long longValue()
- Specified by:
longValuein classjava.lang.Number
-
floatValue
public float floatValue()
- Specified by:
floatValuein classjava.lang.Number
-
doubleValue
public double doubleValue()
- Specified by:
doubleValuein classjava.lang.Number
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(int value)
Compares the give integer value to this unsigned integer numerically treating the given value as unsigned.- Parameters:
value- the integer to compare to this unsigned integer instance.- Returns:
- the value 0 if this == value; a value less than 0 if this < value as unsigned values; and a value greater than 0 if this > value as unsigned values
-
compareTo
public int compareTo(long value)
Compares the give long value to this unsigned integer numerically treating the given value as unsigned.- Parameters:
value- the long to compare to this unsigned integer instance.- Returns:
- the value 0 if this == value; a value less than 0 if this < value as unsigned values; and a value greater than 0 if this > value as unsigned values
-
compareTo
public int compareTo(UnsignedInteger value)
- Specified by:
compareToin interfacejava.lang.Comparable<UnsignedInteger>
-
compare
public static int compare(int left, int right)Compares two integer values numerically treating the values as unsigned.- Parameters:
left- the left hand side integer to compareright- the right hand side integer to compare- Returns:
- the value 0 if left == right; a value less than 0 if left < right as unsigned values; and a value greater than 0 if left > right as unsigned values
-
compare
public static int compare(long left, long right)Compares two long values numerically treating the values as unsigned.- Parameters:
left- the left hand side long value to compareright- the right hand side long value to compare- Returns:
- the value 0 if left == right; a value less than 0 if left < right as unsigned values; and a value greater than 0 if left > right as unsigned values
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
valueOf
public static UnsignedInteger valueOf(int value)
Returns an UnsignedInteger instance representing the specified int value. This method always returns a cachedUnsignedIntegerinstance for values in the range [0...255] which can save space and time over calling the constructorUnsignedInteger(int)which will always create a new instance of theUnsignedIntegertype.- Parameters:
value- The int value to return as anUnsignedIntegerinstance.- Returns:
- an
UnsignedIntegerinstance representing the unsigned view of the given int.
-
add
public UnsignedInteger add(UnsignedInteger value)
Adds the value of the givenUnsignedIntegerto this instance and return a newUnsignedIntegerinstance that represents the newly computed value.- Parameters:
value- TheUnsignedIntegerwhose underlying value should be added to this instance's value.- Returns:
- a new immutable
UnsignedIntegerresulting from the addition of this with the given value.
-
subtract
public UnsignedInteger subtract(UnsignedInteger value)
Subtract the value of the givenUnsignedIntegerfrom this instance and return a newUnsignedIntegerinstance that represents the newly computed value.- Parameters:
value- TheUnsignedIntegerwhose underlying value should be subtracted to this instance's value.- Returns:
- a new immutable
UnsignedIntegerresulting from the subtraction the given value from this.
-
valueOf
public static UnsignedInteger valueOf(java.lang.String value)
Returns anUnsignedIntegerinstance representing the specifiedStringvalue. This method always returns a cachedUnsignedIntegerinstance for values in the range [0...255] which can save space and time over calling the constructorUnsignedInteger(int)which will always create a new instance of theUnsignedIntegertype.- Parameters:
value- The String value to return as anUnsignedIntegerinstance.- Returns:
- an
UnsignedIntegerinstance representing the unsigned view of the given String. - Throws:
java.lang.NumberFormatException- if the given value is greater than the maxUnsignedIntegervalue possible or theStringvalue given cannot be converted to a numeric value.
-
valueOf
public static UnsignedInteger valueOf(long value)
Returns an UnsignedInteger instance representing the specified long value. This method always returns a cachedUnsignedIntegerinstance for values in the range [0...255] which can save space and time over calling the constructorUnsignedInteger(int)which will always create a new instance of theUnsignedIntegertype.- Parameters:
value- The long value to return as anUnsignedIntegerinstance.- Returns:
- an
UnsignedIntegerinstance representing the unsigned view of the given long. - Throws:
java.lang.NumberFormatException- if the given value is greater than the maxUnsignedIntegervalue possible.
-
toUnsignedLong
public static long toUnsignedLong(int value)
Returns alongthat represents the unsigned view of the givenintvalue.- Parameters:
value- The integer whose unsigned value should be converted to a long.- Returns:
- a positive long value that represents the given
intas unsigned.
-
-