001/*
002 * #%L
003 * SIH-Adagio
004 * $Id: javaMergeMappings.xml 12002 2014-03-26 10:17:22Z bl05b3e $
005 * $HeadURL: https://forge.ifremer.fr/svn/sih-adagio/tags/adagio-3.5.6/mda/src/main/config/javaMergeMappings.xml $
006 * %%
007 * Copyright (C) 2012 - 2013 Ifremer
008 * %%
009 * This program is free software: you can redistribute it and/or modify
010 * it under the terms of the GNU Affero General Public License as published by
011 * the Free Software Foundation, either version 3 of the License, or
012 * (at your option) any later version.
013 * 
014 * This program is distributed in the hope that it will be useful,
015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017 * GNU General Public License for more details.
018 * 
019 * You should have received a copy of the GNU Affero General Public License
020 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
021 * #L%
022 */
023//
024// Attention: Generated code! Do not modify by hand!
025// Generated by: TypeSafeEnumeration.vsl in andromda-java-cartridge.
026// Model Class:  Data::fr.ifremer.adagio.core.dao::referential::pmfm::FractionId
027// Metafacade:   org.andromda.metafacades.uml.Enumeration
028// Stereotype:  Enumeration
029//
030package fr.ifremer.adagio.core.dao.referential.pmfm;
031
032import fr.ifremer.adagio.core.dao.technical.AdagioEnumerationDef;
033import java.io.Serializable;
034import java.util.ArrayList;
035import java.util.Collections;
036import java.util.LinkedHashMap;
037import java.util.List;
038import java.util.Map;
039import static org.nuiton.i18n.I18n.n;
040
041/**
042 * 
043 */
044public enum FractionId
045    implements Serializable, AdagioEnumerationDef<Integer>
046{
047    /** TODO: Model Documentation for Enumeration Literal ALL value 1 */
048    ALL (
049            "adagio.enumeration.FractionId.ALL", 
050            n("adagio.enumeration.FractionId.ALL.description"), 
051            1),
052    /** TODO: Model Documentation for Enumeration Literal GEAR value 2 */
053    GEAR (
054            "adagio.enumeration.FractionId.GEAR", 
055            n("adagio.enumeration.FractionId.GEAR.description"), 
056            2);
057
058    /**
059     * The serial version UID of this class. Needed for serialization.
060     */
061    private static final long serialVersionUID = 9014368696487419155L;
062
063    private String key;
064    private String description;
065    private Integer enumValue;
066
067    private FractionId(String key, String description, Integer value)
068    {
069        this.key = key;
070        this.description = description;
071        this.enumValue = value;
072    }
073    
074    @Override
075    public void setValue(Integer newValue) {
076        if (newValue != null && !this.enumValue.equals(newValue)) {
077            // Update static lists
078            values.remove(this.enumValue);
079            literals.remove(this.enumValue);
080            this.enumValue = newValue;
081            values.put(this.enumValue, this);
082            literals.add(this.enumValue);
083        }
084    }
085    
086
087    @Override
088    public String getValueAsString()
089    {
090        return String.valueOf(this.enumValue);
091    }
092
093    /**
094     * Retrieves an instance of FractionId from <code>its name</code>.
095     *
096     * @param name the name to create the FractionId from.
097     * @return The enumeration literal named after the 'name' argument
098     */
099    public static FractionId fromString(String name)
100    {
101        return FractionId.valueOf(name);
102    }
103
104    /**
105     * Returns an enumeration literal Integer <code>value</code>.
106     * Required by JAXB2 enumeration implementation
107     *
108     * @return Integer with corresponding value
109     */
110    public Integer value()
111    {
112        return this.enumValue;
113    }
114
115    /**
116     * Returns an instance of FractionId from Integer <code>value</code>.
117     * Required by JAXB2 enumeration implementation
118     *
119     * @param value the value to create the FractionId from.
120     * @return static Enumeration with corresponding value
121     */
122    public static FractionId fromValue(Integer value)
123    {
124        for (FractionId enumName: FractionId.values())
125        {
126            if (enumName.getValue().equals(value))
127            {
128                return enumName;
129            }
130        }
131        throw new IllegalArgumentException("FractionId.fromValue(" + value.toString() + ')');
132    }
133
134    /**
135     * Gets the underlying value of this type safe enumeration.
136     * This method is necessary to comply with DaoBase implementation.
137     * @return The name of this literal.
138     */
139    public Integer getValue()
140    {
141        return this.enumValue;
142    }
143    
144    @Override
145    public String getDescription() {
146        return description;
147    }
148    
149    @Override
150    public String getKey() {
151        return key;
152    }
153    
154    @Override
155    public Class<?> getType() {
156        return Integer.class;
157    }
158    
159    /**
160     * Returns an unmodifiable list containing the literals that are known by this enumeration.
161     *
162     * @return A List containing the actual literals defined by this enumeration, this list
163     *         can not be modified.
164     */
165    public static List<Integer> literals()
166    {
167        return FractionId.literals;
168    }
169
170    /**
171     * Returns an unmodifiable list containing the names of the literals that are known
172     * by this enumeration.
173     *
174     * @return A List containing the actual names of the literals defined by this
175     *         enumeration, this list can not be modified.
176     */
177    public static List<String> names()
178    {
179        return FractionId.names;
180    }
181
182    private static Map<Integer, FractionId> values = new LinkedHashMap<Integer, FractionId>(2, 1);
183    private static List<Integer> literals = new ArrayList<Integer>(2);
184    private static List<String> names = new ArrayList<String>(2);
185    private static List<FractionId> valueList = new ArrayList<FractionId>(2);
186
187    /**
188     * Initializes the values.
189     */
190    static
191    {
192        synchronized (FractionId.values)
193        {
194            FractionId.values.put(ALL.enumValue, ALL);
195            FractionId.values.put(GEAR.enumValue, GEAR);
196        }
197        synchronized (FractionId.valueList)
198        {
199            FractionId.valueList.add(ALL);
200            FractionId.valueList.add(GEAR);
201            // For Adagio, lists could be reload from configuration
202            //FractionId.valueList = Collections.unmodifiableList(valueList);
203        }
204        synchronized (FractionId.literals)
205        {
206            FractionId.literals.add(ALL.enumValue);
207            FractionId.literals.add(GEAR.enumValue);
208            // For Adagio, lists could be reload from configuration
209            //FractionId.literals = Collections.unmodifiableList(literals);
210        }
211        synchronized (FractionId.names)
212        {
213            FractionId.names.add("ALL");
214            FractionId.names.add("GEAR");
215            FractionId.names = Collections.unmodifiableList(names);
216        }
217    }
218    // type-safe-enumeration-object java merge-point
219}