Class UintConversions
java.lang.Object
org.opendaylight.yangtools.yang.common.UintConversions
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 Summary
Modifier and TypeMethodDescriptionstatic 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 Details
-
fromJava
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
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
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
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
Convert anUnsignedInteger
to a Uint32.- Parameters:
value
- value- Returns:
- Uint32 object
- Throws:
NullPointerException
- if value is null
-
fromGuava
Convert anUnsignedLong
to a Uint64.- Parameters:
value
- value- Returns:
- Uint64 object
- Throws:
NullPointerException
- if value is null
-