Class ObjectUtil

java.lang.Object
com.restfb.util.ObjectUtil

public class ObjectUtil extends Object
  • Method Details

    • requireNotEmpty

      public static String requireNotEmpty(String obj, String errorText)
      Ensures that obj isn't null or an empty string.
      Parameters:
      obj - The parameter to check.
      errorText - The exception message.
      Throws:
      IllegalArgumentException - If obj is null 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
      Ensures that obj isn't null.
      Parameters:
      obj - The parameter to check.
      exceptionSupplier - The supplier for the exception that is thrown if obj is null.
      Throws:
      T - If obj is null.
    • 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 that parameter isn't null or an empty string.
      Parameters:
      parameterName - The name of the parameter (to be used in exception message).
      parameter - The parameter to check.
      Throws:
      IllegalArgumentException - If parameter is null or an empty string.
    • verifyParameterPresence

      public static void verifyParameterPresence(String parameterName, Object parameter)
      Ensures that parameter isn't null.
      Parameters:
      parameterName - The name of the parameter (to be used in exception message).
      parameter - The parameter to check.
      Throws:
      NullPointerException - If parameter is null.