mirror of
https://github.com/tommyskeff/futur4j.git
synced 2026-03-19 02:01:22 +00:00
version 21 compatibility
This commit is contained in:
@@ -12,14 +12,14 @@ public final class FunctionAdapter {
|
||||
}
|
||||
|
||||
public static <K, V> @NotNull ExceptionalFunction<K, V> adapt(@NotNull ExceptionalRunnable runnable) {
|
||||
return _ -> {
|
||||
return v -> {
|
||||
runnable.run();
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
public static <K, T> @NotNull ExceptionalFunction<K, T> adapt(@NotNull ExceptionalSupplier<T> supplier) {
|
||||
return _ -> supplier.get();
|
||||
return v -> supplier.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public abstract class AbstractPromise<T> implements Promise<T> {
|
||||
|
||||
@Override
|
||||
public @NotNull Promise<Void> thenRun(@NotNull ExceptionalRunnable task) {
|
||||
return thenApply(_ -> {
|
||||
return thenApply(v -> {
|
||||
task.run();
|
||||
return null;
|
||||
});
|
||||
@@ -155,7 +155,7 @@ public abstract class AbstractPromise<T> implements Promise<T> {
|
||||
|
||||
@Override
|
||||
public <V> @NotNull Promise<V> thenSupply(@NotNull ExceptionalSupplier<V> task) {
|
||||
return thenApply(_ -> task.get());
|
||||
return thenApply(v -> task.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,13 +228,13 @@ public abstract class AbstractPromise<T> implements Promise<T> {
|
||||
private <F> void execute(@NotNull Promise<?> promise, @NotNull Runnable task, @NotNull PromiseExecutor<F> executor)
|
||||
throws Exception {
|
||||
F future = executor.run(task);
|
||||
promise.addDirectListener(_ -> executor.cancel(future));
|
||||
promise.addDirectListener(v -> executor.cancel(future));
|
||||
}
|
||||
|
||||
private <F> void schedule(@NotNull Promise<?> promise, @NotNull Runnable task, long delay, @NotNull TimeUnit unit,
|
||||
@NotNull PromiseScheduler<F> scheduler) throws Exception {
|
||||
F future = scheduler.schedule(task, delay, unit);
|
||||
promise.addDirectListener(_ -> scheduler.cancel(future));
|
||||
promise.addDirectListener(v -> scheduler.cancel(future));
|
||||
}
|
||||
|
||||
private <V> @NotNull Promise<V> thenCompose(@NotNull ExceptionalFunction<T, Promise<V>> task,
|
||||
@@ -494,12 +494,12 @@ public abstract class AbstractPromise<T> implements Promise<T> {
|
||||
|
||||
@Override
|
||||
public @NotNull Promise<T> orDefault(@Nullable T defaultValue) {
|
||||
return orDefault(_ -> defaultValue);
|
||||
return orDefault(v -> defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Promise<T> orDefault(@NotNull ExceptionalSupplier<T> supplier) {
|
||||
return orDefault(_ -> supplier.get());
|
||||
return orDefault(v -> supplier.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,7 +40,7 @@ public abstract class AbstractPromiseFactory implements PromiseFactory {
|
||||
});
|
||||
|
||||
if (future != null) {
|
||||
promise.onCancel(_ -> future.cancel(true));
|
||||
promise.onCancel(v -> future.cancel(true));
|
||||
}
|
||||
|
||||
return promise;
|
||||
@@ -48,7 +48,7 @@ public abstract class AbstractPromiseFactory implements PromiseFactory {
|
||||
|
||||
@Override
|
||||
public <K, V> @NotNull Promise<Map.Entry<K, V>> combine(@NotNull Promise<K> p1, @NotNull Promise<V> p2) {
|
||||
return all(p1, p2).thenApply(_ -> new AbstractMap.SimpleImmutableEntry<>(
|
||||
return all(p1, p2).thenApply(v -> new AbstractMap.SimpleImmutableEntry<>(
|
||||
Objects.requireNonNull(p1.getCompletion()).getResult(),
|
||||
Objects.requireNonNull(p2.getCompletion()).getResult()
|
||||
));
|
||||
|
||||
@@ -55,7 +55,7 @@ public abstract class BasePromise<T> extends AbstractPromise<T> implements Compl
|
||||
PromiseScheduler<F> scheduler) {
|
||||
runCompleter(this, () -> {
|
||||
F future = scheduler.schedule(() -> completeExceptionally(e), delay, unit);
|
||||
addDirectListener(_ -> scheduler.cancel(future));
|
||||
addDirectListener(v -> scheduler.cancel(future));
|
||||
});
|
||||
|
||||
return this;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class PromiseUtil {
|
||||
* @param to the promise to cancel upon completion
|
||||
*/
|
||||
public static void cancelOnComplete(@NotNull Promise<?> from, @NotNull Promise<?> to) {
|
||||
from.addDirectListener(_ -> to.cancel());
|
||||
from.addDirectListener(v -> to.cancel());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -263,7 +263,7 @@ public final class PromiseTests {
|
||||
@Test
|
||||
public void testImmediate2() {
|
||||
var resolved = promises.resolve(10);
|
||||
var promise = promises.start().thenCompose(_ -> resolved);
|
||||
var promise = promises.start().thenCompose(v -> resolved);
|
||||
assert promise.isCompleted() && promise instanceof CompletedPromise;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user