Package com.restfb.util
Class ObjectUtil
- java.lang.Object
-
- com.restfb.util.ObjectUtil
-
public class ObjectUtil extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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 void
requireNotEmpty(Collection<?> collection, String errorText)
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 Detail
-
requireNotEmpty
public static String requireNotEmpty(String obj, String errorText)
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.
-
requireNotEmpty
public static void requireNotEmpty(Collection<?> collection, String errorText)
-
requireNotNull
public static <T extends Exception> void requireNotNull(Object obj, Supplier<T> exceptionSupplier) throws T extends Exception
Ensures 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
.T extends Exception
-
isEmptyCollectionOrMap
public static boolean isEmptyCollectionOrMap(Object obj)
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
public static void verifyParameterPresence(String parameterName, String parameter)
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
public static void verifyParameterPresence(String parameterName, Object parameter)
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
.
-
-