{{!

  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 {{service:javaPackage}};
{{#service:disableReactive?}}// Generation of this class is disabled using (java.swift.disable_reactive){{/service:disableReactive?}}{{^service:disableReactive?}}
import java.util.*;

public class {{service:javaCapitalName}}ReactiveBlockingWrapper {{#service:extends}} extends {{service:javaPackage}}.{{service:javaCapitalName}}ReactiveBlockingWrapper{{/service:extends}}
  implements {{service:javaCapitalName}} {
  private final {{service:javaCapitalName}}.Reactive _delegate;

  public {{service:javaCapitalName}}ReactiveBlockingWrapper({{service:javaCapitalName}}.Reactive _delegate) {
    {{#service:extends}}super(_delegate);{{/service:extends}}
    this._delegate = _delegate;
  }

  public {{service:javaCapitalName}}ReactiveBlockingWrapper(org.apache.thrift.ProtocolId _protocolId, reactor.core.publisher.Mono<? extends com.facebook.thrift.client.RpcClient> _rpcClient, Map<String, String> _headers, Map<String, String> _persistentHeaders) {
    this(new {{service:javaCapitalName}}ReactiveClient(_protocolId, _rpcClient, _headers, _persistentHeaders));
  }

  @java.lang.Override
  public void close() {
    _delegate.dispose();
  }

  {{#service:singleRequestFunctions}}
  @java.lang.Override
  public {{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}} final {{#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:voidType}}
      {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}}com.facebook.thrift.client.RpcOptions.EMPTY);
    {{/function:voidType}}
    {{^function:voidType}}
      return {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}}com.facebook.thrift.client.RpcOptions.EMPTY).getData();
    {{/function:voidType}}
  }

  @java.lang.Override
  public {{#function:return_type}}{{> Type}}{{/function:return_type}} {{function:javaName}}({{#function:args}}
        final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}}
        com.facebook.thrift.client.RpcOptions rpcOptions){{!
          Exceptions
        }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException {
    {{#function:voidType}}
      {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}},{{/function:args}}rpcOptions);
    {{/function:voidType}}
    {{^function:voidType}}
      return {{function:javaName}}Wrapper({{#function:args}}{{field:javaName}},{{/function:args}}rpcOptions).getData();
    {{/function:voidType}}
  }

  @java.lang.Override
  public com.facebook.thrift.client.ResponseWrapper<{{#function:return_type}}{{> BoxedType}}{{/function:return_type}}> {{function:javaName}}Wrapper({{#function:args}}
    final {{#field:type}}{{> Type}}{{/field:type}} {{field:javaName}},{{/function:args}}
    com.facebook.thrift.client.RpcOptions rpcOptions){{!
      Exceptions
    }} throws {{#function:exceptions}}{{#field:type}}{{> BoxedType}}{{/field:type}}, {{/function:exceptions}}org.apache.thrift.TException {
      try {
        return _delegate.{{function:javaName}}Wrapper({{#function:args}}{{field:javaName}}, {{/function:args}}rpcOptions).block();
      } catch (Throwable t) {
        {{#function:exceptions}}
        if (t instanceof {{#field:type}}{{> BoxedType}}{{/field:type}}) {
          throw ({{#field:type}}{{> BoxedType}}{{/field:type}})t;
        }
        {{/function:exceptions}}
        throw com.facebook.thrift.util.ExceptionUtil.wrap(t);
      }
  }
  {{/service:singleRequestFunctions}}

  {{#service:interactions}}
  public {{service:name}} create{{service:name}}() {
      throw new UnsupportedOperationException("Interactions are not yet supported on ReactiveBlockingWrapper Interfaces!");
  }
  {{^last?}}

  {{/last?}}
  {{/service:interactions}}
}
{{/service:disableReactive?}}