name task async
This commit is contained in:
@@ -40,8 +40,8 @@ public class AuthlibInjectorDownloader implements AuthlibInjectorArtifactProvide
|
||||
|
||||
private static final String LATEST_BUILD_URL = "https://authlib-injector.yushi.moe/artifact/latest.json";
|
||||
|
||||
private Path artifactLocation;
|
||||
private Supplier<DownloadProvider> downloadProvider;
|
||||
private final Path artifactLocation;
|
||||
private final Supplier<DownloadProvider> downloadProvider;
|
||||
|
||||
/**
|
||||
* The flag will be reset after application restart.
|
||||
|
||||
@@ -25,7 +25,7 @@ public enum TextureModel {
|
||||
|
||||
public final String modelName;
|
||||
|
||||
private TextureModel(String modelName) {
|
||||
TextureModel(String modelName) {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
||||
public Task<Version> installLibraryAsync(String gameVersion, Version version, String libraryId, String libraryVersion) {
|
||||
VersionList<?> versionList = getVersionList(libraryId);
|
||||
return versionList.loadAsync(gameVersion, getDownloadProvider())
|
||||
.thenCompose(() -> installLibraryAsync(version, versionList.getVersion(gameVersion, libraryVersion)
|
||||
.thenComposeAsync(() -> installLibraryAsync(version, versionList.getVersion(gameVersion, libraryVersion)
|
||||
.orElseThrow(() -> new IllegalStateException("Remote library " + libraryId + " has no version " + libraryVersion))));
|
||||
}
|
||||
|
||||
@@ -108,9 +108,9 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
||||
else
|
||||
throw new IllegalArgumentException("Remote library " + libraryVersion + " is unrecognized.");
|
||||
return task
|
||||
.thenCompose(LibrariesUniqueTask::new)
|
||||
.thenCompose(MaintainTask::new)
|
||||
.thenCompose(newVersion -> new VersionJsonSaveTask(repository, newVersion));
|
||||
.thenComposeAsync(LibrariesUniqueTask::new)
|
||||
.thenComposeAsync(MaintainTask::new)
|
||||
.thenComposeAsync(newVersion -> new VersionJsonSaveTask(repository, newVersion));
|
||||
}
|
||||
|
||||
|
||||
@@ -120,9 +120,7 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
||||
|
||||
public Task installLibraryAsync(Version oldVersion, Path installer) {
|
||||
return Task
|
||||
.of(() -> {
|
||||
})
|
||||
.thenCompose(() -> {
|
||||
.composeAsync(() -> {
|
||||
try {
|
||||
return ForgeInstallTask.install(this, oldVersion, installer);
|
||||
} catch (IOException ignore) {
|
||||
@@ -135,8 +133,8 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
||||
|
||||
throw new UnsupportedOperationException("Library cannot be recognized");
|
||||
})
|
||||
.thenCompose(LibrariesUniqueTask::new)
|
||||
.thenCompose(MaintainTask::new)
|
||||
.thenCompose(newVersion -> new VersionJsonSaveTask(repository, newVersion));
|
||||
.thenComposeAsync(LibrariesUniqueTask::new)
|
||||
.thenComposeAsync(MaintainTask::new)
|
||||
.thenComposeAsync(newVersion -> new VersionJsonSaveTask(repository, newVersion));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,25 +47,25 @@ public class DefaultGameBuilder extends GameBuilder {
|
||||
|
||||
@Override
|
||||
public Task<?> buildAsync() {
|
||||
return new VersionJsonDownloadTask(gameVersion, dependencyManager).thenCompose(rawJson -> {
|
||||
return new VersionJsonDownloadTask(gameVersion, dependencyManager).thenComposeAsync(rawJson -> {
|
||||
Version original = JsonUtils.GSON.fromJson(rawJson, Version.class);
|
||||
Version version = original.setId(name).setJar(null);
|
||||
Task<?> vanillaTask = downloadGameAsync(gameVersion, version).thenCompose(Task.allOf(
|
||||
Task<?> vanillaTask = downloadGameAsync(gameVersion, version).thenComposeAsync(Task.allOf(
|
||||
new GameAssetDownloadTask(dependencyManager, version, GameAssetDownloadTask.DOWNLOAD_INDEX_FORCIBLY),
|
||||
new GameLibrariesTask(dependencyManager, version) // Game libraries will be downloaded for multiple times partly, this time is for vanilla libraries.
|
||||
).withCompose(new VersionJsonSaveTask(dependencyManager.getGameRepository(), version))); // using [with] because download failure here are tolerant.
|
||||
).withComposeAsync(new VersionJsonSaveTask(dependencyManager.getGameRepository(), version))); // using [with] because download failure here are tolerant.
|
||||
|
||||
Task<Version> libraryTask = vanillaTask.thenSupply(() -> version);
|
||||
Task<Version> libraryTask = vanillaTask.thenSupplyAsync(() -> version);
|
||||
|
||||
if (toolVersions.containsKey("forge"))
|
||||
libraryTask = libraryTask.thenCompose(libraryTaskHelper(gameVersion, "forge"));
|
||||
libraryTask = libraryTask.thenComposeAsync(libraryTaskHelper(gameVersion, "forge"));
|
||||
if (toolVersions.containsKey("liteloader"))
|
||||
libraryTask = libraryTask.thenCompose(libraryTaskHelper(gameVersion, "liteloader"));
|
||||
libraryTask = libraryTask.thenComposeAsync(libraryTaskHelper(gameVersion, "liteloader"));
|
||||
if (toolVersions.containsKey("optifine"))
|
||||
libraryTask = libraryTask.thenCompose(libraryTaskHelper(gameVersion, "optifine"));
|
||||
libraryTask = libraryTask.thenComposeAsync(libraryTaskHelper(gameVersion, "optifine"));
|
||||
|
||||
for (RemoteVersion remoteVersion : remoteVersions)
|
||||
libraryTask = libraryTask.thenCompose(dependencyManager.installLibraryAsync(remoteVersion));
|
||||
libraryTask = libraryTask.thenComposeAsync(dependencyManager.installLibraryAsync(remoteVersion));
|
||||
|
||||
return libraryTask;
|
||||
}).whenComplete(exception -> {
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class CurseCompletionTask extends Task<Void> {
|
||||
private final DefaultGameRepository repository;
|
||||
private final ModManager modManager;
|
||||
private final String version;
|
||||
private CurseManifest manifest = null;
|
||||
private CurseManifest manifest;
|
||||
private final List<Task<?>> dependents = new LinkedList<>();
|
||||
private final List<Task<?>> dependencies = new LinkedList<>();
|
||||
|
||||
|
||||
@@ -174,10 +174,8 @@ public class Datapack {
|
||||
continue;
|
||||
|
||||
String name = FileUtils.getName(subDir);
|
||||
boolean enabled = true;
|
||||
if (name.endsWith(".disabled")) {
|
||||
name = name.substring(0, name.length() - ".disabled".length());
|
||||
enabled = false;
|
||||
}
|
||||
if (!name.endsWith(".zip"))
|
||||
continue;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.jackhuang.hmcl.mod;
|
||||
|
||||
import org.jackhuang.hmcl.util.Lang;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
import org.jackhuang.hmcl.util.io.CompressingUtils;
|
||||
import org.jackhuang.hmcl.util.io.FileUtils;
|
||||
|
||||
|
||||
@@ -20,12 +20,9 @@ package org.jackhuang.hmcl.mod;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.jackhuang.hmcl.util.Immutable;
|
||||
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
||||
import org.jackhuang.hmcl.util.io.CompressingUtils;
|
||||
import org.jackhuang.hmcl.util.io.IOUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
@@ -155,7 +155,7 @@ public final class MultiMCModpackInstallTask extends Task<Void> {
|
||||
}
|
||||
}
|
||||
|
||||
dependencies.add(new MaintainTask(version).thenCompose(maintainedVersion -> new VersionJsonSaveTask(repository, maintainedVersion)));
|
||||
dependencies.add(new MaintainTask(version).thenComposeAsync(maintainedVersion -> new VersionJsonSaveTask(repository, maintainedVersion)));
|
||||
dependencies.add(new MinecraftInstanceTask<>(zipFile, modpack.getEncoding(), "/" + manifest.getName() + "/minecraft", manifest, MODPACK_TYPE, repository.getModpackConfiguration(name)));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package org.jackhuang.hmcl.mod;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.jackhuang.hmcl.util.Immutable;
|
||||
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
||||
@@ -28,14 +27,9 @@ import org.jackhuang.hmcl.util.io.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Immutable
|
||||
public class PackMcMeta implements Validation {
|
||||
|
||||
@@ -34,7 +34,6 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
@@ -200,13 +200,13 @@ public abstract class Task<T> {
|
||||
|
||||
/**
|
||||
* @throws InterruptedException if current thread is interrupted
|
||||
* @see Thread#isInterrupted
|
||||
* @see Thread#interrupted
|
||||
*/
|
||||
public void preExecute() throws Exception {}
|
||||
|
||||
/**
|
||||
* @throws InterruptedException if current thread is interrupted
|
||||
* @see Thread#isInterrupted
|
||||
* @see Thread#interrupted
|
||||
*/
|
||||
public abstract void execute() throws Exception;
|
||||
|
||||
@@ -222,7 +222,7 @@ public abstract class Task<T> {
|
||||
* {@link Task#isRelyingOnDependencies()} returns true or false.
|
||||
*
|
||||
* @throws InterruptedException if current thread is interrupted
|
||||
* @see Thread#isInterrupted
|
||||
* @see Thread#interrupted
|
||||
* @see Task#isDependenciesSucceeded()
|
||||
*/
|
||||
public void postExecute() throws Exception {}
|
||||
@@ -342,8 +342,8 @@ public abstract class Task<T> {
|
||||
* @param <U> the function's return type
|
||||
* @return the new Task
|
||||
*/
|
||||
public <U, E extends Exception> Task<U> thenApply(ExceptionalFunction<T, U, E> fn) {
|
||||
return thenApply(Schedulers.defaultScheduler(), fn);
|
||||
public <U, E extends Exception> Task<U> thenApplyAsync(ExceptionalFunction<T, U, E> fn) {
|
||||
return thenApplyAsync(Schedulers.defaultScheduler(), fn);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,8 +356,8 @@ public abstract class Task<T> {
|
||||
* @param <U> the function's return type
|
||||
* @return the new Task
|
||||
*/
|
||||
public <U, E extends Exception> Task<U> thenApply(Executor executor, ExceptionalFunction<T, U, E> fn) {
|
||||
return thenApply(getCaller(), executor, fn);
|
||||
public <U, E extends Exception> Task<U> thenApplyAsync(Executor executor, ExceptionalFunction<T, U, E> fn) {
|
||||
return thenApplyAsync(getCaller(), executor, fn);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,7 +371,7 @@ public abstract class Task<T> {
|
||||
* @param <U> the function's return type
|
||||
* @return the new Task
|
||||
*/
|
||||
public <U, E extends Exception> Task<U> thenApply(String name, Executor executor, ExceptionalFunction<T, U, E> fn) {
|
||||
public <U, E extends Exception> Task<U> thenApplyAsync(String name, Executor executor, ExceptionalFunction<T, U, E> fn) {
|
||||
return new UniApply<>(fn).setExecutor(executor).setName(name);
|
||||
}
|
||||
|
||||
@@ -384,8 +384,8 @@ public abstract class Task<T> {
|
||||
* returned Task
|
||||
* @return the new Task
|
||||
*/
|
||||
public <E extends Exception> Task<Void> thenAccept(ExceptionalConsumer<T, E> action) {
|
||||
return thenAccept(Schedulers.defaultScheduler(), action);
|
||||
public <E extends Exception> Task<Void> thenAcceptAsync(ExceptionalConsumer<T, E> action) {
|
||||
return thenAcceptAsync(Schedulers.defaultScheduler(), action);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -397,8 +397,8 @@ public abstract class Task<T> {
|
||||
* @param executor the executor to use for asynchronous execution
|
||||
* @return the new Task
|
||||
*/
|
||||
public <E extends Exception> Task<Void> thenAccept(Executor executor, ExceptionalConsumer<T, E> action) {
|
||||
return thenAccept(getCaller(), executor, action);
|
||||
public <E extends Exception> Task<Void> thenAcceptAsync(Executor executor, ExceptionalConsumer<T, E> action) {
|
||||
return thenAcceptAsync(getCaller(), executor, action);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,8 +411,8 @@ public abstract class Task<T> {
|
||||
* @param executor the executor to use for asynchronous execution
|
||||
* @return the new Task
|
||||
*/
|
||||
public <E extends Exception> Task<Void> thenAccept(String name, Executor executor, ExceptionalConsumer<T, E> action) {
|
||||
return thenApply(name, executor, result -> {
|
||||
public <E extends Exception> Task<Void> thenAcceptAsync(String name, Executor executor, ExceptionalConsumer<T, E> action) {
|
||||
return thenApplyAsync(name, executor, result -> {
|
||||
action.accept(result);
|
||||
return null;
|
||||
});
|
||||
@@ -426,8 +426,8 @@ public abstract class Task<T> {
|
||||
* returned Task
|
||||
* @return the new Task
|
||||
*/
|
||||
public <E extends Exception> Task<Void> thenRun(ExceptionalRunnable<E> action) {
|
||||
return thenRun(Schedulers.defaultScheduler(), action);
|
||||
public <E extends Exception> Task<Void> thenRunAsync(ExceptionalRunnable<E> action) {
|
||||
return thenRunAsync(Schedulers.defaultScheduler(), action);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -439,8 +439,8 @@ public abstract class Task<T> {
|
||||
* @param executor the executor to use for asynchronous execution
|
||||
* @return the new Task
|
||||
*/
|
||||
public <E extends Exception> Task<Void> thenRun(Executor executor, ExceptionalRunnable<E> action) {
|
||||
return thenRun(getCaller(), executor, action);
|
||||
public <E extends Exception> Task<Void> thenRunAsync(Executor executor, ExceptionalRunnable<E> action) {
|
||||
return thenRunAsync(getCaller(), executor, action);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,8 +453,8 @@ public abstract class Task<T> {
|
||||
* @param executor the executor to use for asynchronous execution
|
||||
* @return the new Task
|
||||
*/
|
||||
public <E extends Exception> Task<Void> thenRun(String name, Executor executor, ExceptionalRunnable<E> action) {
|
||||
return thenApply(name, executor, ignore -> {
|
||||
public <E extends Exception> Task<Void> thenRunAsync(String name, Executor executor, ExceptionalRunnable<E> action) {
|
||||
return thenApplyAsync(name, executor, ignore -> {
|
||||
action.run();
|
||||
return null;
|
||||
});
|
||||
@@ -468,8 +468,8 @@ public abstract class Task<T> {
|
||||
* @param <U> the function's return type
|
||||
* @return the new Task
|
||||
*/
|
||||
public final <U> Task<U> thenSupply(Callable<U> fn) {
|
||||
return thenCompose(() -> Task.supplyAsync(fn));
|
||||
public final <U> Task<U> thenSupplyAsync(Callable<U> fn) {
|
||||
return thenComposeAsync(() -> Task.supplyAsync(fn));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -481,8 +481,8 @@ public abstract class Task<T> {
|
||||
* @param <U> the function's return type
|
||||
* @return the new Task
|
||||
*/
|
||||
public final <U> Task<U> thenSupply(String name, Callable<U> fn) {
|
||||
return thenCompose(() -> Task.supplyAsync(name, fn));
|
||||
public final <U> Task<U> thenSupplyAsync(String name, Callable<U> fn) {
|
||||
return thenComposeAsync(() -> Task.supplyAsync(name, fn));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -493,8 +493,8 @@ public abstract class Task<T> {
|
||||
* @param <U> the type of the returned Task's result
|
||||
* @return the Task
|
||||
*/
|
||||
public final <U> Task<U> thenCompose(Task<U> other) {
|
||||
return thenCompose(() -> other);
|
||||
public final <U> Task<U> thenComposeAsync(Task<U> other) {
|
||||
return thenComposeAsync(() -> other);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,7 +505,7 @@ public abstract class Task<T> {
|
||||
* @param <U> the type of the returned Task's result
|
||||
* @return the Task
|
||||
*/
|
||||
public final <U> Task<U> thenCompose(ExceptionalSupplier<Task<U>, ?> fn) {
|
||||
public final <U> Task<U> thenComposeAsync(ExceptionalSupplier<Task<U>, ?> fn) {
|
||||
return new UniCompose<>(fn, true);
|
||||
}
|
||||
|
||||
@@ -518,15 +518,15 @@ public abstract class Task<T> {
|
||||
* @param <U> the type of the returned Task's result
|
||||
* @return the Task
|
||||
*/
|
||||
public <U, E extends Exception> Task<U> thenCompose(ExceptionalFunction<T, Task<U>, E> fn) {
|
||||
public <U, E extends Exception> Task<U> thenComposeAsync(ExceptionalFunction<T, Task<U>, E> fn) {
|
||||
return new UniCompose<>(fn, true);
|
||||
}
|
||||
|
||||
public final <U> Task<U> withCompose(Task<U> other) {
|
||||
return withCompose(() -> other);
|
||||
public final <U> Task<U> withComposeAsync(Task<U> other) {
|
||||
return withComposeAsync(() -> other);
|
||||
}
|
||||
|
||||
public final <U, E extends Exception> Task<U> withCompose(ExceptionalSupplier<Task<U>, E> fn) {
|
||||
public final <U, E extends Exception> Task<U> withComposeAsync(ExceptionalSupplier<Task<U>, E> fn) {
|
||||
return new UniCompose<>(fn, false);
|
||||
}
|
||||
|
||||
@@ -538,8 +538,8 @@ public abstract class Task<T> {
|
||||
* returned Task
|
||||
* @return the new Task
|
||||
*/
|
||||
public <E extends Exception> Task<Void> withRun(ExceptionalRunnable<E> action) {
|
||||
return withRun(Schedulers.defaultScheduler(), action);
|
||||
public <E extends Exception> Task<Void> withRunAsync(ExceptionalRunnable<E> action) {
|
||||
return withRunAsync(Schedulers.defaultScheduler(), action);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -551,8 +551,8 @@ public abstract class Task<T> {
|
||||
* @param executor the executor to use for asynchronous execution
|
||||
* @return the new Task
|
||||
*/
|
||||
public <E extends Exception> Task<Void> withRun(Executor executor, ExceptionalRunnable<E> action) {
|
||||
return withRun(getCaller(), executor, action);
|
||||
public <E extends Exception> Task<Void> withRunAsync(Executor executor, ExceptionalRunnable<E> action) {
|
||||
return withRunAsync(getCaller(), executor, action);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -565,7 +565,7 @@ public abstract class Task<T> {
|
||||
* @param executor the executor to use for asynchronous execution
|
||||
* @return the new Task
|
||||
*/
|
||||
public <E extends Exception> Task<Void> withRun(String name, Executor executor, ExceptionalRunnable<E> action) {
|
||||
public <E extends Exception> Task<Void> withRunAsync(String name, Executor executor, ExceptionalRunnable<E> action) {
|
||||
return new UniCompose<>(() -> Task.runAsync(name, executor, action), false);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,7 @@ public class Pair<K, V> implements Map.Entry<K, V> {
|
||||
private K key;
|
||||
private V value;
|
||||
|
||||
@Deprecated
|
||||
public Pair(K key, V value) {
|
||||
private Pair(K key, V value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -66,8 +66,8 @@ public final class NetworkUtils {
|
||||
|
||||
/**
|
||||
* @see <a href="https://github.com/curl/curl/blob/3f7b1bb89f92c13e69ee51b710ac54f775aab320/lib/transfer.c#L1427-L1461">Curl</a>
|
||||
* @param location
|
||||
* @return
|
||||
* @param location the url to be URL encoded
|
||||
* @return encoded URL
|
||||
*/
|
||||
public static String encodeLocation(String location) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -93,11 +93,11 @@ public final class NetworkUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method aims to solve problem when "Location" in stupid server's response is not encoded.
|
||||
* This method is a work-around that aims to solve problem when "Location" in stupid server's response is not encoded.
|
||||
* @see <a href="https://github.com/curl/curl/issues/473">Issue with libcurl</a>
|
||||
* @param conn
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @param conn the stupid http connection.
|
||||
* @return manually redirected http connection.
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*/
|
||||
public static HttpURLConnection resolveConnection(HttpURLConnection conn) throws IOException {
|
||||
int redirect = 0;
|
||||
|
||||
@@ -37,7 +37,6 @@ import javafx.beans.value.ObservableValue;
|
||||
*/
|
||||
public abstract class BindingMapping<T, U> extends ObjectBinding<U> {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> BindingMapping<?, T> of(ObservableValue<T> property) {
|
||||
if (property instanceof BindingMapping) {
|
||||
return (BindingMapping<?, T>) property;
|
||||
|
||||
@@ -130,7 +130,7 @@ public final class ExtendedProperties {
|
||||
return (ObjectProperty<Boolean>) checkbox.getProperties().computeIfAbsent(
|
||||
PROP_PREFIX + ".checkbox.reservedSelected",
|
||||
any -> new MappedProperty<>(checkbox, "ext.reservedSelected",
|
||||
checkbox.selectedProperty(), it -> !(boolean) it, it -> !(boolean) it));
|
||||
checkbox.selectedProperty(), it -> !it, it -> !it));
|
||||
}
|
||||
// ====
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ public enum OperatingSystem {
|
||||
return Paths.get(home, "." + folder);
|
||||
case WINDOWS:
|
||||
String appdata = System.getenv("APPDATA");
|
||||
return Paths.get(Lang.nonNull(appdata, home), "." + folder);
|
||||
return Paths.get(appdata == null ? home : appdata, "." + folder);
|
||||
case OSX:
|
||||
return Paths.get(home, "Library", "Application Support", folder);
|
||||
default:
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -50,12 +49,12 @@ public class TaskTest {
|
||||
AtomicBoolean bool = new AtomicBoolean();
|
||||
boolean success = Task.supplyAsync(() -> {
|
||||
throw new IllegalStateException();
|
||||
}).withRun(() -> {
|
||||
}).withRunAsync(() -> {
|
||||
bool.set(true);
|
||||
}).test();
|
||||
|
||||
Assert.assertTrue("Task should success because withRun will ignore previous exception", success);
|
||||
Assert.assertTrue("withRun should be executed", bool.get());
|
||||
Assert.assertTrue("Task should success because withRunAsync will ignore previous exception", success);
|
||||
Assert.assertTrue("withRunAsync should be executed", bool.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,7 +62,7 @@ public class TaskTest {
|
||||
new JFXPanel(); // init JavaFX Toolkit
|
||||
AtomicBoolean flag = new AtomicBoolean();
|
||||
boolean result = Task.supplyAsync(JavaVersion::fromCurrentEnvironment)
|
||||
.thenAccept(Schedulers.javafx(), javaVersion -> {
|
||||
.thenAcceptAsync(Schedulers.javafx(), javaVersion -> {
|
||||
flag.set(true);
|
||||
Assert.assertEquals(javaVersion, JavaVersion.fromCurrentEnvironment());
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user