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::administration::user::PrivilegeCode
25  // Metafacade:   org.andromda.metafacades.uml.Enumeration
26  // Stereotype:  Enumeration
27  //
28  package fr.ifremer.quadrige3.core.dao.administration.user;
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 PrivilegeCode
43      implements Serializable, QuadrigeEnumerationDef<String>
44  {
45      REFERENTIAL_ADMINISTRATOR (
46  			"quadrige3.enumeration.PrivilegeCode.REFERENTIAL_ADMINISTRATOR",
47  			n("quadrige3.enumeration.PrivilegeCode.REFERENTIAL_ADMINISTRATOR.description"),
48  			"1"),
49      LOCAL_PREFERENCE_ADMINISTRATOR (
50  			"quadrige3.enumeration.PrivilegeCode.LOCAL_PREFERENCE_ADMINISTRATOR",
51  			n("quadrige3.enumeration.PrivilegeCode.LOCAL_PREFERENCE_ADMINISTRATOR.description"),
52  			"2"),
53      QUALIFIER (
54  			"quadrige3.enumeration.PrivilegeCode.QUALIFIER",
55  			n("quadrige3.enumeration.PrivilegeCode.QUALIFIER.description"),
56  			"3"),
57      VIEWER (
58  			"quadrige3.enumeration.PrivilegeCode.VIEWER",
59  			n("quadrige3.enumeration.PrivilegeCode.VIEWER.description"),
60  			"4"),
61      LOCAL_ADMINISTRATOR (
62  			"quadrige3.enumeration.PrivilegeCode.LOCAL_ADMINISTRATOR",
63  			n("quadrige3.enumeration.PrivilegeCode.LOCAL_ADMINISTRATOR.description"),
64  			"5"),
65      VALIDATOR (
66  			"quadrige3.enumeration.PrivilegeCode.VALIDATOR",
67  			n("quadrige3.enumeration.PrivilegeCode.VALIDATOR.description"),
68  			"6");
69  
70      /**
71       * The serial version UID of this class. Needed for serialization.
72       */
73      private static final long serialVersionUID = 5331190844893834373L;
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 PrivilegeCode(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 PrivilegeCode from <code>its name</code>.
114      *
115      * @param name the name to create the PrivilegeCode from.
116      * @return The enumeration literal named after the 'name' argument
117      */
118     public static PrivilegeCode fromString(String name)
119     {
120         return PrivilegeCode.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 PrivilegeCode from String <code>value</code>.
136      * Required by JAXB2 enumeration implementation
137      *
138      * @param value the value to create the PrivilegeCode from.
139      * @return static Enumeration with corresponding value
140      */
141     public static PrivilegeCode fromValue(String value)
142     {
143         for (PrivilegeCode enumName: PrivilegeCode.values())
144         {
145             if (enumName.getValue().equals(value))
146             {
147                 return enumName;
148             }
149         }
150         throw new IllegalArgumentException("PrivilegeCode.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 PrivilegeCode.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 PrivilegeCode.names;
199     }
200 
201     private static Map<String, PrivilegeCode> values = new LinkedHashMap<String, PrivilegeCode>(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<PrivilegeCode> valueList = new ArrayList<PrivilegeCode>(6);
205 
206     /**
207      * Initializes the values.
208      */
209     static
210     {
211         synchronized (PrivilegeCode.values)
212         {
213             PrivilegeCode.values.put(REFERENTIAL_ADMINISTRATOR.enumValue, REFERENTIAL_ADMINISTRATOR);
214             PrivilegeCode.values.put(LOCAL_PREFERENCE_ADMINISTRATOR.enumValue, LOCAL_PREFERENCE_ADMINISTRATOR);
215             PrivilegeCode.values.put(QUALIFIER.enumValue, QUALIFIER);
216             PrivilegeCode.values.put(VIEWER.enumValue, VIEWER);
217             PrivilegeCode.values.put(LOCAL_ADMINISTRATOR.enumValue, LOCAL_ADMINISTRATOR);
218             PrivilegeCode.values.put(VALIDATOR.enumValue, VALIDATOR);
219         }
220         synchronized (PrivilegeCode.valueList)
221         {
222             PrivilegeCode.valueList.add(REFERENTIAL_ADMINISTRATOR);
223             PrivilegeCode.valueList.add(LOCAL_PREFERENCE_ADMINISTRATOR);
224             PrivilegeCode.valueList.add(QUALIFIER);
225             PrivilegeCode.valueList.add(VIEWER);
226             PrivilegeCode.valueList.add(LOCAL_ADMINISTRATOR);
227             PrivilegeCode.valueList.add(VALIDATOR);
228             // For Quadrige3, lists could be reload from configuration (see method 'setValue')
229             //PrivilegeCode.valueList = Collections.unmodifiableList(valueList);
230         }
231         synchronized (PrivilegeCode.literals)
232         {
233             PrivilegeCode.literals.add(REFERENTIAL_ADMINISTRATOR.enumValue);
234             PrivilegeCode.literals.add(LOCAL_PREFERENCE_ADMINISTRATOR.enumValue);
235             PrivilegeCode.literals.add(QUALIFIER.enumValue);
236             PrivilegeCode.literals.add(VIEWER.enumValue);
237             PrivilegeCode.literals.add(LOCAL_ADMINISTRATOR.enumValue);
238             PrivilegeCode.literals.add(VALIDATOR.enumValue);
239             // For Quadrige3, lists could be reload from configuration (see method 'setValue')
240             //PrivilegeCode.literals = Collections.unmodifiableList(literals);
241         }
242         synchronized (PrivilegeCode.names)
243         {
244             PrivilegeCode.names.add("REFERENTIAL_ADMINISTRATOR");
245             PrivilegeCode.names.add("LOCAL_PREFERENCE_ADMINISTRATOR");
246             PrivilegeCode.names.add("QUALIFIER");
247             PrivilegeCode.names.add("VIEWER");
248             PrivilegeCode.names.add("LOCAL_ADMINISTRATOR");
249             PrivilegeCode.names.add("VALIDATOR");
250             PrivilegeCode.names = Collections.unmodifiableList(names);
251         }
252     }
253     // type-safe-enumeration-object java merge-point
254 }