Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "added option to java client to send query with CompletableFut…
…ure response"

This reverts commit 37a7c1c.
  • Loading branch information
p-vorobyev committed Feb 17, 2024
commit 2d65201af9c4a90eba299b739005bd45c73fb9f9
22 changes: 0 additions & 22 deletions example/java/org/drinkless/tdlib/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
package org.drinkless.tdlib;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

Expand Down Expand Up @@ -112,27 +111,6 @@ public void send(TdApi.Function query, ResultHandler resultHandler) {
send(query, resultHandler, null);
}

/**
* Sends a request to the TDLib.
*
* @param query Object representing a query to the TDLib.
* @param <T> Automatically deduced return type of the query.
* @return {@link CompletableFuture} response with result type
* If this stage completes exceptionally it throws {@link ExecutionException}
*/
@SuppressWarnings("unchecked")
public <T extends TdApi.Object> CompletableFuture<T> send(TdApi.Function<T> query) {
CompletableFuture<T> future = new CompletableFuture<>();
send(query, object -> {
if (object instanceof TdApi.Error) {
future.completeExceptionally(new ExecutionException((TdApi.Error) object));
} else {
future.complete((T) object);
}
});
return future;
}

/**
* Synchronously executes a TDLib request. Only a few marked accordingly requests can be executed synchronously.
*
Expand Down