Package io.netty.util.internal
Class ObjectUtil
- java.lang.Object
-
- io.netty.util.internal.ObjectUtil
-
public final class ObjectUtil extends Object
A grab-bag of useful utility methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
checkInRange(int i, int start, int end, String name)
Checks that the given argument is in range.static long
checkInRange(long l, long start, long end, String name)
Checks that the given argument is in range.static <T> T[]
checkNonEmpty(T[] array, String name)
Checks that the given argument is neither null nor empty.static <T extends Collection<?>>
TcheckNonEmpty(T collection, String name)
Checks that the given argument is neither null nor empty.static <T> T
checkNotNull(T arg, String text)
Checks that the given argument is not null.static int
checkPositive(int i, String name)
Checks that the given argument is strictly positive.static long
checkPositive(long l, String name)
Checks that the given argument is strictly positive.static int
checkPositiveOrZero(int i, String name)
Checks that the given argument is positive or zero.static long
checkPositiveOrZero(long l, String name)
Checks that the given argument is positive or zero.static int
intValue(Integer wrapper, int defaultValue)
Resolves a possibly null Integer to a primitive int, using a default value.static long
longValue(Long wrapper, long defaultValue)
Resolves a possibly null Long to a primitive long, using a default value.
-
-
-
Method Detail
-
checkNotNull
public static <T> T checkNotNull(T arg, String text)
Checks that the given argument is not null. If it is, throwsNullPointerException
. Otherwise, returns the argument.
-
checkPositive
public static int checkPositive(int i, String name)
Checks that the given argument is strictly positive. If it is not, throwsIllegalArgumentException
. Otherwise, returns the argument.
-
checkPositive
public static long checkPositive(long l, String name)
Checks that the given argument is strictly positive. If it is not, throwsIllegalArgumentException
. Otherwise, returns the argument.
-
checkPositiveOrZero
public static int checkPositiveOrZero(int i, String name)
Checks that the given argument is positive or zero. If it is not , throwsIllegalArgumentException
. Otherwise, returns the argument.
-
checkPositiveOrZero
public static long checkPositiveOrZero(long l, String name)
Checks that the given argument is positive or zero. If it is not, throwsIllegalArgumentException
. Otherwise, returns the argument.
-
checkInRange
public static int checkInRange(int i, int start, int end, String name)
Checks that the given argument is in range. If it is not, throwsIllegalArgumentException
. Otherwise, returns the argument.
-
checkInRange
public static long checkInRange(long l, long start, long end, String name)
Checks that the given argument is in range. If it is not, throwsIllegalArgumentException
. Otherwise, returns the argument.
-
checkNonEmpty
public static <T> T[] checkNonEmpty(T[] array, String name)
Checks that the given argument is neither null nor empty. If it is, throwsNullPointerException
orIllegalArgumentException
. Otherwise, returns the argument.
-
checkNonEmpty
public static <T extends Collection<?>> T checkNonEmpty(T collection, String name)
Checks that the given argument is neither null nor empty. If it is, throwsNullPointerException
orIllegalArgumentException
. Otherwise, returns the argument.
-
intValue
public static int intValue(Integer wrapper, int defaultValue)
Resolves a possibly null Integer to a primitive int, using a default value.- Parameters:
wrapper
- the wrapperdefaultValue
- the default value- Returns:
- the primitive value
-
longValue
public static long longValue(Long wrapper, long defaultValue)
Resolves a possibly null Long to a primitive long, using a default value.- Parameters:
wrapper
- the wrapperdefaultValue
- the default value- Returns:
- the primitive value
-
-