public final class NumberUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
MEDIUM_BYTES
The size of a medium in
bytes. |
| Modifier and Type | Method and Description |
|---|---|
static void |
encodeUnsignedMedium(ByteBuf byteBuf,
int i)
Encode an unsigned medium integer on 3 bytes / 24 bits.
|
static int |
requireNonNegative(int i,
String message)
Requires that an
int is greater than or equal to zero. |
static int |
requirePositive(int i,
String message)
Requires that an
int is greater than zero. |
static long |
requirePositive(long l,
String message)
Requires that a
long is greater than zero. |
static int |
requireUnsignedByte(int i)
Requires that an
int can be represented as an unsigned byte. |
static int |
requireUnsignedMedium(int i)
Requires that an
int can be represented as an unsigned medium. |
static int |
requireUnsignedShort(int i)
Requires that an
int can be represented as an unsigned short. |
public static final int MEDIUM_BYTES
bytes.public static int requireNonNegative(int i,
String message)
int is greater than or equal to zero.i - the int to testmessage - detail message to be used in the event that a IllegalArgumentException
is thrownint if greater than or equal to zeroIllegalArgumentException - if i is less than zeropublic static long requirePositive(long l,
String message)
long is greater than zero.l - the long to testmessage - detail message to be used in the event that a IllegalArgumentException
is thrownlong if greater than zeroIllegalArgumentException - if l is less than or equal to zeropublic static int requirePositive(int i,
String message)
int is greater than zero.i - the int to testmessage - detail message to be used in the event that a IllegalArgumentException
is thrownint if greater than zeroIllegalArgumentException - if i is less than or equal to zeropublic static int requireUnsignedByte(int i)
int can be represented as an unsigned byte.i - the int to testint if it can be represented as an unsigned byteIllegalArgumentException - if i cannot be represented as an unsigned bytepublic static int requireUnsignedMedium(int i)
int can be represented as an unsigned medium.i - the int to testint if it can be represented as an unsigned mediumIllegalArgumentException - if i cannot be represented as an unsigned mediumpublic static int requireUnsignedShort(int i)
int can be represented as an unsigned short.i - the int to testint if it can be represented as an unsigned shortIllegalArgumentException - if i cannot be represented as an unsigned shortpublic static void encodeUnsignedMedium(ByteBuf byteBuf, int i)
ByteBuf.readUnsignedMedium() method.byteBuf - the ByteBuf into which to write the bitsi - the medium integer to encoderequireUnsignedMedium(int)