Add advanced send

This commit is contained in:
Andrea Cavalli 2023-03-12 15:10:38 +01:00
parent 33bc58bcb3
commit 17d55599d2

View File

@ -236,7 +236,7 @@ public final class SimpleTelegramClient implements Authenticable {
* @throws NullPointerException if function is null. * @throws NullPointerException if function is null.
*/ */
public <R extends TdApi.Object> void send(TdApi.Function<R> function, GenericResultHandler<R> resultHandler) { public <R extends TdApi.Object> void send(TdApi.Function<R> function, GenericResultHandler<R> resultHandler) {
this.send(function, resultHandler, null); client.send(function, result -> resultHandler.onResult(Result.of(result)), this::handleResultHandlingException);
} }
/** /**
@ -250,10 +250,10 @@ public final class SimpleTelegramClient implements Authenticable {
*/ */
public <R extends TdApi.Object> void send(TdApi.Function<R> function, GenericResultHandler<R> resultHandler, public <R extends TdApi.Object> void send(TdApi.Function<R> function, GenericResultHandler<R> resultHandler,
ExceptionHandler resultHandlerExceptionHandler) { ExceptionHandler resultHandlerExceptionHandler) {
client.send(function, if (resultHandlerExceptionHandler == null) {
result -> resultHandler.onResult(Result.of(result)), resultHandlerExceptionHandler = this::handleResultHandlingException;
Objects.requireNonNullElse(resultHandlerExceptionHandler, this::handleResultHandlingException) }
); client.send(function, result -> resultHandler.onResult(Result.of(result)), resultHandlerExceptionHandler);
} }
/** /**