java.lang.Object
java.lang.Number
org.opendaylight.yangtools.yang.common.Uint16
All Implemented Interfaces:
Serializable, Comparable<Uint16>, Immutable, CanonicalValue<Uint16>

@NonNullByDefault public class Uint16 extends Number implements CanonicalValue<Uint16>
Dedicated type for YANG's type uint16 type.
See Also:
  • Field Details

    • ZERO

      public static final Uint16 ZERO
      Value of 0.
    • ONE

      public static final Uint16 ONE
      Value of 1.
    • TWO

      public static final Uint16 TWO
      Value of 2.
    • TEN

      public static final Uint16 TEN
      Value of 10.
    • MAX_VALUE

      public static final Uint16 MAX_VALUE
      Value of 65535.
  • Constructor Details

    • Uint16

      protected Uint16(Uint16 other)
  • Method Details

    • fromShortBits

      public static Uint16 fromShortBits(short bits)
      Returns an Uint16 corresponding to a given bit representation. The argument is interpreted as an unsigned 16-bit value.
      Parameters:
      bits - unsigned bit representation
      Returns:
      A Uint16 instance
    • valueOf

      public static Uint16 valueOf(byte byteVal)
      Returns an Uint16 corresponding to a given byteVal. The inverse operation is Number.byteValue().
      Parameters:
      byteVal - byte value
      Returns:
      A Uint16 instance
      Throws:
      IllegalArgumentException - if byteVal is less than zero
    • valueOf

      public static Uint16 valueOf(short shortVal)
      Returns an Uint16 corresponding to a given shortVal. The inverse operation is shortValue().
      Parameters:
      shortVal - short value
      Returns:
      A Uint16 instance
      Throws:
      IllegalArgumentException - if shortVal is less than zero.
    • valueOf

      public static Uint16 valueOf(int intVal)
      Returns an Uint16 corresponding to a given intVal. The inverse operation is intValue().
      Parameters:
      intVal - int value
      Returns:
      A Uint16 instance
      Throws:
      IllegalArgumentException - if intVal is less than zero or greater than 65535.
    • valueOf

      public static Uint16 valueOf(long longVal)
      Returns an Uint16 corresponding to a given longVal. The inverse operation is longValue().
      Parameters:
      longVal - long value
      Returns:
      A Uint16 instance
      Throws:
      IllegalArgumentException - if intVal is less than zero or greater than 65535.
    • valueOf

      public static Uint16 valueOf(Uint8 uint)
      Returns an Uint16 corresponding to a given uint.
      Parameters:
      uint - Uint8 value
      Returns:
      A Uint16 instance
      Throws:
      NullPointerException - if uint is null
    • valueOf

      public static Uint16 valueOf(Uint32 uint)
      Returns an Uint8 corresponding to a given uint.
      Parameters:
      uint - Uint32 value
      Returns:
      A Uint16 instance
      Throws:
      NullPointerException - if uint is null
      IllegalArgumentException - if uint is greater than 65535.
    • valueOf

      public static Uint16 valueOf(Uint64 uint)
      Returns an Uint8 corresponding to a given uint.
      Parameters:
      uint - Uint64 value
      Returns:
      A Uint16 instance
      Throws:
      NullPointerException - if uint is null
      IllegalArgumentException - if uint is greater than 65535.
    • valueOf

      public static Uint16 valueOf(String string)
      Returns an Uint16 holding the value of the specified String, parsed as an unsigned int value.
      Parameters:
      string - String to parse
      Returns:
      A Uint16 instance
      Throws:
      NullPointerException - if string is null
      IllegalArgumentException - if the parsed value is less than zero or greater than 65535
      NumberFormatException - if the string does not contain a parsable unsigned int value.
    • valueOf

      public static Uint16 valueOf(String string, int radix)
      Returns an Uint16 holding the value of the specified String, parsed as an unsigned int value.
      Parameters:
      string - String to parse
      radix - Radix to use
      Returns:
      A Uint16 instance
      Throws:
      NullPointerException - if string is null
      IllegalArgumentException - if the parsed value is less than zero or greater than 65535
      NumberFormatException - if the string does not contain a parsable unsigned int value, or if the radix is outside of allowed range.
    • saturatedOf

      public static Uint16 saturatedOf(byte byteVal)
      Returns an Uint16 corresponding to a given byteVal if it is representable. If the value is negative ZERO will be returned.
      Parameters:
      byteVal - byte value
      Returns:
      A Uint16 instance
    • saturatedOf

      public static Uint16 saturatedOf(short shortVal)
      Returns an Uint16 corresponding to a given shortVal if it is representable. If the value is negative ZERO will be returned.
      Parameters:
      shortVal - short value
      Returns:
      A Uint16 instance
    • saturatedOf

      public static Uint16 saturatedOf(int intVal)
      Returns an Uint16 corresponding to a given intVal if it is representable. If the value is negative ZERO will be returned. If the value is greater than 65535, MAX_VALUE will be returned.
      Parameters:
      intVal - int value
      Returns:
      A Uint16 instance
    • saturatedOf

      public static Uint16 saturatedOf(long longVal)
      Returns an Uint16 corresponding to a given longVal if it is representable. If the value is negative ZERO will be returned. If the value is greater than 65535, MAX_VALUE will be returned.
      Parameters:
      longVal - long value
      Returns:
      A Uint16 instance
    • shortValue

      public final short shortValue()

      The inverse operation is fromShortBits(short). In case this value is greater than Short.MAX_VALUE, the returned value will be equal to this - 2^16.

      Overrides:
      shortValue in class Number
    • intValue

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

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

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

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

      public final int compareTo(Uint16 o)
      Specified by:
      compareTo in interface Comparable<Uint16>
    • toCanonicalString

      public final String toCanonicalString()
      Description copied from interface: CanonicalValue
      Return the canonical string representation of this value.
      Specified by:
      toCanonicalString in interface CanonicalValue<Uint16>
      Returns:
      Canonical string
    • support

      public final CanonicalValueSupport<Uint16> support()
      Description copied from interface: CanonicalValue
      Return the CanonicalValue associated with this type. It can be used to create new instances of this representation.
      Specified by:
      support in interface CanonicalValue<Uint16>
      Returns:
      A CanonicalValue instance.
    • intern

      public final Uint16 intern()
      Return an interned (shared) instance equivalent to this object. This may return the same object.
      Returns:
      A shared instance.
    • toJava

      public final int toJava()
      Convert this value to an int.
      Returns:
      An int
    • toUint8

      public final Uint8 toUint8()
      Convert this value to a Uint8.
      Returns:
      A Uint8
      Throws:
      IllegalArgumentException - if this value is greater than 255.
    • toUint32

      public final Uint32 toUint32()
      Convert this value to a Uint32.
      Returns:
      A Uint32
    • toUint64

      public final Uint64 toUint64()
      Convert this value to a Uint64.
      Returns:
      A Uint64
    • toSaturatedUint8

      public final Uint8 toSaturatedUint8()
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • equals

      public final boolean equals(@Nullable Uint16 obj)
      A slightly faster version of equals(Object).
      Parameters:
      obj - Uint16 object
      Returns:
      true if this object is the same as the obj argument; false otherwise.
    • toString

      public final String toString()
      Overrides:
      toString in class Object