Class Parameters


  • public final class Parameters
    extends java.lang.Object
    This class provides a few static utility methods to extracts parameters from an array.
    Author:
    Fabrizio Giudici
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void checkNonNull​(java.lang.Object parameter, java.lang.String name)  
      static <T,​O>
      java.util.Collection<T>
      find​(java.lang.Class<T> parameterClass, O... parameters)
      Extracts multiple-value parameters of the given type from an array.
      static <T,​O>
      T
      find​(java.lang.Class<T> parameterClass, T defaultOption, O... parameters)
      Extracts a singled-value parameter of the given type from an array.
      • Methods inherited from class java.lang.Object

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

      • checkNonNull

        public static void checkNonNull​(@CheckForNull
                                        java.lang.Object parameter,
                                        @Nonnull
                                        java.lang.String name)
                                 throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • find

        @CheckForNull
        public static <T,​O> T find​(@Nonnull
                                         java.lang.Class<T> parameterClass,
                                         @CheckForNull
                                         T defaultOption,
                                         @Nonnull
                                         O... parameters)
                                  throws java.lang.IllegalArgumentException
        Extracts a singled-value parameter of the given type from an array. If the parameter is not found, the default value is passed. If more than a single parameter is found, an IllegalparameterException is thrown.
        Parameters:
        parameterClass - the class of the parameter to retrieve
        defaultOption - the default value of the parameter
        parameters - the array of parameters
        Throws:
        IllegalparameterException - if more than a single value is found
        java.lang.IllegalArgumentException
      • find

        @Nonnull
        public static <T,​O> java.util.Collection<T> find​(@Nonnull
                                                               java.lang.Class<T> parameterClass,
                                                               @Nonnull
                                                               O... parameters)
        Extracts multiple-value parameters of the given type from an array. If the parameter is not found, an empty collection is returned.
        Parameters:
        parameterClass - the class of the parameter to retrieve
        parameters - the array of parameters