{{! 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. }} {{> AutoGenerated}} package {{service:javaPackage}}; import com.facebook.nifty.client.RequestChannel; import com.facebook.swift.codec.*; import com.facebook.swift.service.*; import com.facebook.swift.service.metadata.*; import com.facebook.thrift.client.*; import com.facebook.thrift.util.FutureUtil; import java.io.*; import java.lang.reflect.Method; import java.util.*; import org.apache.thrift.ProtocolId; import reactor.core.publisher.Mono; @SwiftGenerated @Deprecated public class {{service:javaCapitalName}}ClientImpl extends {{^service:extends}}AbstractThriftClient{{/service:extends}}{{#service:extends}}{{service:javaPackage}}.{{service:javaCapitalName}}ClientImpl{{/service:extends}} implements {{service:javaCapitalName}} { // Method Handlers {{#service:singleRequestFunctions}} private ThriftMethodHandler {{function:javaName}}MethodHandler; {{/service:singleRequestFunctions}} // Method Exceptions {{#service:singleRequestFunctions}} private static final Class[] {{function:javaName}}Exceptions = new Class[] { {{#function:exceptions}}{{#field:type}}{{> BoxedType}}.class{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException.class}; {{/service:singleRequestFunctions}} public {{service:javaCapitalName}}ClientImpl( RequestChannel channel, Map methods, Map headers, Map persistentHeaders, List eventHandlers) { this("{{service:name}}", channel, methods, headers, persistentHeaders, eventHandlers); } protected {{service:javaCapitalName}}ClientImpl( String serviceName, RequestChannel channel, Map methods, Map headers, Map persistentHeaders, List eventHandlers) { {{^service:extends}}super(serviceName, channel, headers, persistentHeaders, eventHandlers);{{/service:extends}}{{#service:extends}}super(serviceName, channel, methods, headers, persistentHeaders, eventHandlers);{{/service:extends}} Map methodHandlerMap = new HashMap<>(); methods.forEach( (key, value) -> { methodHandlerMap.put(key.getName(), value); }); // Set method handlers {{#service:singleRequestFunctions}} {{function:javaName}}MethodHandler = methodHandlerMap.get("{{function:javaName}}"); {{/service:singleRequestFunctions}} } @java.lang.Override public void close() { super.close(); } {{#service:singleRequestFunctions}} @java.lang.Override public {{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}}{{^last?}},{{/last?}}{{/function:args}}){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException { {{#function:return_type}}{{^type:void?}}return {{/type:void?}}{{/function:return_type}}{{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}}RpcOptions.EMPTY).getData(); } @java.lang.Override public {{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException { {{#function:return_type}}{{^type:void?}}return {{/type:void?}}{{/function:return_type}}{{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}}rpcOptions).getData(); } @java.lang.Override public ResponseWrapper<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}Wrapper({{#function:args}} {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}} RpcOptions rpcOptions){{! Exceptions }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException { try { return FutureUtil.get(executeWrapperWithOptions({{function:javaName}}MethodHandler, {{function:javaName}}Exceptions, rpcOptions{{#function:args}}, {{field:javaName}}{{/function:args}})); } catch (Throwable t) { if (t instanceof org.apache.thrift.TException) { throw (org.apache.thrift.TException) t; } {{#function:exceptions}} if (t instanceof {{#field:type}}{{> BoxedType}}{{/field:type}}) { throw ({{#field:type}}{{> BoxedType}}{{/field:type}}) t; } {{/function:exceptions}} throw new org.apache.thrift.TException(t); } } {{/service:singleRequestFunctions}} {{#service:interactions}} public {{service:name}} create{{service:name}}() { throw new RuntimeException("create interaction is not supported"); } {{/service:interactions}} }