Package it.tidalwave.util
Class Parameters
- java.lang.Object
-
- it.tidalwave.util.Parameters
-
public final class Parameters extends Object
This class provides a few static utility methods to extracts parameters from an array.- Version:
- $Id$
- Author:
- Fabrizio Giudici
- Status: stable API
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckNonNull(Object parameter, String name)static <T,O>
Collection<T>find(Class<T> parameterClass, O... parameters)Extracts multiple-value parameters of the given type from an array.static <T,O>
Tfind(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 Object parameter, @Nonnull String name) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
find
@CheckForNull public static <T,O> T find(@Nonnull Class<T> parameterClass, @CheckForNull T defaultOption, @Nonnull O... parameters) throws IllegalArgumentException
Extracts a singled-value parameter of the given type from an array. If the parameter is not found, the default value is returned. If more than a single parameter is found, anIllegalparameterExceptionis 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 foundIllegalArgumentException
-
find
@Nonnull public static <T,O> Collection<T> find(@Nonnull 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
-
-