Package org.drasyl.util
Class UnsignedShort
- java.lang.Object
-
- org.drasyl.util.UnsignedShort
-
public final class UnsignedShort extends Object
This class represents an unsigned short in a rang of [0, 2^16)
-
-
Field Summary
Fields Modifier and Type Field Description static UnsignedShort
MAX_VALUE
static UnsignedShort
MIN_VALUE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UnsignedShort
decrement()
boolean
equals(Object o)
int
getValue()
int
hashCode()
UnsignedShort
increment()
static UnsignedShort
of(byte[] value)
Creates a newUnsignedShort
.static UnsignedShort
of(int value)
Creates a newUnsignedShort
.byte[]
toBytes()
String
toString()
-
-
-
Field Detail
-
MIN_VALUE
public static final UnsignedShort MIN_VALUE
-
MAX_VALUE
public static final UnsignedShort MAX_VALUE
-
-
Method Detail
-
of
public static UnsignedShort of(int value)
Creates a newUnsignedShort
.- Parameters:
value
- the value as integer- Returns:
- an unsigned short
- Throws:
IllegalArgumentException
- if the value is not in range of [0, 2^16).
-
of
public static UnsignedShort of(byte[] value)
Creates a newUnsignedShort
.- Parameters:
value
- the value as byte array in big-endian (BE) format- Returns:
- an unsigned short
- Throws:
IllegalArgumentException
- if the value is not in range of [0, 2^16).
-
toBytes
public byte[] toBytes()
- Returns:
- a byte array of length 2.
-
getValue
public int getValue()
- Returns:
- the value as integer.
-
increment
public UnsignedShort increment()
-
decrement
public UnsignedShort decrement()
-
-