Class ParametersChecker

java.lang.Object
fr.gouv.vitam.common.ParametersChecker

public final class ParametersChecker extends Object
Checker for Parameters

Can be used for String (testing also emptiness) and for general Object.
For null String only, use the special method.
  • Method Details

    • checkParameter

      public static void checkParameter(String errorMessage, String... parameters)
      Check if any parameter are null or empty and if so, throw an IllegalArgumentException
      Parameters:
      errorMessage - the error message
      parameters - parameters to be checked
      Throws:
      IllegalArgumentException - if null or empty
    • checkParameterDefault

      public static void checkParameterDefault(String errorMessage, String... parameters)
      Check if any parameter are null or empty and if so, throw an IllegalArgumentException
      Parameters:
      errorMessage - the error message
      parameters - set of parameters
      Throws:
      IllegalArgumentException - if null or empty
    • isNotEmpty

      public static boolean isNotEmpty(String... parameters)
      Check if any parameter are null or empty and if so, return false
      Parameters:
      parameters - set of parameters
      Returns:
      True if not null and not empty neither containing only spaces
    • checkParameterDefault

      public static void checkParameterDefault(String errorMessage, Object... parameters)
      Check if any parameter are null or empty and if so, throw an IllegalArgumentException
      Parameters:
      errorMessage - the error message
      parameters - set of parameters
      Throws:
      IllegalArgumentException - if null or empty
    • checkParameterNullOnly

      public static void checkParameterNullOnly(String errorMessage, String... parameters)
      Check if any parameter are null and if so, throw an IllegalArgumentException
      Parameters:
      errorMessage - the error message
      parameters - parameters to be checked
      Throws:
      IllegalArgumentException - if null
    • checkParameter

      public static void checkParameter(String errorMessage, Object... parameters)
      Check if any parameter are null and if so, throw an IllegalArgumentException
      Parameters:
      errorMessage - set of parameters
      parameters - set parameters to be checked
      Throws:
      IllegalArgumentException - if null
    • checkDateParam

      public static void checkDateParam(String errorMessage, String date)
    • checkValue

      public static void checkValue(String name, long variable, long minValue)
      Check if an integer parameter is greater or equals to minValue
      Parameters:
      name - name of the variable
      variable - the value of variable to check
      minValue - the min value
    • checkNullOrEmptyParameter

      public static <T extends Enum<T>> void checkNullOrEmptyParameter(T key, String value, Set<T> mandatories)
      Check parameter emptiness or nullity
      Parameters:
      key - the attribute name
      value - the attribute value to check
      mandatories - the set of mandatories field
      Throws:
      IllegalArgumentException - if an argument is null or empty against mandatory
    • checkNullOrEmptyParameters

      public static <T extends Enum<T>> void checkNullOrEmptyParameters(Map<T,String> parameters, Set<T> mandatories)
      Check parameters emptiness or nullity
      Parameters:
      parameters - the map parameters (key = attribute name, value = attribute value)
      mandatories - the set of mandatories field
      Throws:
      IllegalArgumentException - if an argument is null or empty against mandatory
    • checkNullOrEmptyParameters

      public static <T extends VitamParameter> void checkNullOrEmptyParameters(T parameter)
      Check parameters emptiness or nullity
      Parameters:
      parameter - the template of vitam parameter
      Throws:
      IllegalArgumentException - if an argument is null or empty against mandatory
    • checkNullOrEmptyParameters

      public static <T extends VitamParameter> void checkNullOrEmptyParameters(T... parameters)
      Check parameters emptiness or nullity
      Parameters:
      parameters - the template of vitam parameter
      Throws:
      IllegalArgumentException - if an argument is null or empty against mandatory
    • checkNullOrEmptyParameters

      public static <T> List<T> checkNullOrEmptyParameters(String errorMessage, List<T> parameters)
      Check List parameters emptiness or nullity
      Parameters:
      parameters - list of parameters
      Returns:
      list of parameters
      Throws:
      IllegalArgumentException - if list is null or empty