Package com.restfb.util
Class ObjectUtil
java.lang.Object
com.restfb.util.ObjectUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks is the object is a empty 'collection' or 'map'.static StringrequireNotEmpty(String obj, String errorText) Ensures thatobjisn'tnullor an empty string.static voidrequireNotEmpty(Collection<?> collection, String errorText) static <T extends Exception>
voidrequireNotNull(Object obj, Supplier<T> exceptionSupplier) Ensures thatobjisn'tnull.static voidverifyParameterPresence(String parameterName, Object parameter) Ensures thatparameterisn'tnull.static voidverifyParameterPresence(String parameterName, String parameter) Ensures thatparameterisn'tnullor an empty string.
-
Method Details
-
requireNotEmpty
Ensures thatobjisn'tnullor an empty string.- Parameters:
obj- The parameter to check.errorText- The exception message.- Throws:
IllegalArgumentException- Ifobjisnullor an empty string.
-
requireNotEmpty
-
requireNotNull
public static <T extends Exception> void requireNotNull(Object obj, Supplier<T> exceptionSupplier) throws T Ensures thatobjisn'tnull.- Parameters:
obj- The parameter to check.exceptionSupplier- The supplier for the exception that is thrown if obj is null.- Throws:
T- Ifobjisnull.
-
isEmptyCollectionOrMap
Checks is the object is a empty 'collection' or 'map'.- Parameters:
obj- the object that is checked- Returns:
trueif the given object is a empty collection or an empty map,falseotherwise
-
verifyParameterPresence
Ensures thatparameterisn'tnullor an empty string.- Parameters:
parameterName- The name of the parameter (to be used in exception message).parameter- The parameter to check.- Throws:
IllegalArgumentException- Ifparameterisnullor an empty string.
-
verifyParameterPresence
Ensures thatparameterisn'tnull.- Parameters:
parameterName- The name of the parameter (to be used in exception message).parameter- The parameter to check.- Throws:
NullPointerException- Ifparameterisnull.
-