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

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

    • ZERO

      public static final Uint8 ZERO
      Value of 0.
    • ONE

      public static final Uint8 ONE
      Value of 1.
    • TWO

      public static final Uint8 TWO
      Value of 2.
    • TEN

      public static final Uint8 TEN
      Value of 10.
    • MAX_VALUE

      public static final Uint8 MAX_VALUE
      Value of 255.
  • Constructor Details

    • Uint8

      protected Uint8(Uint8 other)
  • Method Details

    • fromByteBits

      public static Uint8 fromByteBits(byte bits)
      Returns an Uint8 corresponding to a given bit representation. The argument is interpreted as an unsigned 8-bit value.
      Parameters:
      bits - unsigned bit representation
      Returns:
      A Uint8 instance
    • valueOf

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

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

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

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

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

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

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

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

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

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

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

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

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

      public final byte byteValue()

      The inverse operation is fromByteBits(byte). In case this value is greater than Byte.MAX_VALUE, the returned value will be equal to this - 2^8.

      Overrides:
      byteValue 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(Uint8 o)
      Specified by:
      compareTo in interface Comparable<Uint8>
    • toCanonicalString

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

      public final CanonicalValueSupport<Uint8> 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<Uint8>
      Returns:
      A CanonicalValue instance.
    • toJava

      public final short toJava()
      Convert this value to a short.
      Returns:
      A short
    • toUint16

      public final Uint16 toUint16()
      Convert this value to a Uint16.
      Returns:
      A Uint16
    • 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
    • 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 Uint8 obj)
      A slightly faster version of equals(Object).
      Parameters:
      obj - Uint8 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