{{! Copyright (c) Meta Platforms, Inc. and affiliates. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. }} {{> AutoGenerated}} package {{enum:javaPackage}}; import com.facebook.swift.codec.*; import org.apache.thrift.TException; import org.apache.thrift.protocol.TProtocol; @SwiftGenerated public {{#enum:skipEnumNameMap?}}class{{/enum:skipEnumNameMap?}}{{^enum:skipEnumNameMap?}}enum{{/enum:skipEnumNameMap?}} {{enum:javaCapitalName}}{{#enum:skipEnumNameMap?}} extends IntEnum{{/enum:skipEnumNameMap?}} implements com.facebook.thrift.enums.BaseEnum, com.facebook.thrift.payload.ThriftSerializable { {{^enum:skipEnumNameMap?}} {{#enum:values}} {{enum_value:javaConstantName}}({{enum_value:value}}){{^last?}},{{/last?}}{{#last?}};{{/last?}} {{/enum:values}} {{! semicolon here is required for Java Enum definition, see Java Language Spec section 8.9.1 https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.9.1}} {{^enum:values}} ; {{/enum:values}} {{/enum:skipEnumNameMap?}} private final int value; {{enum:javaCapitalName}}(int value) { this.value = value; } {{#enum:skipEnumNameMap?}} @java.lang.Override {{/enum:skipEnumNameMap?}} @ThriftEnumValue public int getValue() { return value; } {{#enum:skipEnumNameMap?}} @ThriftIntEnumResolver {{/enum:skipEnumNameMap?}} public static {{enum:javaCapitalName}} fromInteger(int n) { {{^enum:skipEnumNameMap?}} switch (n) { {{#enum:values}} case {{enum_value:value}}: return {{enum_value:javaConstantName}}; {{/enum:values}} default: return null; } {{/enum:skipEnumNameMap?}} {{#enum:skipEnumNameMap?}} return new {{enum:javaCapitalName}}(n); {{/enum:skipEnumNameMap?}} } {{#enum:thrift_uri}} static { com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type(new com.facebook.thrift.type.UniversalName("{{enum:thrift_uri}}"), {{enum:javaCapitalName}}.class, {{enum:javaCapitalName}}::read0)); } {{/enum:thrift_uri}} public static com.facebook.thrift.payload.Reader<{{enum:javaCapitalName}}> asReader() { return {{enum:javaCapitalName}}::read0; } public static {{enum:javaCapitalName}} read0(TProtocol iprot) throws TException { return {{enum:javaCapitalName}}.fromInteger(iprot.readI32()); } public void write0(TProtocol oprot) throws TException { oprot.writeI32(getValue()); } {{#enum:skipEnumNameMap?}} @java.lang.Override public boolean equals(java.lang.Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } {{enum:javaCapitalName}} other = ({{enum:javaCapitalName}})o; return this.value == other.value; } @java.lang.Override public int hashCode() { return value; } {{/enum:skipEnumNameMap?}} }