Package com.restfb.util
Class ObjectUtil
java.lang.Object
com.restfb.util.ObjectUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isEmptyCollectionOrMap(Object obj)
Checks is the object is a empty 'collection' or 'map'.static String
requireNotEmpty(String obj, String errorText)
Ensures thatobj
isn'tnull
or an empty string.static <T extends Exception>
voidrequireNotNull(Object obj, Supplier<T> exceptionSupplier)
Ensures thatobj
isn'tnull
.static void
verifyParameterPresence(String parameterName, Object parameter)
Ensures thatparameter
isn'tnull
.static void
verifyParameterPresence(String parameterName, String parameter)
Ensures thatparameter
isn'tnull
or an empty string.
-
Method Details
-
requireNotEmpty
Ensures thatobj
isn'tnull
or an empty string.- Parameters:
obj
- The parameter to check.errorText
- The exception message.- Throws:
IllegalArgumentException
- Ifobj
isnull
or an empty string.
-
requireNotNull
public static <T extends Exception> void requireNotNull(Object obj, Supplier<T> exceptionSupplier) throws TEnsures thatobj
isn'tnull
.- Parameters:
obj
- The parameter to check.exceptionSupplier
- The supplier for the exception that is thrown if obj is null.- Throws:
T
- Ifobj
isnull
.
-
isEmptyCollectionOrMap
Checks is the object is a empty 'collection' or 'map'.- Parameters:
obj
- the object that is checked- Returns:
true
if the given object is a empty collection or an empty map,false
otherwise
-
verifyParameterPresence
Ensures thatparameter
isn'tnull
or an empty string.- Parameters:
parameterName
- The name of the parameter (to be used in exception message).parameter
- The parameter to check.- Throws:
IllegalArgumentException
- Ifparameter
isnull
or an empty string.
-
verifyParameterPresence
Ensures thatparameter
isn'tnull
.- Parameters:
parameterName
- The name of the parameter (to be used in exception message).parameter
- The parameter to check.- Throws:
NullPointerException
- Ifparameter
isnull
.
-