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 Uint32fromGuava(com.google.common.primitives.UnsignedInteger value) Convert anUnsignedIntegerto a Uint32.static Uint64fromGuava(com.google.common.primitives.UnsignedLong value) Convert anUnsignedLongto a Uint64.static Uint16fromJava(int value) Convert anintin range 0-65535 to a Uint16.static Uint32fromJava(long value) Convert alongin range 0-4294967295 to a Uint32.static Uint8fromJava(short value) Convert ashortin range 0-255 to an Uint8.static Uint64fromJava(BigInteger value) Convert aBigIntegerin range 0-18446744073709551615 to an Uint64.
-
Method Details
-
fromJava
Convert ashortin 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 anintin 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 alongin 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 aBigIntegerin 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 anUnsignedIntegerto a Uint32.- Parameters:
value- value- Returns:
- Uint32 object
- Throws:
NullPointerException- if value is null
-
fromGuava
Convert anUnsignedLongto a Uint64.- Parameters:
value- value- Returns:
- Uint64 object
- Throws:
NullPointerException- if value is null
-