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 * @deprecated use ElementDefinition instead
047 */
048@Deprecated
049public class Parameter<T extends Enum<T>>
050{
051    private String _id;
052    private String _pluginName;
053    private I18nizableText _label;
054    private I18nizableText _description;
055    private T _type;
056    private String _widget;
057    private Map<String, I18nizableText> _widgetParams;
058    private Enumerator _enumerator;
059    private Validator _validator;
060    private Object _defaultValue;
061
062    /**
063     * Get the id.
064     * @return Returns the id.
065     */
066    public String getId()
067    {
068        return _id;
069    }
070
071    /**
072     * Set the id.
073     * @param id the id.
074     */
075    public void setId(String id)
076    {
077        _id = id;
078    }
079
080    
081    /**
082     * Retrieves the name of the plugin declaring this parameter.
083     * @return the plugin name.
084     */
085    public String getPluginName()
086    {
087        return _pluginName;
088    }
089
090    /**
091     * Set the name of the plugin declaring this parameter.
092     * @param pluginName the plugin name.
093     */
094    public void setPluginName(String pluginName)
095    {
096        _pluginName = pluginName;
097    }
098
099    /**
100     * Retrieves the label.
101     * @return the label.
102     */
103    public I18nizableText getLabel()
104    {
105        return _label;
106    }
107
108    /**
109     * Set the label.
110     * @param label the label.
111     */
112    public void setLabel(I18nizableText label)
113    {
114        _label = label;
115    }
116
117    /**
118     * Retrieves the description.
119     * @return the description.
120     */
121    public I18nizableText getDescription()
122    {
123        return _description;
124    }
125
126    /**
127     * Set the description.
128     * @param description the description.
129     */
130    public void setDescription(I18nizableText description)
131    {
132        _description = description;
133    }
134
135    /**
136     * Retrieves the type.
137     * @return the type.
138     */
139    public T getType()
140    {
141        return _type;
142    }
143
144    /**
145     * Set the type.
146     * @param type the type.
147     */
148    public void setType(T type)
149    {
150        _type = type;
151    }
152
153    /**
154     * Retrieves the widget to use for rendering.
155     * @return the widget or <code>null</code> if none is defined.
156     */
157    public String getWidget()
158    {
159        return _widget;
160    }
161
162    /**
163     * Set the widget.
164     * @param widget the widget.
165     */
166    public void setWidget(String widget)
167    {
168        _widget = widget;
169    }
170    
171    /**
172     * Get the widget's parameters
173     * @return the widget's parameters
174     */
175    public Map<String, I18nizableText> getWidgetParameters()
176    {
177        return _widgetParams;
178    }
179    
180    /**
181     * Set the widget's parameters
182     * @param params the parameters to set
183     */
184    public void setWidgetParameters (Map<String, I18nizableText> params)
185    {
186        _widgetParams = params;
187    }
188    
189    /**
190     * Retrieves the enumerator.
191     * @return the enumerator or <code>null</code> if none is defined.
192     */
193    public Enumerator getEnumerator()
194    {
195        return _enumerator;
196    }
197
198    /**
199     * Set the enumerator.
200     * @param enumerator the enumerator.
201     */
202    public void setEnumerator(Enumerator enumerator)
203    {
204        _enumerator = enumerator;
205    }
206
207    /**
208     * Retrieves the validator.
209     * @return the validator or <code>null</code> if none is defined.
210     */
211    public Validator getValidator()
212    {
213        return _validator;
214    }
215
216    /**
217     * Set the validator.
218     * @param validator the validator.
219     */
220    public void setValidator(Validator validator)
221    {
222        _validator = validator;
223    }
224
225    /**
226     * Retrieves the default value.
227     * @return the default value or <code>null</code> if none is defined.
228     */
229    public Object getDefaultValue()
230    {
231        return _defaultValue;
232    }
233
234    /**
235     * Set the default value.
236     * @param defaultValue the default value.
237     */
238    public void setDefaultValue(Object defaultValue)
239    {
240        _defaultValue = defaultValue;
241    }
242}