Package org.drasyl.util
Class UnsignedShort
java.lang.Object
org.drasyl.util.UnsignedShort
This class represents an unsigned short in a rang of [0, 2^16 - 1]
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
int
getValue()
int
hashCode()
static UnsignedShort
of
(byte[] value) Creates a newUnsignedShort
.static UnsignedShort
of
(int value) Creates a newUnsignedShort
.byte[]
toBytes()
toString()
-
Field Details
-
MIN_VALUE
-
MAX_VALUE
-
-
Method Details
-
of
Creates a newUnsignedShort
.- Parameters:
value
- the value as integer- Returns:
- an unaligned short
- Throws:
IllegalArgumentException
- if the value is not in range of [0, 2^16 - 1].
-
of
Creates a newUnsignedShort
.- Parameters:
value
- the value as byte array in big-endian (BE) format- Returns:
- an unaligned short
- Throws:
IllegalArgumentException
- if the value is not in range of [0, 2^16 - 1].
-
toBytes
public byte[] toBytes()- Returns:
- a byte array of length 2.
-
getValue
public int getValue()- Returns:
- the value as integer.
-
toString
-
increment
-
decrement
-
equals
-
hashCode
public int hashCode()
-