// Auto-generated by BoltFFI. Do not edit.
package {{ package_name }};

{{ self::javadoc_block(enumeration.doc, "") }}public enum {{ enumeration.class_name }} {
{%- for variant in enumeration.variants %}
{{ self::javadoc_block(variant.doc, "    ") }}    {{ variant.name }}({{ enumeration.tag_literal(variant.tag) }}){% if !loop.last %},{% else %};{% endif %}
{%- endfor %}

    public final {{ enumeration.value_type }} value;

    private static final {{ enumeration.class_name }}[] VALUES = values();

    {{ enumeration.class_name }}({{ enumeration.value_type }} value) {
        this.value = value;
    }

    public static {{ enumeration.class_name }} fromValue({{ enumeration.value_type }} value) {
        for ({{ enumeration.class_name }} v : VALUES) {
            if (v.value == value) return v;
        }
        throw new IllegalArgumentException("Unknown {{ enumeration.class_name }} value: " + value);
    }

    static {{ enumeration.class_name }} fromTag(int tag) {
        if (tag < 0 || tag >= VALUES.length) {
            throw new IllegalArgumentException("Unknown {{ enumeration.class_name }} wire tag: " + tag);
        }
        return VALUES[tag];
    }

    int wireTag() {
        return ordinal();
    }

    {{ enumeration.value_type }} nativeValue() {
        return value;
    }

{%- for ctor in enumeration.constructors %}
{% include "render_java/value_type_constructor.txt" %}
{%- endfor %}

{%- for method in enumeration.methods %}
{% include "render_java/value_type_method.txt" %}
{%- endfor %}
}
