Role.java

// license-header java merge-point
//
/**
 * @author Generated by TypeSafeEnumeration.vsl in andromda-java-cartridge on 09/18/2014 12:09:11-0400 Do not modify by hand!
 *
 * TEMPLATE:     TypeSafeEnumeration.vsl in andromda-java-cartridge.
 * MODEL CLASS:  Timetracker EJB3 ::TimeTracker::org.andromda.timetracker::domain::Role
 * STEREOTYPE:   Enumeration
 */
//
package org.andromda.timetracker.domain;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * TODO: Model Documentation for org.andromda.timetracker.domain.Role
 * </p>
 */
public enum Role
{
    /** TODO: Model Documentation for Enumeration Literal USER value "User" */
    USER("User"),
    /** TODO: Model Documentation for Enumeration Literal ADMIN value "Admin" */
    ADMIN("Admin");

    /**
     * The serial version UID of this class. Needed for serialization.
     */
    private static final long serialVersionUID = 4272521091931210674L;

    private final String enumValue;

    /**
     * The constructor with enumeration literal value allowing
     * super classes to access it.
     */
    private Role(String value)
    {
        this.enumValue = value;
    }

    /*
     * Do not override this method directly. Use an alternate name
     * if providing a different toString implementation
     * @see Object#toString()
    @Override
    public String toString()
    {
        return String.valueOf(this.enumValue);
    }
     */

    /**
     * Retrieves an instance of Role from <code>its name</code>.
     *
     * @param name the name to create the Role from.
     * @return The enumeration literal named after the 'name' argument
     */
    public static Role fromString(String name)
    {
        return Role.valueOf(name);
    }

    /**
     * Returns an enumeration literal String <code>value</code>.
     * Required by JAXB2 enumeration implementation
     *
     * @return String with corresponding value
     */
    public String value()
    {
        return this.enumValue;
    }

    /**
     * Returns an instance of Role from String <code>value</code>.
     * Required by JAXB2 enumeration implementation
     *
     * @param value the value to create the Role from.
     * @return static Enumeration with corresponding value
     */
    public static Role fromValue(String value)
    {
        // Allow either the Enum name or value string to be used to retrieve the enum
        for (Role enumName: Role.values())
        {
            if (enumName.getValue().equals(value))
            {
                return enumName;
            }
        }
        for (String enumName: Role.names())
        {
            if (enumName.equals(value))
            {
                return Role.valueOf(enumName);
            }
        }
        throw new IllegalArgumentException("Role.fromValue(" + value + ')');
    }

    /**
     * Gets the underlying value of this type safe enumeration.
     * This method is necessary to comply with DaoBase implementation.
     * @return The name of this literal.
     */
    public String getValue()
    {
        return this.enumValue;
    }

    /**
     * Returns an unmodifiable list containing the literals that are known by this enumeration.
     *
     * @return A List containing the actual literals defined by this enumeration, this list
     *         can not be modified.
     */
    public static List<String> literals()
    {
        return Role.literals;
    }

    /**
     * Returns an unmodifiable list containing the names of the literals that are known
     * by this enumeration.
     *
     * @return A List containing the actual names of the literals defined by this
     *         enumeration, this list can not be modified.
     */
    public static List<String> names()
    {
        return Role.names;
    }

    private static Map<String, Role> values = new LinkedHashMap<String, Role>(2, 1);
    private static List<String> literals = new ArrayList<String>(2);
    private static List<String> names = new ArrayList<String>(2);
    private static List<Role> valueList = new ArrayList<Role>(2);

    /**
     * Initializes the values.
     */
    static
    {
        synchronized (Role.values)
        {
            Role.values.put(USER.enumValue, USER);
            Role.values.put(ADMIN.enumValue, ADMIN);
        }
        synchronized (Role.valueList)
        {
            Role.valueList.add(USER);
            Role.valueList.add(ADMIN);
            Role.valueList = Collections.unmodifiableList(valueList);
        }
        synchronized (Role.literals)
        {
            Role.literals.add(USER.enumValue);
            Role.literals.add(ADMIN.enumValue);
            Role.literals = Collections.unmodifiableList(literals);
        }
        synchronized (Role.names)
        {
            Role.names.add("USER");
            Role.names.add("ADMIN");
            Role.names = Collections.unmodifiableList(names);
        }
    }
    // type-safe-enumeration-object java merge-point
}