some refactoring
This commit is contained in:
@@ -21,12 +21,22 @@ public interface TelegramBot {
|
||||
|
||||
void shutdown();
|
||||
|
||||
default CompletableFuture<File> downloadFile(TelegramFile telegramFile, Path targetDirectory) throws TelegramApiException, TelegramApiNetworkException {
|
||||
return CompletableFuture.supplyAsync(() -> awaitDownloadFile(telegramFile, targetDirectory));
|
||||
default CompletableFuture<File> downloadFile(TelegramFile telegramFile, Path targetDirectory) {
|
||||
CompletableFuture<File> completableFuture = CompletableFuture.supplyAsync(() -> awaitDownloadFile(telegramFile, targetDirectory));
|
||||
completableFuture.exceptionally(e -> {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
});
|
||||
return completableFuture;
|
||||
}
|
||||
|
||||
default <T> CompletableFuture<T> execute(TelegramApiMethod<T> telegramApiMethod) throws TelegramApiException, TelegramApiNetworkException, TelegramMethodParsingException {
|
||||
return CompletableFuture.supplyAsync(() -> awaitExecute(telegramApiMethod));
|
||||
default <T> CompletableFuture<T> execute(TelegramApiMethod<T> telegramApiMethod) {
|
||||
CompletableFuture<T> completableFuture = CompletableFuture.supplyAsync(() -> awaitExecute(telegramApiMethod));
|
||||
completableFuture.exceptionally(e -> {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
});
|
||||
return completableFuture;
|
||||
}
|
||||
|
||||
default int getPing() throws TelegramApiNetworkException {
|
||||
|
||||
@@ -19,8 +19,12 @@ public final class TelegramApiMethodBody {
|
||||
if (value != null) this.elements.add(new Element(name, value));
|
||||
}
|
||||
|
||||
public void forEach(Consumer<? super Element> action) {
|
||||
this.elements.forEach(action);
|
||||
public int size() {
|
||||
return this.elements.size();
|
||||
}
|
||||
|
||||
public Element get(int i) {
|
||||
return this.elements.get(i);
|
||||
}
|
||||
|
||||
public record Element(String name, String value) {
|
||||
|
||||
Reference in New Issue
Block a user