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.
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
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`" class="net.sf.basedb.core.data.ParameterValueData" */ 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();