Remove unnecessary Generic parameters from ServerCall.
The client Call needs both parameters because it containts start(), but
ServerCall doesn't actually have that same need.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=73662252
diff --git a/core/src/main/java/com/google/net/stubby/ServerCall.java b/core/src/main/java/com/google/net/stubby/ServerCall.java
index bc7950c..bf4daae 100644
--- a/core/src/main/java/com/google/net/stubby/ServerCall.java
+++ b/core/src/main/java/com/google/net/stubby/ServerCall.java
@@ -19,7 +19,7 @@
*
* <p>Methods are guaranteed to be non-blocking. Implementations are not required to be thread-safe.
*/
-public abstract class ServerCall<RequestT, ResponseT> {
+public abstract class ServerCall<ResponseT> {
/**
* Callbacks for consuming incoming RPC messages.
*
@@ -32,7 +32,7 @@
// TODO(user): We need to decide what to do in the case of server closing with non-cancellation
// before client half closes. It may be that we treat such a case as an error. If we permit such
// a case then we either get to generate a half close or purposefully omit it.
- public abstract static class Listener<T> {
+ public abstract static class Listener<RequestT> {
/**
* A request context has been received. Any context messages will precede payload messages.
*
@@ -48,7 +48,7 @@
* messages.
*/
@Nullable
- public abstract ListenableFuture<Void> onPayload(T payload);
+ public abstract ListenableFuture<Void> onPayload(RequestT payload);
/**
* The client completed all message sending. However, the call may still be cancelled.
diff --git a/core/src/main/java/com/google/net/stubby/ServerCallHandler.java b/core/src/main/java/com/google/net/stubby/ServerCallHandler.java
index 9f97c7b..065a7b9 100644
--- a/core/src/main/java/com/google/net/stubby/ServerCallHandler.java
+++ b/core/src/main/java/com/google/net/stubby/ServerCallHandler.java
@@ -21,5 +21,5 @@
* @return listener for processing incoming messages for {@code call}
*/
ServerCall.Listener<ReqT> startCall(MethodDescriptor<ReqT, RespT> method,
- ServerCall<ReqT, RespT> call);
+ ServerCall<RespT> call);
}
diff --git a/core/src/main/java/com/google/net/stubby/ServerInterceptor.java b/core/src/main/java/com/google/net/stubby/ServerInterceptor.java
index 28be428..5dade5e 100644
--- a/core/src/main/java/com/google/net/stubby/ServerInterceptor.java
+++ b/core/src/main/java/com/google/net/stubby/ServerInterceptor.java
@@ -21,5 +21,5 @@
* @return listener for processing incoming messages for {@code call}
*/
<ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(MethodDescriptor<ReqT, RespT> method,
- ServerCall<ReqT, RespT> call, ServerCallHandler<ReqT, RespT> next);
+ ServerCall<RespT> call, ServerCallHandler<ReqT, RespT> next);
}
diff --git a/core/src/main/java/com/google/net/stubby/ServerInterceptors.java b/core/src/main/java/com/google/net/stubby/ServerInterceptors.java
index 79f1f13..a8a2c96 100644
--- a/core/src/main/java/com/google/net/stubby/ServerInterceptors.java
+++ b/core/src/main/java/com/google/net/stubby/ServerInterceptors.java
@@ -60,7 +60,7 @@
@Override
public ServerCall.Listener<ReqT> startCall(MethodDescriptor<ReqT, RespT> method,
- ServerCall<ReqT, RespT> call) {
+ ServerCall<RespT> call) {
return ProcessInterceptorsCallHandler.create(interceptors.iterator(), callHandler)
.startCall(method, call);
}
@@ -84,7 +84,7 @@
@Override
public ServerCall.Listener<ReqT> startCall(MethodDescriptor<ReqT, RespT> method,
- ServerCall<ReqT, RespT> call) {
+ ServerCall<RespT> call) {
if (interceptors != null && interceptors.hasNext()) {
return interceptors.next().interceptCall(method, call, this);
} else {
diff --git a/core/src/test/java/com/google/net/stubby/ServerInterceptorsTest.java b/core/src/test/java/com/google/net/stubby/ServerInterceptorsTest.java
index a64e4d6..17e687a 100644
--- a/core/src/test/java/com/google/net/stubby/ServerInterceptorsTest.java
+++ b/core/src/test/java/com/google/net/stubby/ServerInterceptorsTest.java
@@ -33,15 +33,14 @@
private ServerCallHandler<String, Integer> handler = mock(ServerCallHandler.class);
private ServerCall.Listener<String> listener = mock(ServerCall.Listener.class);
private MethodDescriptor<String, Integer> methodDescriptor = mock(MethodDescriptor.class);
- private ServerCall<String, Integer> call = mock(ServerCall.class);
+ private ServerCall<Integer> call = mock(ServerCall.class);
private ServerServiceDefinition serviceDefinition = ServerServiceDefinition.builder("basic")
.addMethod("flow", requestMarshaller, responseMarshaller, handler).build();
@Before
public void setUp() {
Mockito.when(handler.startCall(
- Mockito.<MethodDescriptor<String, Integer>>any(),
- Mockito.<ServerCall<String, Integer>>any()))
+ Mockito.<MethodDescriptor<String, Integer>>any(), Mockito.<ServerCall<Integer>>any()))
.thenReturn(listener);
}
@@ -118,7 +117,7 @@
handler = new ServerCallHandler<String, Integer>() {
@Override
public ServerCall.Listener<String> startCall(MethodDescriptor<String, Integer> method,
- ServerCall<String, Integer> call) {
+ ServerCall<Integer> call) {
order.add("handler");
return listener;
}
@@ -126,7 +125,7 @@
ServerInterceptor interceptor1 = new ServerInterceptor() {
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
- MethodDescriptor<ReqT, RespT> method, ServerCall<ReqT, RespT> call,
+ MethodDescriptor<ReqT, RespT> method, ServerCall<RespT> call,
ServerCallHandler<ReqT, RespT> next) {
order.add("i1");
return next.startCall(method, call);
@@ -135,7 +134,7 @@
ServerInterceptor interceptor2 = new ServerInterceptor() {
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
- MethodDescriptor<ReqT, RespT> method, ServerCall<ReqT, RespT> call,
+ MethodDescriptor<ReqT, RespT> method, ServerCall<RespT> call,
ServerCallHandler<ReqT, RespT> next) {
order.add("i2");
return next.startCall(method, call);
@@ -153,12 +152,13 @@
@Test
public void argumentsPassed() {
final MethodDescriptor<String, Integer> method2 = mock(MethodDescriptor.class);
- final ServerCall<String, Integer> call2 = mock(ServerCall.class);
+ @SuppressWarnings("unchecked")
+ final ServerCall<Integer> call2 = mock(ServerCall.class);
final ServerCall.Listener<String> listener2 = mock(ServerCall.Listener.class);
ServerInterceptor interceptor = new ServerInterceptor() {
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
- MethodDescriptor<ReqT, RespT> method, ServerCall<ReqT, RespT> call,
+ MethodDescriptor<ReqT, RespT> method, ServerCall<RespT> call,
ServerCallHandler<ReqT, RespT> next) {
assertSame(method, methodDescriptor);
assertSame(call, ServerInterceptorsTest.this.call);
@@ -180,7 +180,7 @@
private static class NoopInterceptor implements ServerInterceptor {
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
- MethodDescriptor<ReqT, RespT> method, ServerCall<ReqT, RespT> call,
+ MethodDescriptor<ReqT, RespT> method, ServerCall<RespT> call,
ServerCallHandler<ReqT, RespT> next) {
return next.startCall(method, call);
}