{{! Copyright (c) Meta Platforms, 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. }} public static com.facebook.thrift.payload.Reader<{{struct:javaCapitalName}}> asReader() { return {{struct:javaCapitalName}}::read0; } public static {{struct:javaCapitalName}} read0(TProtocol oprot) throws TException { {{struct:javaCapitalName}} res = new {{struct:javaCapitalName}}(); res.value = null; res.id = (short) 0; oprot.readStructBegin({{struct:javaCapitalName}}.NAMES_TO_IDS, {{struct:javaCapitalName}}.THRIFT_NAMES_TO_IDS, {{struct:javaCapitalName}}.FIELD_METADATA); TField __field = oprot.readFieldBegin(); if (__field.type != TType.STOP) { switch (__field.id) { {{#struct:fields}} case _{{field:javaAllCapsName}}: if (__field.type == {{field:javaTFieldName}}.type) { {{#field:type}} {{field:nestedDepth++}}{{> ReadType}}{{field:nestedDepth--}} {{/field:type}} {{#field:hasAdapter?}} res.value = {{> FromThriftStart}}{{field:javaName}}{{> FromThriftEnd}}; {{/field:hasAdapter?}} {{^field:hasAdapter?}} res.value = {{field:javaName}}; {{/field:hasAdapter?}} } break; {{/struct:fields}} default: TProtocolUtil.skip(oprot, __field.type); } if (res.value != null) { res.id = __field.id; } oprot.readFieldEnd(); TField __stopField = oprot.readFieldBegin(); // Consume the STOP byte if (__stopField.type != TType.STOP) { throw new TProtocolException(TProtocolException.INVALID_DATA, "Union '{{struct:javaCapitalName}}' is missing a STOP byte"); } } oprot.readStructEnd(); return res; }