001/*
002 *  Copyright 2012 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016
017package org.ametys.runtime.parameter;
018
019import java.util.Map;
020
021import org.ametys.runtime.i18n.I18nizableText;
022
023/**
024 * A parameter is defined with the following properties:
025 * <dl>
026 *  <dd>id
027 *  <dt>id of the parameter, must be unique
028 *  <dd>pluginName
029 *  <dt>the plugin name defining this parameter
030 *  <dd>label
031 *  <dt>the label (can be i18nized)
032 *  <dd>description
033 *  <dt>the description (can be i18nized)
034 *  <dd>type
035 *  <dt>the type
036 *  <dd>widget
037 *  <dt>the optional widget to use for rendering
038 *  <dd>enumerator
039 *  <dt>the optional enumerator
040 *  <dd>validator
041 *  <dt>the optional validator
042 *  <dd>defaultValue
043 *  <dt>the default value
044 * </dl>
045 * @param <T> the actual parameter type.
046 */
047public class Parameter<T>
048{
049    private String _id;
050    private String _pluginName;
051    private I18nizableText _label;
052    private I18nizableText _description;
053    private T _type;
054    private String _widget;
055    private Map<String, I18nizableText> _widgetParams;
056    private Enumerator _enumerator;
057    private Validator _validator;
058    private Object _defaultValue;
059
060    /**
061     * Get the id.
062     * @return Returns the id.
063     */
064    public String getId()
065    {
066        return _id;
067    }
068
069    /**
070     * Set the id.
071     * @param id the id.
072     */
073    public void setId(String id)
074    {
075        _id = id;
076    }
077
078    
079    /**
080     * Retrieves the name of the plugin declaring this parameter.
081     * @return the plugin name.
082     */
083    public String getPluginName()
084    {
085        return _pluginName;
086    }
087
088    /**
089     * Set the name of the plugin declaring this parameter.
090     * @param pluginName the plugin name.
091     */
092    public void setPluginName(String pluginName)
093    {
094        _pluginName = pluginName;
095    }
096
097    /**
098     * Retrieves the label.
099     * @return the label.
100     */
101    public I18nizableText getLabel()
102    {
103        return _label;
104    }
105
106    /**
107     * Set the label.
108     * @param label the label.
109     */
110    public void setLabel(I18nizableText label)
111    {
112        _label = label;
113    }
114
115    /**
116     * Retrieves the description.
117     * @return the description.
118     */
119    public I18nizableText getDescription()
120    {
121        return _description;
122    }
123
124    /**
125     * Set the description.
126     * @param description the description.
127     */
128    public void setDescription(I18nizableText description)
129    {
130        _description = description;
131    }
132
133    /**
134     * Retrieves the type.
135     * @return the type.
136     */
137    public T getType()
138    {
139        return _type;
140    }
141
142    /**
143     * Set the type.
144     * @param type the type.
145     */
146    public void setType(T type)
147    {
148        _type = type;
149    }
150
151    /**
152     * Retrieves the widget to use for rendering.
153     * @return the widget or <code>null</code> if none is defined.
154     */
155    public String getWidget()
156    {
157        return _widget;
158    }
159
160    /**
161     * Set the widget.
162     * @param widget the widget.
163     */
164    public void setWidget(String widget)
165    {
166        _widget = widget;
167    }
168    
169    /**
170     * Get the widget's parameters
171     * @return the widget's parameters
172     */
173    public Map<String, I18nizableText> getWidgetParameters()
174    {
175        return _widgetParams;
176    }
177    
178    /**
179     * Set the widget's parameters
180     * @param params the parameters to set
181     */
182    public void setWidgetParameters (Map<String, I18nizableText> params)
183    {
184        _widgetParams = params;
185    }
186    
187    /**
188     * Retrieves the enumerator.
189     * @return the enumerator or <code>null</code> if none is defined.
190     */
191    public Enumerator getEnumerator()
192    {
193        return _enumerator;
194    }
195
196    /**
197     * Set the enumerator.
198     * @param enumerator the enumerator.
199     */
200    public void setEnumerator(Enumerator enumerator)
201    {
202        _enumerator = enumerator;
203    }
204
205    /**
206     * Retrieves the validator.
207     * @return the validator or <code>null</code> if none is defined.
208     */
209    public Validator getValidator()
210    {
211        return _validator;
212    }
213
214    /**
215     * Set the validator.
216     * @param validator the validator.
217     */
218    public void setValidator(Validator validator)
219    {
220        _validator = validator;
221    }
222
223    /**
224     * Retrieves the default value.
225     * @return the default value or <code>null</code> if none is defined.
226     */
227    public Object getDefaultValue()
228    {
229        return _defaultValue;
230    }
231
232    /**
233     * Set the default value.
234     * @param defaultValue the default value.
235     */
236    public void setDefaultValue(Object defaultValue)
237    {
238        _defaultValue = defaultValue;
239    }
240}