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