All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.common.enum-class.ftl Maven / Gradle / Ivy

Go to download

The AWS SDK for Java - Code Generator module holds the classes and templates required to generate the AWS Java SDK clients for AWS services.

There is a newer version: 1.11.8
Show newest version
${fileHeader}
package ${metadata.packageName}.model;

/**
 * <#if shape.documentation?has_content>${shape.documentation}
 */
<#if shape.deprecated>
@Deprecated

public enum ${shape.shapeName} {

<#assign enums = shape.enums/>

<#list enums as enum>
    ${enum.name}("${enum.value}")<#if enum_has_next>,<#else>;


    private String value;

    private ${shape.shapeName}(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return this.value;
    }

    /**
     * Use this in place of valueOf.
     *
     * @param value
     *            real value
     * @return ${shape.shapeName} corresponding to the value
     */
    public static ${shape.shapeName} fromValue(String value) {
        if (value == null || "".equals(value)) {
            throw new IllegalArgumentException("Value cannot be null or empty!");
        }

        for (${shape.shapeName} enumEntry : ${shape.shapeName}.values()) {
            if (enumEntry.toString().equals(value)) {
                return enumEntry;
            }
        }

        throw new IllegalArgumentException("Cannot create enum from " + value + " value!");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy