Package io.netty.util.internal
Class ObjectUtil
- java.lang.Object
-
- io.netty.util.internal.ObjectUtil
-
public final class ObjectUtil extends java.lang.ObjectA grab-bag of useful utility methods.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateObjectUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T[]checkNonEmpty(T[] array, java.lang.String name)Checks that the given argument is neither null nor empty.static <T extends java.util.Collection<?>>
TcheckNonEmpty(T collection, java.lang.String name)Checks that the given argument is neither null nor empty.static <T> TcheckNotNull(T arg, java.lang.String text)Checks that the given argument is not null.static intcheckPositive(int i, java.lang.String name)Checks that the given argument is strictly positive.static longcheckPositive(long i, java.lang.String name)Checks that the given argument is strictly positive.static intcheckPositiveOrZero(int i, java.lang.String name)Checks that the given argument is positive or zero.static longcheckPositiveOrZero(long i, java.lang.String name)Checks that the given argument is positive or zero.static intintValue(java.lang.Integer wrapper, int defaultValue)Resolves a possibly null Integer to a primitive int, using a default value.static longlongValue(java.lang.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, java.lang.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, java.lang.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 i, java.lang.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, java.lang.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 i, java.lang.String name)Checks that the given argument is positive or zero. If it is not, throwsIllegalArgumentException. Otherwise, returns the argument.
-
checkNonEmpty
public static <T> T[] checkNonEmpty(T[] array, java.lang.String name)Checks that the given argument is neither null nor empty. If it is, throwsNullPointerExceptionorIllegalArgumentException. Otherwise, returns the argument.
-
checkNonEmpty
public static <T extends java.util.Collection<?>> T checkNonEmpty(T collection, java.lang.String name)Checks that the given argument is neither null nor empty. If it is, throwsNullPointerExceptionorIllegalArgumentException. Otherwise, returns the argument.
-
intValue
public static int intValue(java.lang.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(java.lang.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
-
-