Class ParametersChecker


  • public final class ParametersChecker
    extends java.lang.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 Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkDateParam​(java.lang.String errorMessage, java.lang.String date)  
      static <T extends java.lang.Enum<T>>
      void
      checkNullOrEmptyParameter​(T key, java.lang.String value, java.util.Set<T> mandatories)
      Check parameter emptiness or nullity
      static <T extends java.lang.Enum<T>>
      void
      checkNullOrEmptyParameters​(java.util.Map<T,​java.lang.String> parameters, java.util.Set<T> mandatories)
      Check parameters emptiness or nullity
      static <T extends VitamParameter>
      void
      checkNullOrEmptyParameters​(T parameter)
      Check parameters emptiness or nullity
      static <T extends VitamParameter>
      void
      checkNullOrEmptyParameters​(T... parameters)
      Check parameters emptiness or nullity
      static void checkParameter​(java.lang.String errorMessage, java.lang.Object... parameters)
      Check if any parameter are null and if so, throw an IllegalArgumentException
      static void checkParameter​(java.lang.String errorMessage, java.lang.String... parameters)
      Check if any parameter are null or empty and if so, throw an IllegalArgumentException
      static void checkParameterDefault​(java.lang.String errorMessage, java.lang.Object... parameters)
      Check if any parameter are null or empty and if so, throw an IllegalArgumentException
      static void checkParameterDefault​(java.lang.String errorMessage, java.lang.String... parameters)
      Check if any parameter are null or empty and if so, throw an IllegalArgumentException
      static void checkParameterNullOnly​(java.lang.String errorMessage, java.lang.String... parameters)
      Check if any parameter are null and if so, throw an IllegalArgumentException
      static void checkValue​(java.lang.String name, long variable, long minValue)
      Check if an integer parameter is greater or equals to minValue
      static boolean isNotEmpty​(java.lang.String... parameters)
      Check if any parameter are null or empty and if so, return false
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • checkParameter

        public static void checkParameter​(java.lang.String errorMessage,
                                          java.lang.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:
        java.lang.IllegalArgumentException - if null or empty
      • checkParameterDefault

        public static void checkParameterDefault​(java.lang.String errorMessage,
                                                 java.lang.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:
        java.lang.IllegalArgumentException - if null or empty
      • isNotEmpty

        public static boolean isNotEmpty​(java.lang.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​(java.lang.String errorMessage,
                                                 java.lang.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:
        java.lang.IllegalArgumentException - if null or empty
      • checkParameterNullOnly

        public static void checkParameterNullOnly​(java.lang.String errorMessage,
                                                  java.lang.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:
        java.lang.IllegalArgumentException - if null
      • checkParameter

        public static void checkParameter​(java.lang.String errorMessage,
                                          java.lang.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:
        java.lang.IllegalArgumentException - if null
      • checkDateParam

        public static void checkDateParam​(java.lang.String errorMessage,
                                          java.lang.String date)
      • checkValue

        public static void checkValue​(java.lang.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 java.lang.Enum<T>> void checkNullOrEmptyParameter​(T key,
                                                                                   java.lang.String value,
                                                                                   java.util.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:
        java.lang.IllegalArgumentException - if an argument is null or empty against mandatory
      • checkNullOrEmptyParameters

        public static <T extends java.lang.Enum<T>> void checkNullOrEmptyParameters​(java.util.Map<T,​java.lang.String> parameters,
                                                                                    java.util.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:
        java.lang.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:
        java.lang.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:
        java.lang.IllegalArgumentException - if an argument is null or empty against mandatory