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::QualityFlagCode
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 QualityFlagCode
43      implements Serializable, QuadrigeEnumerationDef<String>
44  {
45      NOT_QUALIFIED (
46  			"quadrige3.enumeration.QualityFlagCode.NOT_QUALIFIED",
47  			n("quadrige3.enumeration.QualityFlagCode.NOT_QUALIFIED.description"),
48  			"0"),
49      GOOD (
50  			"quadrige3.enumeration.QualityFlagCode.GOOD",
51  			n("quadrige3.enumeration.QualityFlagCode.GOOD.description"),
52  			"1"),
53      DOUBTFUL (
54  			"quadrige3.enumeration.QualityFlagCode.DOUBTFUL",
55  			n("quadrige3.enumeration.QualityFlagCode.DOUBTFUL.description"),
56  			"3"),
57      BAD (
58  			"quadrige3.enumeration.QualityFlagCode.BAD",
59  			n("quadrige3.enumeration.QualityFlagCode.BAD.description"),
60  			"4");
61  
62      /**
63       * The serial version UID of this class. Needed for serialization.
64       */
65      private static final long serialVersionUID = -9083805314634950024L;
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 QualityFlagCode(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 QualityFlagCode from <code>its name</code>.
106      *
107      * @param name the name to create the QualityFlagCode from.
108      * @return The enumeration literal named after the 'name' argument
109      */
110     public static QualityFlagCode fromString(String name)
111     {
112         return QualityFlagCode.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 QualityFlagCode from String <code>value</code>.
128      * Required by JAXB2 enumeration implementation
129      *
130      * @param value the value to create the QualityFlagCode from.
131      * @return static Enumeration with corresponding value
132      */
133     public static QualityFlagCode fromValue(String value)
134     {
135         for (QualityFlagCode enumName: QualityFlagCode.values())
136         {
137             if (enumName.getValue().equals(value))
138             {
139                 return enumName;
140             }
141         }
142         throw new IllegalArgumentException("QualityFlagCode.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 QualityFlagCode.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 QualityFlagCode.names;
191     }
192 
193     private static Map<String, QualityFlagCode> values = new LinkedHashMap<String, QualityFlagCode>(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<QualityFlagCode> valueList = new ArrayList<QualityFlagCode>(4);
197 
198     /**
199      * Initializes the values.
200      */
201     static
202     {
203         synchronized (QualityFlagCode.values)
204         {
205             QualityFlagCode.values.put(NOT_QUALIFIED.enumValue, NOT_QUALIFIED);
206             QualityFlagCode.values.put(GOOD.enumValue, GOOD);
207             QualityFlagCode.values.put(DOUBTFUL.enumValue, DOUBTFUL);
208             QualityFlagCode.values.put(BAD.enumValue, BAD);
209         }
210         synchronized (QualityFlagCode.valueList)
211         {
212             QualityFlagCode.valueList.add(NOT_QUALIFIED);
213             QualityFlagCode.valueList.add(GOOD);
214             QualityFlagCode.valueList.add(DOUBTFUL);
215             QualityFlagCode.valueList.add(BAD);
216             // For Quadrige3, lists could be reload from configuration (see method 'setValue')
217             //QualityFlagCode.valueList = Collections.unmodifiableList(valueList);
218         }
219         synchronized (QualityFlagCode.literals)
220         {
221             QualityFlagCode.literals.add(NOT_QUALIFIED.enumValue);
222             QualityFlagCode.literals.add(GOOD.enumValue);
223             QualityFlagCode.literals.add(DOUBTFUL.enumValue);
224             QualityFlagCode.literals.add(BAD.enumValue);
225             // For Quadrige3, lists could be reload from configuration (see method 'setValue')
226             //QualityFlagCode.literals = Collections.unmodifiableList(literals);
227         }
228         synchronized (QualityFlagCode.names)
229         {
230             QualityFlagCode.names.add("NOT_QUALIFIED");
231             QualityFlagCode.names.add("GOOD");
232             QualityFlagCode.names.add("DOUBTFUL");
233             QualityFlagCode.names.add("BAD");
234             QualityFlagCode.names = Collections.unmodifiableList(names);
235         }
236     }
237     // type-safe-enumeration-object java merge-point
238 }