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.Listener} which forwards all of its methods to another {@link 23 * ServerCall.Listener} which may have a different parameterized type than the 24 * onMessage() message type. 25 */ 26 abstract class PartialForwardingServerCallListener<ReqT> 27 extends ServerCall.Listener<ReqT> { 28 /** 29 * Returns the delegated {@code ServerCall.Listener}. 30 */ delegate()31 protected abstract ServerCall.Listener<?> delegate(); 32 33 @Override onHalfClose()34 public void onHalfClose() { 35 delegate().onHalfClose(); 36 } 37 38 @Override onCancel()39 public void onCancel() { 40 delegate().onCancel(); 41 } 42 43 @Override onComplete()44 public void onComplete() { 45 delegate().onComplete(); 46 } 47 48 @Override onReady()49 public void onReady() { 50 delegate().onReady(); 51 } 52 53 @Override toString()54 public String toString() { 55 return MoreObjects.toStringHelper(this).add("delegate", delegate()).toString(); 56 } 57 } 58