View Javadoc
1   /*
2     * #%L
3     * Quadrige3 Core
4     * %%
5     * Copyright (C) 2017 Ifremer
6     * %%
7     * This program is free software: you can redistribute it and/or modify
8     * it under the terms of the GNU Affero General Public License as published by
9     * the Free Software Foundation, either version 3 of the License, or
10    * (at your option) any later version.
11    *
12    * This program is distributed in the hope that it will be useful,
13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    * GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU Affero General Public License
18    * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19    * #L%
20    */
21  //
22  // Attention: Generated code! Do not modify by hand!
23  // Generated by: TypeSafeEnumeration.vsl in andromda-java-cartridge.
24  // Model Class:  Données::fr.ifremer.quadrige3.core::dao::system::rule::FunctionParameterId
25  // Metafacade:   org.andromda.metafacades.uml.Enumeration
26  // Stereotype:  Enumeration
27  //
28  package fr.ifremer.quadrige3.core.dao.system.rule;
29  
30  import fr.ifremer.quadrige3.core.dao.technical.QuadrigeEnumerationDef;
31  import java.io.Serializable;
32  import java.util.ArrayList;
33  import java.util.Collections;
34  import java.util.LinkedHashMap;
35  import java.util.List;
36  import java.util.Map;
37  import static org.nuiton.i18n.I18n.n;
38  
39  /**
40   * 
41   */
42  public enum FunctionParameterId
43      implements Serializable, QuadrigeEnumerationDef<Integer>
44  {
45      MIN (
46  			"quadrige3.enumeration.FunctionParameterId.MIN",
47  			n("quadrige3.enumeration.FunctionParameterId.MIN.description"),
48  			1),
49      MAX (
50  			"quadrige3.enumeration.FunctionParameterId.MAX",
51  			n("quadrige3.enumeration.FunctionParameterId.MAX.description"),
52  			2),
53      IN (
54  			"quadrige3.enumeration.FunctionParameterId.IN",
55  			n("quadrige3.enumeration.FunctionParameterId.IN.description"),
56  			3),
57      DATE_MIN (
58  			"quadrige3.enumeration.FunctionParameterId.DATE_MIN",
59  			n("quadrige3.enumeration.FunctionParameterId.DATE_MIN.description"),
60  			4),
61      DATE_MAX (
62  			"quadrige3.enumeration.FunctionParameterId.DATE_MAX",
63  			n("quadrige3.enumeration.FunctionParameterId.DATE_MAX.description"),
64  			5);
65  
66      /**
67       * The serial version UID of this class. Needed for serialization.
68       */
69      private static final long serialVersionUID = 3382356357711892354L;
70  
71      private String key;
72      private String description;
73      private Integer enumValue;
74  
75      /**
76       * The constructor with enumeration literal value allowing
77       * super classes to access it.
78       */
79      private FunctionParameterId(String key, String description, Integer value)
80      {
81      	this.key = key;
82      	this.description = description;
83          this.enumValue = value;
84      }
85      
86      @Override
87       /**
88        * Setter for value. Use to override value, from configuration
89        */
90       public void setValue(Integer newValue) {
91  		if (newValue != null && !this.enumValue.equals(newValue)) {
92  			// Update static lists
93  	    	values.remove(this.enumValue);
94  	    	literals.remove(this.enumValue);
95  	    	this.enumValue = newValue;
96  	    	values.put(this.enumValue, this);
97  	    	literals.add(this.enumValue);
98  		}
99      }
100     
101 
102     @Override
103     public String getValueAsString()
104     {
105         return String.valueOf(this.enumValue);
106     }
107 
108     /**
109      * Retrieves an instance of FunctionParameterId from <code>its name</code>.
110      *
111      * @param name the name to create the FunctionParameterId from.
112      * @return The enumeration literal named after the 'name' argument
113      */
114     public static FunctionParameterId fromString(String name)
115     {
116         return FunctionParameterId.valueOf(name);
117     }
118 
119     /**
120      * Returns an enumeration literal Integer <code>value</code>.
121      * Required by JAXB2 enumeration implementation
122      *
123      * @return Integer with corresponding value
124      */
125     public Integer value()
126     {
127         return this.enumValue;
128     }
129 
130     /**
131      * Returns an instance of FunctionParameterId from Integer <code>value</code>.
132      * Required by JAXB2 enumeration implementation
133      *
134      * @param value the value to create the FunctionParameterId from.
135      * @return static Enumeration with corresponding value
136      */
137     public static FunctionParameterId fromValue(Integer value)
138     {
139         for (FunctionParameterId enumName: FunctionParameterId.values())
140         {
141             if (enumName.getValue().equals(value))
142             {
143                 return enumName;
144             }
145         }
146         throw new IllegalArgumentException("FunctionParameterId.fromValue(" + value.toString() + ')');
147     }
148 
149     /**
150      * Gets the underlying value of this type safe enumeration.
151      * This method is necessary to comply with DaoBase implementation.
152      * @return The name of this literal.
153      */
154     public Integer getValue()
155     {
156         return this.enumValue;
157     }
158     
159     @Override
160     public String getDescription() {
161     	return description;
162     }
163     
164     @Override
165     public String getKey() {
166     	return key;
167     }
168     
169     @Override
170     public Class<?> getType() {
171     	return Integer.class;
172     }
173     
174     /**
175      * Returns an unmodifiable list containing the literals that are known by this enumeration.
176      *
177      * @return A List containing the actual literals defined by this enumeration, this list
178      *         can not be modified.
179      */
180     public static List<Integer> literals()
181     {
182         return FunctionParameterId.literals;
183     }
184 
185     /**
186      * Returns an unmodifiable list containing the names of the literals that are known
187      * by this enumeration.
188      *
189      * @return A List containing the actual names of the literals defined by this
190      *         enumeration, this list can not be modified.
191      */
192     public static List<String> names()
193     {
194         return FunctionParameterId.names;
195     }
196 
197     private static Map<Integer, FunctionParameterId> values = new LinkedHashMap<Integer, FunctionParameterId>(5, 1);
198     private static List<Integer> literals = new ArrayList<Integer>(5);
199     private static List<String> names = new ArrayList<String>(5);
200     private static List<FunctionParameterId> valueList = new ArrayList<FunctionParameterId>(5);
201 
202     /**
203      * Initializes the values.
204      */
205     static
206     {
207         synchronized (FunctionParameterId.values)
208         {
209             FunctionParameterId.values.put(MIN.enumValue, MIN);
210             FunctionParameterId.values.put(MAX.enumValue, MAX);
211             FunctionParameterId.values.put(IN.enumValue, IN);
212             FunctionParameterId.values.put(DATE_MIN.enumValue, DATE_MIN);
213             FunctionParameterId.values.put(DATE_MAX.enumValue, DATE_MAX);
214         }
215         synchronized (FunctionParameterId.valueList)
216         {
217             FunctionParameterId.valueList.add(MIN);
218             FunctionParameterId.valueList.add(MAX);
219             FunctionParameterId.valueList.add(IN);
220             FunctionParameterId.valueList.add(DATE_MIN);
221             FunctionParameterId.valueList.add(DATE_MAX);
222             // For Quadrige3, lists could be reload from configuration (see method 'setValue')
223             //FunctionParameterId.valueList = Collections.unmodifiableList(valueList);
224         }
225         synchronized (FunctionParameterId.literals)
226         {
227             FunctionParameterId.literals.add(MIN.enumValue);
228             FunctionParameterId.literals.add(MAX.enumValue);
229             FunctionParameterId.literals.add(IN.enumValue);
230             FunctionParameterId.literals.add(DATE_MIN.enumValue);
231             FunctionParameterId.literals.add(DATE_MAX.enumValue);
232             // For Quadrige3, lists could be reload from configuration (see method 'setValue')
233             //FunctionParameterId.literals = Collections.unmodifiableList(literals);
234         }
235         synchronized (FunctionParameterId.names)
236         {
237             FunctionParameterId.names.add("MIN");
238             FunctionParameterId.names.add("MAX");
239             FunctionParameterId.names.add("IN");
240             FunctionParameterId.names.add("DATE_MIN");
241             FunctionParameterId.names.add("DATE_MAX");
242             FunctionParameterId.names = Collections.unmodifiableList(names);
243         }
244     }
245     // type-safe-enumeration-object java merge-point
246 }