Class ObjectUtil
java.lang.Object
com.swiftmq.impl.mqtt.v311.netty.util.internal.ObjectUtil
A grab-bag of useful utility methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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> TcheckNotNull(T arg, String text) Checks that the given argument is not null.static intcheckPositive(int i, String name) Checks that the given argument is strictly positive.static longcheckPositive(long i, String name) Checks that the given argument is strictly positive.static intcheckPositiveOrZero(int i, String name) Checks that the given argument is positive or zero.static longcheckPositiveOrZero(long i, String name) Checks that the given argument is positive or zero.static intResolves a possibly null Integer to a primitive int, using a default value.static longResolves a possibly null Long to a primitive long, using a default value.
-
Method Details
-
checkNotNull
Checks that the given argument is not null. If it is, throwsNullPointerException. Otherwise, returns the argument. -
checkPositive
Checks that the given argument is strictly positive. If it is not, throwsIllegalArgumentException. Otherwise, returns the argument. -
checkPositive
Checks that the given argument is strictly positive. If it is not, throwsIllegalArgumentException. Otherwise, returns the argument. -
checkPositiveOrZero
Checks that the given argument is positive or zero. If it is not , throwsIllegalArgumentException. Otherwise, returns the argument. -
checkPositiveOrZero
Checks that the given argument is positive or zero. If it is not, throwsIllegalArgumentException. Otherwise, returns the argument. -
checkNonEmpty
Checks that the given argument is neither null nor empty. If it is, throwsNullPointerExceptionorIllegalArgumentException. Otherwise, returns the argument. -
checkNonEmpty
Checks that the given argument is neither null nor empty. If it is, throwsNullPointerExceptionorIllegalArgumentException. Otherwise, returns the argument. -
intValue
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
Resolves a possibly null Long to a primitive long, using a default value.- Parameters:
wrapper- the wrapperdefaultValue- the default value- Returns:
- the primitive value
-