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