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