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::FunctionId
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 FunctionId
43      implements Serializable, QuadrigeEnumerationDef<Integer>
44  {
45      MIN_MAX (
46  			"quadrige3.enumeration.FunctionId.MIN_MAX",
47  			n("quadrige3.enumeration.FunctionId.MIN_MAX.description"),
48  			1),
49      IN (
50  			"quadrige3.enumeration.FunctionId.IN",
51  			n("quadrige3.enumeration.FunctionId.IN.description"),
52  			2),
53      EMPTY (
54  			"quadrige3.enumeration.FunctionId.EMPTY",
55  			n("quadrige3.enumeration.FunctionId.EMPTY.description"),
56  			3),
57      NOT_EMPTY (
58  			"quadrige3.enumeration.FunctionId.NOT_EMPTY",
59  			n("quadrige3.enumeration.FunctionId.NOT_EMPTY.description"),
60  			4),
61      MIN_MAX_DATE (
62  			"quadrige3.enumeration.FunctionId.MIN_MAX_DATE",
63  			n("quadrige3.enumeration.FunctionId.MIN_MAX_DATE.description"),
64  			5),
65      ERROR (
66  			"quadrige3.enumeration.FunctionId.ERROR",
67  			n("quadrige3.enumeration.FunctionId.ERROR.description"),
68  			6),
69      PRECONDITION_QUALITATIVE (
70  			"quadrige3.enumeration.FunctionId.PRECONDITION_QUALITATIVE",
71  			n("quadrige3.enumeration.FunctionId.PRECONDITION_QUALITATIVE.description"),
72  			-1),
73      PRECONDITION_NUMERICAL (
74  			"quadrige3.enumeration.FunctionId.PRECONDITION_NUMERICAL",
75  			n("quadrige3.enumeration.FunctionId.PRECONDITION_NUMERICAL.description"),
76  			-2),
77      NOT_EMPTY_CONDITIONAL (
78  			"quadrige3.enumeration.FunctionId.NOT_EMPTY_CONDITIONAL",
79  			n("quadrige3.enumeration.FunctionId.NOT_EMPTY_CONDITIONAL.description"),
80  			-3);
81  
82      /**
83       * The serial version UID of this class. Needed for serialization.
84       */
85      private static final long serialVersionUID = 1413969215516048969L;
86  
87      private String key;
88      private String description;
89      private Integer enumValue;
90  
91      /**
92       * The constructor with enumeration literal value allowing
93       * super classes to access it.
94       */
95      private FunctionId(String key, String description, Integer value)
96      {
97      	this.key = key;
98      	this.description = description;
99          this.enumValue = value;
100     }
101     
102     @Override
103      /**
104       * Setter for value. Use to override value, from configuration
105       */
106      public void setValue(Integer newValue) {
107 		if (newValue != null && !this.enumValue.equals(newValue)) {
108 			// Update static lists
109 	    	values.remove(this.enumValue);
110 	    	literals.remove(this.enumValue);
111 	    	this.enumValue = newValue;
112 	    	values.put(this.enumValue, this);
113 	    	literals.add(this.enumValue);
114 		}
115     }
116     
117 
118     @Override
119     public String getValueAsString()
120     {
121         return String.valueOf(this.enumValue);
122     }
123 
124     /**
125      * Retrieves an instance of FunctionId from <code>its name</code>.
126      *
127      * @param name the name to create the FunctionId from.
128      * @return The enumeration literal named after the 'name' argument
129      */
130     public static FunctionId fromString(String name)
131     {
132         return FunctionId.valueOf(name);
133     }
134 
135     /**
136      * Returns an enumeration literal Integer <code>value</code>.
137      * Required by JAXB2 enumeration implementation
138      *
139      * @return Integer with corresponding value
140      */
141     public Integer value()
142     {
143         return this.enumValue;
144     }
145 
146     /**
147      * Returns an instance of FunctionId from Integer <code>value</code>.
148      * Required by JAXB2 enumeration implementation
149      *
150      * @param value the value to create the FunctionId from.
151      * @return static Enumeration with corresponding value
152      */
153     public static FunctionId fromValue(Integer value)
154     {
155         for (FunctionId enumName: FunctionId.values())
156         {
157             if (enumName.getValue().equals(value))
158             {
159                 return enumName;
160             }
161         }
162         throw new IllegalArgumentException("FunctionId.fromValue(" + value.toString() + ')');
163     }
164 
165     /**
166      * Gets the underlying value of this type safe enumeration.
167      * This method is necessary to comply with DaoBase implementation.
168      * @return The name of this literal.
169      */
170     public Integer getValue()
171     {
172         return this.enumValue;
173     }
174     
175     @Override
176     public String getDescription() {
177     	return description;
178     }
179     
180     @Override
181     public String getKey() {
182     	return key;
183     }
184     
185     @Override
186     public Class<?> getType() {
187     	return Integer.class;
188     }
189     
190     /**
191      * Returns an unmodifiable list containing the literals that are known by this enumeration.
192      *
193      * @return A List containing the actual literals defined by this enumeration, this list
194      *         can not be modified.
195      */
196     public static List<Integer> literals()
197     {
198         return FunctionId.literals;
199     }
200 
201     /**
202      * Returns an unmodifiable list containing the names of the literals that are known
203      * by this enumeration.
204      *
205      * @return A List containing the actual names of the literals defined by this
206      *         enumeration, this list can not be modified.
207      */
208     public static List<String> names()
209     {
210         return FunctionId.names;
211     }
212 
213     private static Map<Integer, FunctionId> values = new LinkedHashMap<Integer, FunctionId>(9, 1);
214     private static List<Integer> literals = new ArrayList<Integer>(9);
215     private static List<String> names = new ArrayList<String>(9);
216     private static List<FunctionId> valueList = new ArrayList<FunctionId>(9);
217 
218     /**
219      * Initializes the values.
220      */
221     static
222     {
223         synchronized (FunctionId.values)
224         {
225             FunctionId.values.put(MIN_MAX.enumValue, MIN_MAX);
226             FunctionId.values.put(IN.enumValue, IN);
227             FunctionId.values.put(EMPTY.enumValue, EMPTY);
228             FunctionId.values.put(NOT_EMPTY.enumValue, NOT_EMPTY);
229             FunctionId.values.put(MIN_MAX_DATE.enumValue, MIN_MAX_DATE);
230             FunctionId.values.put(ERROR.enumValue, ERROR);
231             FunctionId.values.put(PRECONDITION_QUALITATIVE.enumValue, PRECONDITION_QUALITATIVE);
232             FunctionId.values.put(PRECONDITION_NUMERICAL.enumValue, PRECONDITION_NUMERICAL);
233             FunctionId.values.put(NOT_EMPTY_CONDITIONAL.enumValue, NOT_EMPTY_CONDITIONAL);
234         }
235         synchronized (FunctionId.valueList)
236         {
237             FunctionId.valueList.add(MIN_MAX);
238             FunctionId.valueList.add(IN);
239             FunctionId.valueList.add(EMPTY);
240             FunctionId.valueList.add(NOT_EMPTY);
241             FunctionId.valueList.add(MIN_MAX_DATE);
242             FunctionId.valueList.add(ERROR);
243             FunctionId.valueList.add(PRECONDITION_QUALITATIVE);
244             FunctionId.valueList.add(PRECONDITION_NUMERICAL);
245             FunctionId.valueList.add(NOT_EMPTY_CONDITIONAL);
246             // For Quadrige3, lists could be reload from configuration (see method 'setValue')
247             //FunctionId.valueList = Collections.unmodifiableList(valueList);
248         }
249         synchronized (FunctionId.literals)
250         {
251             FunctionId.literals.add(MIN_MAX.enumValue);
252             FunctionId.literals.add(IN.enumValue);
253             FunctionId.literals.add(EMPTY.enumValue);
254             FunctionId.literals.add(NOT_EMPTY.enumValue);
255             FunctionId.literals.add(MIN_MAX_DATE.enumValue);
256             FunctionId.literals.add(ERROR.enumValue);
257             FunctionId.literals.add(PRECONDITION_QUALITATIVE.enumValue);
258             FunctionId.literals.add(PRECONDITION_NUMERICAL.enumValue);
259             FunctionId.literals.add(NOT_EMPTY_CONDITIONAL.enumValue);
260             // For Quadrige3, lists could be reload from configuration (see method 'setValue')
261             //FunctionId.literals = Collections.unmodifiableList(literals);
262         }
263         synchronized (FunctionId.names)
264         {
265             FunctionId.names.add("MIN_MAX");
266             FunctionId.names.add("IN");
267             FunctionId.names.add("EMPTY");
268             FunctionId.names.add("NOT_EMPTY");
269             FunctionId.names.add("MIN_MAX_DATE");
270             FunctionId.names.add("ERROR");
271             FunctionId.names.add("PRECONDITION_QUALITATIVE");
272             FunctionId.names.add("PRECONDITION_NUMERICAL");
273             FunctionId.names.add("NOT_EMPTY_CONDITIONAL");
274             FunctionId.names = Collections.unmodifiableList(names);
275         }
276     }
277     // type-safe-enumeration-object java merge-point
278 }