{{ javadocs }}@SuppressWarnings("PMD")
public enum {{ enum_name }} {
{{ variants_block }}
    /** The string value. */
    private final String value;

    {{ enum_name }}(final String value) {
        this.value = value;
    }

    /** Returns the string value. */
    @JsonValue
    public String getValue() {
        return value;
    }

    /** Creates an instance from a string value. */
    @JsonCreator
    public static {{ enum_name }} fromValue(final String value) {
        for ({{ enum_name }} e : values()) {
            if (e.value.equalsIgnoreCase(value)) {
                return e;
            }
        }
{% if has_excluded_variants %}        // This enum has variant(s) excluded from binding (marked with #[cfg_attr(alef, alef(skip))]):
        // Excluded variants that may appear in Rust-serialized JSON: {{ excluded_variant_names | join(", ") }}
{% endif %}        throw new IllegalArgumentException("Unknown {{ enum_name }} value: " + value);
    }

    /** Returns the wire-format string value (matches JSON serialization). */
    @Override
    public String toString() {
        return value;
    }
}
