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