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 - 1]
  • Field Details

  • Method Details

    • of

      public static UnsignedShort of(int value)
      Creates a new UnsignedShort.
      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

      public static UnsignedShort of(byte[] value)
      Creates a new UnsignedShort.
      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

      public String toString()
      Overrides:
      toString in class Object
    • increment

      public UnsignedShort increment()
    • decrement

      public UnsignedShort decrement()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object