Class UintConversions

java.lang.Object
org.opendaylight.yangtools.yang.common.UintConversions

@NonNullByDefault public final class UintConversions extends Object
Utility methods for converting Java and Guava integer types to their Uint8, Uint16, Uint32 and Uint64 equivalents. While individual types provide these through their valueOf() methods, this class allows dealing with multiple types through a static import:
   
     import static org.opendaylight.yangtools.yang.common.UintConversions.fromJava;

     Uint16 two = fromJava(32);
     Uint32 one = fromJava(32L);
   
 
  • Method Details

    • fromJava

      public static Uint8 fromJava(short value)
      Convert a short in range 0-255 to an Uint8.
      Parameters:
      value - value
      Returns:
      Uint8 object
      Throws:
      IllegalArgumentException - if value is less than zero or greater than 255
    • fromJava

      public static Uint16 fromJava(int value)
      Convert an int in range 0-65535 to a Uint16.
      Parameters:
      value - value
      Returns:
      Uint16 object
      Throws:
      IllegalArgumentException - if value is less than zero or greater than 65535.
    • fromJava

      public static Uint32 fromJava(long value)
      Convert a long in range 0-4294967295 to a Uint32.
      Parameters:
      value - value
      Returns:
      Uint32 object
      Throws:
      IllegalArgumentException - if value is less than zero or greater than 4294967295
    • fromJava

      public static Uint64 fromJava(BigInteger value)
      Convert a BigInteger in range 0-18446744073709551615 to an Uint64.
      Parameters:
      value - value
      Returns:
      Uint64 object
      Throws:
      NullPointerException - if value is null
      IllegalArgumentException - if value is less than zero or greater than 18446744073709551615
    • fromGuava

      public static Uint32 fromGuava(UnsignedInteger value)
      Convert an UnsignedInteger to a Uint32.
      Parameters:
      value - value
      Returns:
      Uint32 object
      Throws:
      NullPointerException - if value is null
    • fromGuava

      public static Uint64 fromGuava(UnsignedLong value)
      Convert an UnsignedLong to a Uint64.
      Parameters:
      value - value
      Returns:
      Uint64 object
      Throws:
      NullPointerException - if value is null