public final class ConfigurationParameterFactory extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ConfigurationParameterFactory.ConfigurationData
A simple class for storing an array of configuration parameters along with an array of the
values that will fill in those configuration parameters
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addConfigurationParameter(ResourceCreationSpecifier specifier,
String name,
Object value)
Adds a single configuration parameter name value pair to a specifier
|
static void |
addConfigurationParameters(ResourceCreationSpecifier specifier,
Class<?>... dynamicallyLoadedClasses)
Provides a mechanism to add configuration parameter information to a specifier for the given
classes.
|
static void |
addConfigurationParameters(ResourceCreationSpecifier specifier,
List<Class<?>> dynamicallyLoadedClasses)
Provides a mechanism to add configuration parameter information to a specifier for the given
classes.
|
static void |
addConfigurationParameters(ResourceCreationSpecifier specifier,
Object... configurationData)
This method adds configuration parameter information to the specifier given the provided
configuration data
|
static boolean |
canParameterBeSet(ResourceSpecifier aSpec,
String name)
Check if the given parameter can be set on the provided specifier.
|
protected static Object |
convertParameterValue(ConfigurationParameter param,
Object aValue)
Convert a value so it can be injected into a UIMA component.
|
static ConfigurationParameterFactory.ConfigurationData |
createConfigurationData(Class<?> componentClass)
This method creates configuration data for a given class definition using reflection and the
configuration parameter annotation
|
static ConfigurationParameterFactory.ConfigurationData |
createConfigurationData(Object... configurationData)
This method converts configuration data provided as an array of objects and returns a
ConfigurationParameterFactory.ConfigurationData object. |
static ConfigurationParameter |
createPrimitiveParameter(Field field)
A factory method for creating a ConfigurationParameter from a given field definition
|
static ConfigurationParameter |
createPrimitiveParameter(String name,
Class<?> parameterClass,
String parameterDescription,
boolean isMandatory)
A factory method for creating a ConfigurationParameter object.
|
static ConfigurationParameter |
createPrimitiveParameter(String name,
String parameterType,
String parameterDescription,
boolean isMultiValued,
boolean isMandatory)
A factory method for creating a ConfigurationParameter object.
|
static String |
getConfigurationParameterName(Field field)
This method generates the default name of a configuration parameter that is defined by an
ConfigurationParameter annotation when no name is given |
static Object |
getDefaultValue(Field field)
Determines the default value of an annotated configuration parameter.
|
static Map<String,Object> |
getParameterSettings(ResourceSpecifier spec)
Fetches the parameter settings from the given resource specifier.
|
static boolean |
isConfigurationParameterField(Field field)
This method determines if the field is annotated with
ConfigurationParameter. |
static void |
setParameter(ResourceSpecifier aSpec,
String name,
Object value)
Sets the specified parameter in the given resource specifier.
|
static void |
setParameters(ResourceCreationSpecifier desc,
Class<?> componentClass,
ConfigurationParameter[] configurationParameters,
Object[] configurationValues)
Analyze a component for parameters and default values, merge that with parameter values
specified, potentially adding extra parameters.
|
public static boolean isConfigurationParameterField(Field field)
ConfigurationParameter.field - the field to analyzepublic static Object getDefaultValue(Field field)
field - the field to analyzepublic static String getConfigurationParameterName(Field field)
ConfigurationParameter annotation when no name is givenfield - the field to analyzepublic static ConfigurationParameter createPrimitiveParameter(Field field)
field - the field to analyzepublic static ConfigurationParameter createPrimitiveParameter(String name, Class<?> parameterClass, String parameterDescription, boolean isMandatory)
name - the parameter nameparameterClass - the parameter classparameterDescription - the parameter descriptionisMandatory - whether the parameter is mandatoryprotected static Object convertParameterValue(ConfigurationParameter param, Object aValue)
param - the configuration parameter.aValue - the parameter value.public static ConfigurationParameter createPrimitiveParameter(String name, String parameterType, String parameterDescription, boolean isMultiValued, boolean isMandatory)
name - the parameter nameparameterType - the parameter typeparameterDescription - the parameter descriptionisMultiValued - whether the parameter is multi-valuedisMandatory - whether the parameter is mandatorypublic static void setParameters(ResourceCreationSpecifier desc, Class<?> componentClass, ConfigurationParameter[] configurationParameters, Object[] configurationValues)
desc - the descriptor into which to merge the parameterscomponentClass - the component class which will be analyzed for parameters. Must match the
implementationName set in the descriptor.configurationParameters - additional parameter namesconfigurationValues - additional parameters valuespublic static ConfigurationParameterFactory.ConfigurationData createConfigurationData(Object... configurationData)
ConfigurationParameterFactory.ConfigurationData object. This should only be used to prepare values supplied in a
factory method call for merging with existing parameter declarations, e.g. extracted from a
class using createConfigurationData(Class).configurationData - configuration parameters as (name, value) pairs, so there should always be an even
number of parameters.public static ConfigurationParameterFactory.ConfigurationData createConfigurationData(Class<?> componentClass)
componentClass - the class to analyzepublic static void addConfigurationParameters(ResourceCreationSpecifier specifier, Object... configurationData)
specifier - the specified to add the parameters toconfigurationData - should consist of name value pairs.public static void addConfigurationParameters(ResourceCreationSpecifier specifier, List<Class<?>> dynamicallyLoadedClasses)
specifier - the specified to add the parameters todynamicallyLoadedClasses - the classes to analyze and extract parameter information frompublic static void addConfigurationParameters(ResourceCreationSpecifier specifier, Class<?>... dynamicallyLoadedClasses)
specifier - the specified to add the parameters todynamicallyLoadedClasses - the classes to analyze and extract parameter information frompublic static void addConfigurationParameter(ResourceCreationSpecifier specifier, String name, Object value)
specifier - the specifier to add the parameter setting toname - the name of the parametervalue - the parameter valuepublic static Map<String,Object> getParameterSettings(ResourceSpecifier spec)
spec - a resource specifier.public static void setParameter(ResourceSpecifier aSpec, String name, Object value)
CustomResourceSpecifier an exception is thrown if the parameter value not a String.aSpec - a resource specifier.name - the parameter name.value - the parameter value.IllegalArgumentException - if the value is not of a supported type for the given specifier.public static boolean canParameterBeSet(ResourceSpecifier aSpec, String name)
aSpec - the specifier to testname - the parameter to be testedCopyright © 2012–2021 The Apache Software Foundation. All rights reserved.