Class UintConversions
- java.lang.Object
-
- org.opendaylight.yangtools.yang.common.UintConversions
-
@Beta @NonNullByDefault public final class UintConversions extends Object
Utility methods for converting Java and Guava integer types to theirUint8
,Uint16
,Uint32
andUint64
equivalents. While individual types provide these through theirvalueOf()
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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Uint32
fromGuava(UnsignedInteger value)
Convert anUnsignedInteger
to a Uint32.static Uint64
fromGuava(UnsignedLong value)
Convert anUnsignedLong
to a Uint64.static Uint16
fromJava(int value)
Convert anint
in range 0-65535 to a Uint16.static Uint32
fromJava(long value)
Convert along
in range 0-4294967295 to a Uint32.static Uint8
fromJava(short value)
Convert ashort
in range 0-255 to an Uint8.static Uint64
fromJava(BigInteger value)
Convert aBigInteger
in range 0-18446744073709551615 to an Uint64.
-
-
-
Method Detail
-
fromJava
public static Uint8 fromJava(short value)
Convert ashort
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 anint
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 along
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 aBigInteger
in range 0-18446744073709551615 to an Uint64.- Parameters:
value
- value- Returns:
- Uint64 object
- Throws:
NullPointerException
- if value is nullIllegalArgumentException
- if value is less than zero or greater than 18446744073709551615
-
fromGuava
public static Uint32 fromGuava(UnsignedInteger value)
Convert anUnsignedInteger
to a Uint32.- Parameters:
value
- value- Returns:
- Uint32 object
- Throws:
NullPointerException
- if value is null
-
fromGuava
public static Uint64 fromGuava(UnsignedLong value)
Convert anUnsignedLong
to a Uint64.- Parameters:
value
- value- Returns:
- Uint64 object
- Throws:
NullPointerException
- if value is null
-
-