Package it.tidalwave.image.util
Class Parameters
- java.lang.Object
-
- it.tidalwave.image.util.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>
Tfind(java.lang.Class<T> parameterClass, T defaultOption, O... parameters)
Extracts a singled-value parameter of the given type from an array.
-
-
-
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, anIllegalparameterException
is thrown.- Parameters:
parameterClass
- the class of the parameter to retrievedefaultOption
- the default value of the parameterparameters
- the array of parameters- Throws:
IllegalparameterException
- if more than a single value is foundjava.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 retrieveparameters
- the array of parameters
-
-