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)
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanintgetValue()inthashCode()static UnsignedShortof(byte[] value) Creates a newUnsignedShort.static UnsignedShortof(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 unsigned short
- Throws:
IllegalArgumentException- if the value is not in range of [0, 2^16).
-
of
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.
-
toString
-
increment
-
decrement
-
equals
-
hashCode
public int hashCode()
-