{{!

  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 {{struct:javaPackage}};

import com.facebook.swift.codec.*;
import com.facebook.swift.codec.ThriftField.Requiredness;
import com.facebook.swift.codec.ThriftField.Recursiveness;
import java.util.*;
import javax.annotation.Nullable;
import org.apache.thrift.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;
import com.google.common.collect.*;

@SwiftGenerated
@com.facebook.swift.codec.ThriftStruct("{{struct:name}}"){{> common/ObjectCustomAnnotation}}
public final class {{struct:javaCapitalName}} extends org.apache.thrift.TBaseException implements com.facebook.thrift.payload.ThriftSerializable {
    private static final long serialVersionUID = 1L;

    {{> struct/AdapterDefinition}}

    public static final Map<String, Integer> NAMES_TO_IDS = new HashMap();
    public static final Map<String, Integer> THRIFT_NAMES_TO_IDS = new HashMap();
    public static final Map<Integer, TField> FIELD_METADATA = new HashMap<>();

    private static final TStruct STRUCT_DESC = new TStruct("{{struct:name}}");
    {{#struct:fields}}
    private {{^struct:hasWrapper?}}final {{/struct:hasWrapper?}}{{> FieldType}} {{field:javaName}};
    public static final int _{{field:javaAllCapsName}} = {{field:key}};
    private static final TField {{field:javaTFieldName}} = new TField("{{#field:FieldNameUnmangled?}}{{field:name}}{{/field:FieldNameUnmangled?}}{{^field:FieldNameUnmangled?}}{{field:javaName}}{{/field:FieldNameUnmangled?}}", TType.{{#field:type}}{{> TType}}{{/field:type}}, (short){{field:key}});
    {{/struct:fields}}

    static {
      {{#struct:fields}}
      NAMES_TO_IDS.put("{{field:javaName}}", {{field:key}});
      THRIFT_NAMES_TO_IDS.put("{{field:name}}", {{field:key}});
      FIELD_METADATA.put({{field:key}}, {{field:javaTFieldName}});
      {{/struct:fields}}
      {{#struct:thrift_uri}}
      com.facebook.thrift.type.TypeRegistry.add(new com.facebook.thrift.type.Type(
        new com.facebook.thrift.type.UniversalName("{{struct:thrift_uri}}"),
        {{struct:javaCapitalName}}.class, {{struct:javaCapitalName}}::read0));
      {{/struct:thrift_uri}}
    }

    {{> struct/ThriftConstructor}}

    {{> struct/StructBuilder}}

    {{#struct:fields}}
    {{> struct/FieldGetter}}
    {{/struct:fields}}
    {{#struct:needsExceptionMessage?}}
    {{> ExceptionMessage}}
    {{/struct:needsExceptionMessage?}}

    {{> struct/StructRead}}

    {{> struct/StructWrite}}

    {{> Default}}
}
