29.2.9. Parameters

This section gives an overview the generic parameter system in BASE that is used to store annotation values, plugin configuration values, job parameter values, etc.

UML diagram

Figure 29.10. Parameters



The parameter system is a generic system that can store almost any kind of simple values (string, numbers, dates, etc.) and also links to other items. The ParameterValueData class is an abstract base class that can hold multiple values (all must be of the same type). Unless only a specific type of values should be stored, this is the class that should be used when creating references for storing parameter values. It makes it possible for a single relaltion to use any kind of values or for a collection reference to mix multiple types of values. A typical use case maps a Map with the parameter name as the key:

private Map<String, ParameterValueData<?>> configurationValues;
   Link parameter name with it's values.
   @hibernate.map table="`PluginConfigurationValues`" lazy="true" cascade="all"
   @hibernate.collection-key column="`pluginconfiguration_id`"
   @hibernate.collection-index column="`name`" type="string" length="255"
   @hibernate.collection-many-to-many column="`value_id`" 
public Map<String, ParameterValueData<?>> getConfigurationValues()
   return configurationValues;
void setConfigurationValues(Map<String, ParameterValueData<?>> configurationValues)
   this.configurationValues = configurationValues;

Now it is possible for the collection to store all types of values:

Map<String, ParameterValueData<?>> config = ...
config.put("names", new StringParameterValueData("A", "B", "C"));
config.put("sizes", new IntegerParameterValueData(10, 20, 30));

// When you later load those values again you have to cast 
// them to the correct class.
List<String> names = (List<String>)config.get("names").getValues();
List<Integer> sizes = (List<Integer>)config.get("sizes").getValues();