1 /* 2 * Copyright 2018 The gRPC Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package io.grpc; 18 19 import com.google.common.base.MoreObjects; 20 import javax.annotation.Nullable; 21 22 /** 23 * A {@link ClientCall} which forwards all of its methods to another {@link ClientCall} which 24 * may have a different sendMessage() message type. 25 */ 26 abstract class PartialForwardingClientCall<ReqT, RespT> extends ClientCall<ReqT, RespT> { 27 /** 28 * Returns the delegated {@code ClientCall}. 29 */ delegate()30 protected abstract ClientCall<?, ?> delegate(); 31 32 @Override request(int numMessages)33 public void request(int numMessages) { 34 delegate().request(numMessages); 35 } 36 37 @Override cancel(@ullable String message, @Nullable Throwable cause)38 public void cancel(@Nullable String message, @Nullable Throwable cause) { 39 delegate().cancel(message, cause); 40 } 41 42 @Override halfClose()43 public void halfClose() { 44 delegate().halfClose(); 45 } 46 47 @Override setMessageCompression(boolean enabled)48 public void setMessageCompression(boolean enabled) { 49 delegate().setMessageCompression(enabled); 50 } 51 52 @Override isReady()53 public boolean isReady() { 54 return delegate().isReady(); 55 } 56 57 @Override getAttributes()58 public Attributes getAttributes() { 59 return delegate().getAttributes(); 60 } 61 62 @Override toString()63 public String toString() { 64 return MoreObjects.toStringHelper(this).add("delegate", delegate()).toString(); 65 } 66 } 67