Package org.apache.qpid.protonj2.types
Class UnsignedInteger
java.lang.Object
java.lang.Number
org.apache.qpid.protonj2.types.UnsignedInteger
- All Implemented Interfaces:
Serializable,Comparable<UnsignedInteger>
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final UnsignedIntegerstatic final UnsignedIntegerstatic final UnsignedInteger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(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) doublebooleanfloatinthashCode()intintValue()longsubtract(UnsignedInteger value) Subtract the value of the givenUnsignedIntegerfrom this instance and return a newUnsignedIntegerinstance that represents the newly computed value.toString()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 UnsignedIntegerReturns anUnsignedIntegerinstance representing the specifiedStringvalue.Methods inherited from class java.lang.Number
byteValue, shortValue
-
Field Details
-
ZERO
-
ONE
-
MAX_VALUE
-
-
Constructor Details
-
UnsignedInteger
public UnsignedInteger(int underlying)
-
-
Method Details
-
intValue
public int intValue() -
longValue
public long longValue() -
floatValue
public float floatValue()- Specified by:
floatValuein classNumber
-
doubleValue
public double doubleValue()- Specified by:
doubleValuein classNumber
-
equals
-
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
- Specified by:
compareToin interfaceComparable<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() -
toString
-
valueOf
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
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
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
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:
NumberFormatException- if the given value is greater than the maxUnsignedIntegervalue possible or theStringvalue given cannot be converted to a numeric value.
-
valueOf
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:
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.
-