Created
August 21, 2020 14:10
-
-
Save nsivabalan/43debc98eb1e4042ff385516a7bf2f92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UberClientCall<ReqT, RespT> { | |
@Nullable private ClientCall<ReqT, RespT> delegate; | |
public UberClientCall() {} | |
public UberClientCall(ClientCall<ReqT, RespT> delegate) { | |
this.delegate = delegate; | |
} | |
public void start(UberNetworkListener<RespT> responseListener, UberNetworkHeaders headers) { | |
if (delegate != null) { | |
delegate.start(responseListener), | |
(Metadata) headers.getNetworkTransportHeaders()); | |
} else { | |
throw new IllegalStateException("Delegate can't be null"); | |
} | |
} | |
public void request(int numMessages) { | |
if (delegate != null) { | |
delegate.request(numMessages); | |
} else { | |
throw new IllegalStateException("Delegate can't be null"); | |
} | |
} | |
public void cancel(@Nullable String message, @Nullable Throwable cause) { | |
if (delegate != null) { | |
delegate.cancel(message, cause); | |
} else { | |
throw new IllegalStateException("Delegate can't be null"); | |
} | |
} | |
public void halfClose() { | |
if (delegate != null) { | |
delegate.halfClose(); | |
} else { | |
throw new IllegalStateException("Delegate can't be null"); | |
} | |
} | |
public void sendMessage(ReqT message) { | |
if (delegate != null) { | |
delegate.sendMessage(message); | |
} else { | |
throw new IllegalStateException("Delegate can't be null"); | |
} | |
} | |
public boolean isReady() { | |
if (delegate != null) { | |
return delegate.isReady(); | |
} else { | |
throw new IllegalStateException("Delegate can't be null"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment