version 21 compatibility

This commit is contained in:
WhatCats
2026-03-08 12:54:09 +01:00
parent df1ee340dd
commit 0f2ef2ef42
7 changed files with 16 additions and 16 deletions

View File

@@ -6,7 +6,7 @@ plugins {
subprojects {
group = 'dev.tommyjs'
version = '2.5.1'
version = '2.5.2'
apply plugin: 'java-library'
apply plugin: 'com.github.johnrengelman.shadow'
@@ -63,8 +63,8 @@ subprojects {
}
java {
sourceCompatibility = JavaVersion.VERSION_23
targetCompatibility = JavaVersion.VERSION_23
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
withSourcesJar()
}
}

View File

@@ -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();
}
}

View File

@@ -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

View File

@@ -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()
));

View File

@@ -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;

View File

@@ -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());
}
/**

View File

@@ -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;
}