Skip to content

Commit

Permalink
feat: add FunctionalInterface annotation (#1515)
Browse files Browse the repository at this point in the history
* feat: add `FunctionalInterface` annotation

* exclude internal api

* revise according to code review

* remove annotation on beta api

* remove annotation

* remove annotation
  • Loading branch information
JoeWang1127 committed Apr 11, 2023
1 parent e38c8ec commit 66c0509
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*
* <p>It is similar to Guava's {@code AsyncFunction}, redeclared so that Guava can be shaded.
*/
@FunctionalInterface
public interface ApiAsyncFunction<I, O> {
/**
* Returns an output Future to use in place of the given input. The output Future need not be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*
* <p>It is similar to Guava's {@code Function}, redeclared so that Guava can be shaded.
*/
@FunctionalInterface
public interface ApiFunction<F, T> {
T apply(F input);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
*/
public class ValidationException extends IllegalArgumentException {

@FunctionalInterface
public interface Supplier<T> {
T get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* A functional interface to be implemented for each request message to extract specific fields from
* it. For advanced usage only.
*/
@FunctionalInterface
public interface FieldsExtractor<RequestT, ParamsT> {
ParamsT extract(RequestT request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,7 @@ public void call(final BidiStreamObserver<RequestT, ResponseT> bidiObserver) {
/** Listens to server responses and send requests when the network is free. */
public void call(
final BidiStreamObserver<RequestT, ResponseT> bidiObserver, ApiCallContext context) {
internalCall(
bidiObserver,
new ClientStreamReadyObserver<RequestT>() {
@Override
public void onReady(ClientStream<RequestT> stream) {
bidiObserver.onReady(stream);
}
},
context);
internalCall(bidiObserver, bidiObserver, context);
}

/**
Expand Down Expand Up @@ -183,11 +175,8 @@ public ClientStream<RequestT> splitCall(
ResponseObserver<ResponseT> responseObserver, ApiCallContext context) {
return internalCall(
responseObserver,
new ClientStreamReadyObserver<RequestT>() {
@Override
public void onReady(ClientStream<RequestT> stream) {
// no op
}
stream -> {
// no op
},
context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
package com.google.api.gax.rpc;

/** A callback used to report that the {@link ClientStream} is ready to send more messages. */
@FunctionalInterface
public interface ClientStreamReadyObserver<V> {
void onReady(ClientStream<V> stream);
}

0 comments on commit 66c0509

Please sign in to comment.