Class UintConversions


  • @Beta
    @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);
       
     
    Author:
    Robert Varga
    • Method Detail

      • 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