clear
This commit is contained in:
parent
e96dd55395
commit
3ac2c5cd1c
|
@ -19,7 +19,7 @@ package com.tungsten.fcl.util;
|
|||
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ResourceNotFoundError extends Error {
|
||||
public final class ResourceNotFoundError extends Error {
|
||||
public ResourceNotFoundError(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import com.tungsten.fcl.ui.TaskDialog;
|
|||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class TaskCancellationAction {
|
||||
public final class TaskCancellationAction {
|
||||
public static TaskCancellationAction NORMAL = new TaskCancellationAction(() -> {
|
||||
});
|
||||
|
||||
|
|
|
@ -17,11 +17,26 @@
|
|||
*/
|
||||
package com.tungsten.fclcore.util;
|
||||
|
||||
import com.tungsten.fclcore.fakefx.beans.InvalidationListener;
|
||||
import com.tungsten.fclcore.fakefx.beans.Observable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public final class Holder<T> {
|
||||
public final class Holder<T> implements InvalidationListener {
|
||||
public T value;
|
||||
|
||||
public Holder() {
|
||||
}
|
||||
|
||||
public Holder(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidated(Observable observable) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(value);
|
||||
|
|
|
@ -17,13 +17,12 @@
|
|||
*/
|
||||
package com.tungsten.fclcore.util;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class InvocationDispatcher<ARG> implements Consumer<ARG> {
|
||||
public final class InvocationDispatcher<ARG> implements Consumer<ARG> {
|
||||
|
||||
public static <ARG> InvocationDispatcher<ARG> runOn(Executor executor, Consumer<ARG> action) {
|
||||
return new InvocationDispatcher<>(arg -> executor.execute(() -> {
|
||||
|
@ -33,9 +32,8 @@ public class InvocationDispatcher<ARG> implements Consumer<ARG> {
|
|||
}));
|
||||
}
|
||||
|
||||
private Consumer<Supplier<ARG>> handler;
|
||||
|
||||
private AtomicReference<Optional<ARG>> pendingArg = new AtomicReference<>();
|
||||
private final Consumer<Supplier<ARG>> handler;
|
||||
private final AtomicReference<Holder<ARG>> pendingArg = new AtomicReference<>();
|
||||
|
||||
public InvocationDispatcher(Consumer<Supplier<ARG>> handler) {
|
||||
this.handler = handler;
|
||||
|
@ -43,8 +41,8 @@ public class InvocationDispatcher<ARG> implements Consumer<ARG> {
|
|||
|
||||
@Override
|
||||
public void accept(ARG arg) {
|
||||
if (pendingArg.getAndSet(Optional.ofNullable(arg)) == null) {
|
||||
handler.accept(() -> pendingArg.getAndSet(null).orElse(null));
|
||||
if (pendingArg.getAndSet(new Holder<>(arg)) == null) {
|
||||
handler.accept(() -> pendingArg.getAndSet(null).value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -404,7 +404,7 @@ public final class StringUtils {
|
|||
/**
|
||||
* Class for computing the longest common subsequence between strings.
|
||||
*/
|
||||
public static class LongestCommonSubsequence {
|
||||
public static final class LongestCommonSubsequence {
|
||||
// We reuse dynamic programming storage array here to reduce allocations.
|
||||
private final int[][] f;
|
||||
private final int maxLengthA;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
package com.tungsten.fclcore.util;
|
||||
|
||||
public class ToStringBuilder {
|
||||
public final class ToStringBuilder {
|
||||
|
||||
private final StringBuilder stringBuilder;
|
||||
private boolean first = true;
|
||||
|
|
|
@ -27,9 +27,9 @@ import java.lang.reflect.Type;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class EnumOrdinalDeserializer<T extends Enum<T>> implements JsonDeserializer<T> {
|
||||
public final class EnumOrdinalDeserializer<T extends Enum<T>> implements JsonDeserializer<T> {
|
||||
|
||||
private Map<String, T> mapping = new HashMap<>();
|
||||
private final Map<String, T> mapping = new HashMap<>();
|
||||
|
||||
public EnumOrdinalDeserializer(Class<T> enumClass) {
|
||||
for (T constant : enumClass.getEnumConstants()) {
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Map;
|
|||
* @param <K>
|
||||
* @param <V>
|
||||
*/
|
||||
public class JsonMap<K, V> extends HashMap<K, V> {
|
||||
public final class JsonMap<K, V> extends HashMap<K, V> {
|
||||
public JsonMap(int initialCapacity, float loadFactor) {
|
||||
super(initialCapacity, loadFactor);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class JsonTypeAdapterFactory implements TypeAdapterFactory {
|
||||
public final class JsonTypeAdapterFactory implements TypeAdapterFactory {
|
||||
|
||||
public static final JsonTypeAdapterFactory INSTANCE = new JsonTypeAdapterFactory();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import com.tungsten.fclcore.util.DigestUtils;
|
|||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ChecksumMismatchException extends ArtifactMalformedException {
|
||||
public final class ChecksumMismatchException extends ArtifactMalformedException {
|
||||
|
||||
private final String algorithm;
|
||||
private final String expectedChecksum;
|
||||
|
|
|
@ -26,8 +26,8 @@ import java.net.HttpURLConnection;
|
|||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
public class HttpMultipartRequest implements Closeable {
|
||||
private static final String endl = "\r\n";
|
||||
public final class HttpMultipartRequest implements Closeable {
|
||||
private static final byte[] ENDL = {'\r', '\n'};
|
||||
|
||||
private final String boundary = "*****" + System.currentTimeMillis() + "*****";
|
||||
private final HttpURLConnection urlConnection;
|
||||
|
@ -44,7 +44,7 @@ public class HttpMultipartRequest implements Closeable {
|
|||
|
||||
private void addLine(String content) throws IOException {
|
||||
stream.write(content.getBytes(UTF_8));
|
||||
stream.write(endl.getBytes(UTF_8));
|
||||
stream.write(ENDL);
|
||||
}
|
||||
|
||||
public HttpMultipartRequest file(String name, String filename, String contentType, InputStream inputStream) throws IOException {
|
||||
|
|
|
@ -20,7 +20,7 @@ package com.tungsten.fclcore.util.io;
|
|||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
public class ResponseCodeException extends IOException {
|
||||
public final class ResponseCodeException extends IOException {
|
||||
|
||||
private final URL url;
|
||||
private final int responseCode;
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
public class Unzipper {
|
||||
public final class Unzipper {
|
||||
private final Path zipFile, dest;
|
||||
private boolean replaceExistentFile = false;
|
||||
private boolean terminateIfSubDirectoryNotExists = false;
|
||||
|
|
|
@ -23,7 +23,7 @@ import android.graphics.Bitmap;
|
|||
* Describes a Minecraft 1.8+ skin (64x64).
|
||||
* Old format skins are converted to the new format.
|
||||
*/
|
||||
public class NormalizedSkin {
|
||||
public final class NormalizedSkin {
|
||||
|
||||
private static void copyImage(Bitmap src, Bitmap dst, int sx, int sy, int dx, int dy, int w, int h, boolean flipHorizontal) {
|
||||
for (int y = 0; y < h; y++) {
|
||||
|
|
Loading…
Reference in New Issue