Class UnsignedInteger

java.lang.Object
java.lang.Number
org.apache.qpid.protonj2.types.UnsignedInteger
All Implemented Interfaces:
Serializable, Comparable<UnsignedInteger>

public final class UnsignedInteger extends Number implements Comparable<UnsignedInteger>
See Also:
  • Field Details

  • Constructor Details

    • UnsignedInteger

      public UnsignedInteger(int underlying)
  • Method Details

    • intValue

      public int intValue()
      Specified by:
      intValue in class Number
    • longValue

      public long longValue()
      Specified by:
      longValue in class Number
    • floatValue

      public float floatValue()
      Specified by:
      floatValue in class Number
    • doubleValue

      public double doubleValue()
      Specified by:
      doubleValue in class Number
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class 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:
      compareTo in interface 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 compare
      right - 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 compare
      right - 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:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • valueOf

      public static UnsignedInteger valueOf(int value)
      Returns an UnsignedInteger instance representing the specified int value. This method always returns a cached UnsignedInteger instance for values in the range [0...255] which can save space and time over calling the constructor UnsignedInteger(int) which will always create a new instance of the UnsignedInteger type.
      Parameters:
      value - The int value to return as an UnsignedInteger instance.
      Returns:
      an UnsignedInteger instance representing the unsigned view of the given int.
    • add

      public UnsignedInteger add(UnsignedInteger value)
      Adds the value of the given UnsignedInteger to this instance and return a new UnsignedInteger instance that represents the newly computed value.
      Parameters:
      value - The UnsignedInteger whose underlying value should be added to this instance's value.
      Returns:
      a new immutable UnsignedInteger resulting from the addition of this with the given value.
    • subtract

      public UnsignedInteger subtract(UnsignedInteger value)
      Subtract the value of the given UnsignedInteger from this instance and return a new UnsignedInteger instance that represents the newly computed value.
      Parameters:
      value - The UnsignedInteger whose underlying value should be subtracted to this instance's value.
      Returns:
      a new immutable UnsignedInteger resulting from the subtraction the given value from this.
    • valueOf

      public static UnsignedInteger valueOf(String value)
      Returns an UnsignedInteger instance representing the specified String value. This method always returns a cached UnsignedInteger instance for values in the range [0...255] which can save space and time over calling the constructor UnsignedInteger(int) which will always create a new instance of the UnsignedInteger type.
      Parameters:
      value - The String value to return as an UnsignedInteger instance.
      Returns:
      an UnsignedInteger instance representing the unsigned view of the given String.
      Throws:
      NumberFormatException - if the given value is greater than the max UnsignedInteger value possible or the String value 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 cached UnsignedInteger instance for values in the range [0...255] which can save space and time over calling the constructor UnsignedInteger(int) which will always create a new instance of the UnsignedInteger type.
      Parameters:
      value - The long value to return as an UnsignedInteger instance.
      Returns:
      an UnsignedInteger instance representing the unsigned view of the given long.
      Throws:
      NumberFormatException - if the given value is greater than the max UnsignedInteger value possible.
    • toUnsignedLong

      public static long toUnsignedLong(int value)
      Returns a long that represents the unsigned view of the given int value.
      Parameters:
      value - The integer whose unsigned value should be converted to a long.
      Returns:
      a positive long value that represents the given int as unsigned.