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:
@@ -6,7 +6,7 @@ plugins {
|
|||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
group = 'dev.tommyjs'
|
group = 'dev.tommyjs'
|
||||||
version = '2.5.1'
|
version = '2.5.2'
|
||||||
|
|
||||||
apply plugin: 'java-library'
|
apply plugin: 'java-library'
|
||||||
apply plugin: 'com.github.johnrengelman.shadow'
|
apply plugin: 'com.github.johnrengelman.shadow'
|
||||||
@@ -63,8 +63,8 @@ subprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
sourceCompatibility = JavaVersion.VERSION_23
|
sourceCompatibility = JavaVersion.VERSION_21
|
||||||
targetCompatibility = JavaVersion.VERSION_23
|
targetCompatibility = JavaVersion.VERSION_21
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,14 +12,14 @@ public final class FunctionAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <K, V> @NotNull ExceptionalFunction<K, V> adapt(@NotNull ExceptionalRunnable runnable) {
|
public static <K, V> @NotNull ExceptionalFunction<K, V> adapt(@NotNull ExceptionalRunnable runnable) {
|
||||||
return _ -> {
|
return v -> {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <K, T> @NotNull ExceptionalFunction<K, T> adapt(@NotNull ExceptionalSupplier<T> supplier) {
|
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
|
@Override
|
||||||
public @NotNull Promise<Void> thenRun(@NotNull ExceptionalRunnable task) {
|
public @NotNull Promise<Void> thenRun(@NotNull ExceptionalRunnable task) {
|
||||||
return thenApply(_ -> {
|
return thenApply(v -> {
|
||||||
task.run();
|
task.run();
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@@ -155,7 +155,7 @@ public abstract class AbstractPromise<T> implements Promise<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <V> @NotNull Promise<V> thenSupply(@NotNull ExceptionalSupplier<V> task) {
|
public <V> @NotNull Promise<V> thenSupply(@NotNull ExceptionalSupplier<V> task) {
|
||||||
return thenApply(_ -> task.get());
|
return thenApply(v -> task.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
private <F> void execute(@NotNull Promise<?> promise, @NotNull Runnable task, @NotNull PromiseExecutor<F> executor)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
F future = executor.run(task);
|
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,
|
private <F> void schedule(@NotNull Promise<?> promise, @NotNull Runnable task, long delay, @NotNull TimeUnit unit,
|
||||||
@NotNull PromiseScheduler<F> scheduler) throws Exception {
|
@NotNull PromiseScheduler<F> scheduler) throws Exception {
|
||||||
F future = scheduler.schedule(task, delay, unit);
|
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,
|
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
|
@Override
|
||||||
public @NotNull Promise<T> orDefault(@Nullable T defaultValue) {
|
public @NotNull Promise<T> orDefault(@Nullable T defaultValue) {
|
||||||
return orDefault(_ -> defaultValue);
|
return orDefault(v -> defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Promise<T> orDefault(@NotNull ExceptionalSupplier<T> supplier) {
|
public @NotNull Promise<T> orDefault(@NotNull ExceptionalSupplier<T> supplier) {
|
||||||
return orDefault(_ -> supplier.get());
|
return orDefault(v -> supplier.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public abstract class AbstractPromiseFactory implements PromiseFactory {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (future != null) {
|
if (future != null) {
|
||||||
promise.onCancel(_ -> future.cancel(true));
|
promise.onCancel(v -> future.cancel(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
@@ -48,7 +48,7 @@ public abstract class AbstractPromiseFactory implements PromiseFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <K, V> @NotNull Promise<Map.Entry<K, V>> combine(@NotNull Promise<K> p1, @NotNull Promise<V> p2) {
|
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(p1.getCompletion()).getResult(),
|
||||||
Objects.requireNonNull(p2.getCompletion()).getResult()
|
Objects.requireNonNull(p2.getCompletion()).getResult()
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public abstract class BasePromise<T> extends AbstractPromise<T> implements Compl
|
|||||||
PromiseScheduler<F> scheduler) {
|
PromiseScheduler<F> scheduler) {
|
||||||
runCompleter(this, () -> {
|
runCompleter(this, () -> {
|
||||||
F future = scheduler.schedule(() -> completeExceptionally(e), delay, unit);
|
F future = scheduler.schedule(() -> completeExceptionally(e), delay, unit);
|
||||||
addDirectListener(_ -> scheduler.cancel(future));
|
addDirectListener(v -> scheduler.cancel(future));
|
||||||
});
|
});
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class PromiseUtil {
|
|||||||
* @param to the promise to cancel upon completion
|
* @param to the promise to cancel upon completion
|
||||||
*/
|
*/
|
||||||
public static void cancelOnComplete(@NotNull Promise<?> from, @NotNull Promise<?> to) {
|
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
|
@Test
|
||||||
public void testImmediate2() {
|
public void testImmediate2() {
|
||||||
var resolved = promises.resolve(10);
|
var resolved = promises.resolve(10);
|
||||||
var promise = promises.start().thenCompose(_ -> resolved);
|
var promise = promises.start().thenCompose(v -> resolved);
|
||||||
assert promise.isCompleted() && promise instanceof CompletedPromise;
|
assert promise.isCompleted() && promise instanceof CompletedPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user