Top Fields Constructors Methods
io.rsocket.util

public final Class NumberUtils

extends Object
Class Inheritance
Imports
io.netty.buffer.ByteBuf, java.util.Objects

Field Summary

Modifier and TypeField and Description
public static final int
MEDIUM_BYTES

The size of a medium in bytes.

private static final int
private static final int
private static final int
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
encodeUnsignedMedium(ByteBuf
the ByteBuf into which to write the bits
byteBuf
,
int
the medium integer to encode
i
)

Encode an unsigned medium integer on 3 bytes / 24 bits.

public static int

Returns:

the int if greater than or equal to zero
requireNonNegative
(int
the int to test
i
,
String
detail message to be used in the event that a IllegalArgumentException is thrown
message
)

Requires that an int is greater than or equal to zero.

public static long

Returns:

the long if greater than zero
requirePositive
(long
the long to test
l
,
String
detail message to be used in the event that a IllegalArgumentException is thrown
message
)

Requires that a long is greater than zero.

public static int

Returns:

the int if greater than zero
requirePositive
(int
the int to test
i
,
String
detail message to be used in the event that a IllegalArgumentException is thrown
message
)

Requires that an int is greater than zero.

public static int

Returns:

the int if it can be represented as an unsigned byte
requireUnsignedByte
(int
the int to test
i
)

Requires that an int can be represented as an unsigned byte.

public static int

Returns:

the int if it can be represented as an unsigned medium
requireUnsignedMedium
(int
the int to test
i
)

Requires that an int can be represented as an unsigned medium.

public static int

Returns:

the int if it can be represented as an unsigned short
requireUnsignedShort
(int
the int to test
i
)

Requires that an int can be represented as an unsigned short.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MEDIUM_BYTESback to summary
public static final int MEDIUM_BYTES

The size of a medium in bytes.

UNSIGNED_BYTE_MAX_VALUEback to summary
private static final int UNSIGNED_BYTE_MAX_VALUE
UNSIGNED_BYTE_SIZEback to summary
private static final int UNSIGNED_BYTE_SIZE
UNSIGNED_MEDIUM_MAX_VALUEback to summary
private static final int UNSIGNED_MEDIUM_MAX_VALUE
UNSIGNED_MEDIUM_SIZEback to summary
private static final int UNSIGNED_MEDIUM_SIZE
UNSIGNED_SHORT_MAX_VALUEback to summary
private static final int UNSIGNED_SHORT_MAX_VALUE
UNSIGNED_SHORT_SIZEback to summary
private static final int UNSIGNED_SHORT_SIZE

Constructor Detail

NumberUtilsback to summary
private NumberUtils()

Method Detail

encodeUnsignedMediumback to summary
public static void encodeUnsignedMedium(ByteBuf byteBuf, int i)

Encode an unsigned medium integer on 3 bytes / 24 bits. This can be decoded directly by the ByteBuf#readUnsignedMedium() method.

Parameters
byteBuf:ByteBuf

the ByteBuf into which to write the bits

i:int

the medium integer to encode

See Also
requireUnsignedMedium(int)
requireNonNegativeback to summary
public static int requireNonNegative(int i, String message)

Requires that an int is greater than or equal to zero.

Parameters
i:int

the int to test

message:String

detail message to be used in the event that a IllegalArgumentException is thrown

Returns:int

the int if greater than or equal to zero

Exceptions
IllegalArgumentException:
if i is less than zero
requirePositiveback to summary
public static long requirePositive(long l, String message)

Requires that a long is greater than zero.

Parameters
l:long

the long to test

message:String

detail message to be used in the event that a IllegalArgumentException is thrown

Returns:long

the long if greater than zero

Exceptions
IllegalArgumentException:
if l is less than or equal to zero
requirePositiveback to summary
public static int requirePositive(int i, String message)

Requires that an int is greater than zero.

Parameters
i:int

the int to test

message:String

detail message to be used in the event that a IllegalArgumentException is thrown

Returns:int

the int if greater than zero

Exceptions
IllegalArgumentException:
if i is less than or equal to zero
requireUnsignedByteback to summary
public static int requireUnsignedByte(int i)

Requires that an int can be represented as an unsigned byte.

Parameters
i:int

the int to test

Returns:int

the int if it can be represented as an unsigned byte

Exceptions
IllegalArgumentException:
if i cannot be represented as an unsigned byte
requireUnsignedMediumback to summary
public static int requireUnsignedMedium(int i)

Requires that an int can be represented as an unsigned medium.

Parameters
i:int

the int to test

Returns:int

the int if it can be represented as an unsigned medium

Exceptions
IllegalArgumentException:
if i cannot be represented as an unsigned medium
requireUnsignedShortback to summary
public static int requireUnsignedShort(int i)

Requires that an int can be represented as an unsigned short.

Parameters
i:int

the int to test

Returns:int

the int if it can be represented as an unsigned short

Exceptions
IllegalArgumentException:
if i cannot be represented as an unsigned short