1 /* 2 * Copyright 2015 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 21 /** 22 * A {@link ServerCall} which forwards all of it's methods to another {@link ServerCall} which 23 * may have a different onMessage() message type. 24 */ 25 abstract class PartialForwardingServerCall<ReqT, RespT> extends ServerCall<ReqT, RespT> { 26 /** 27 * Returns the delegated {@code ServerCall}. 28 */ delegate()29 protected abstract ServerCall<?, ?> delegate(); 30 31 @Override request(int numMessages)32 public void request(int numMessages) { 33 delegate().request(numMessages); 34 } 35 36 @Override sendHeaders(Metadata headers)37 public void sendHeaders(Metadata headers) { 38 delegate().sendHeaders(headers); 39 } 40 41 @Override isReady()42 public boolean isReady() { 43 return delegate().isReady(); 44 } 45 46 @Override close(Status status, Metadata trailers)47 public void close(Status status, Metadata trailers) { 48 delegate().close(status, trailers); 49 } 50 51 @Override isCancelled()52 public boolean isCancelled() { 53 return delegate().isCancelled(); 54 } 55 56 @Override 57 @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1703") setMessageCompression(boolean enabled)58 public void setMessageCompression(boolean enabled) { 59 delegate().setMessageCompression(enabled); 60 } 61 62 @Override 63 @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704") setCompression(String compressor)64 public void setCompression(String compressor) { 65 delegate().setCompression(compressor); 66 } 67 68 @Override 69 @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1779") getAttributes()70 public Attributes getAttributes() { 71 return delegate().getAttributes(); 72 } 73 74 @Override getAuthority()75 public String getAuthority() { 76 return delegate().getAuthority(); 77 } 78 79 @Override toString()80 public String toString() { 81 return MoreObjects.toStringHelper(this).add("delegate", delegate()).toString(); 82 } 83 } 84