thrift/compiler/generate/templates/java2/Struct.mustache (91 lines of code) (raw):
{{!
Copyright (c) Facebook, Inc. and its 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 com.google.common.collect.*;
import java.util.*;
import javax.annotation.Nullable;
import org.apache.thrift.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.MoreObjects.ToStringHelper;
@SwiftGenerated
{{#struct:asBean?}}
@com.facebook.swift.codec.ThriftStruct("{{struct:name}}"){{> common/ObjectCustomAnnotation}}
{{/struct:asBean?}}
{{^struct:asBean?}}
@com.facebook.swift.codec.ThriftStruct(value="{{struct:name}}", builder={{struct:javaCapitalName}}.Builder.class){{> common/ObjectCustomAnnotation}}
{{/struct:asBean?}}
public final class {{struct:javaCapitalName}} implements com.facebook.thrift.payload.ThriftSerializable {
{{#struct:enableIsSet?}}
private BitSet __isset_bit_vector = new BitSet();
{{/struct:enableIsSet?}}
{{> struct/ThriftConstructor}}
{{> struct/StructBuilder}}{{!
}}{{#struct:fields}}
{{#field:hasAdapter?}}
private static final com.facebook.thrift.adapter.TypeAdapter<{{field:typeClassName}}> _{{field:javaName}}_Adapter = new {{field:adapterClassName}}();
{{/field:hasAdapter?}}
{{/struct:fields}}{{!
}}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}}{{!
}}{{#struct:asBean?}}
{{#field:isSensitive?}}
@org.apache.thrift.annotations.Sensitive
{{/field:isSensitive?}}
private {{> FieldType}} {{field:javaName}};
public static final int _{{field:javaAllCapsName}} = {{field:key}};
private static final TField {{field:javaTFieldName}} = new TField("{{field:name}}", TType.{{#field:type}}{{> TType}}{{/field:type}}, (short){{field:key}});
{{/struct:asBean?}}{{!
}}{{^struct:asBean?}}
{{#field:isSensitive?}}
@org.apache.thrift.annotations.Sensitive
{{/field:isSensitive?}}
{{#field:javaAnnotations?}}{{field:javaAnnotations}} {{/field:javaAnnotations?}}private {{^struct:isBigStruct?}}final {{/struct:isBigStruct?}}{{> FieldType}} {{field:javaName}};
public static final int _{{field:javaAllCapsName}} = {{field:key}};
private static final TField {{field:javaTFieldName}} = new TField("{{field:name}}", TType.{{#field:type}}{{> TType}}{{/field:type}}, (short){{field:key}});
{{/struct:asBean?}}{{!
}}{{/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:fields}}
{{> struct/FieldGetter}}{{!
}}{{#struct:asBean?}}
{{> struct/FieldSetter}}
{{/struct:asBean?}}{{!
}}
{{#struct:enableIsSet?}}
{{> struct/FieldIsSet}}
{{/struct:enableIsSet?}}{{!
}}{{/struct:fields}}
{{> struct/StructToString}}
{{> struct/StructEquals}}
{{> struct/StructHashCode}}
{{> struct/StructRead}}
{{> struct/StructWrite}}
{{^struct:asBean?}}
{{> Default}}
{{/struct:asBean?}}
}