legolas.async.api.interfaces.Promises Maven / Gradle / Ivy
package legolas.async.api.interfaces;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
public class Promises {
private final List> promises;
private Promises() {
this.promises = new ArrayList<>();
}
public static Promises create() {
return new Promises();
}
public Promise add() {
return this.add(() -> null);
}
public Promise add(Supplier supplier) {
Promise promise = Promise.create(supplier);
this.promises.add(promise.asFuture());
return promise;
}
public Promise all() {
CompletableFuture future = CompletableFuture.allOf(this.promises.toArray(new CompletableFuture[this.promises.size()]));
return new Promise<>(future);
}
public Promise
© 2015 - 2025 Weber Informatics LLC | Privacy Policy