Reconstruct the codes.
This commit is contained in:
@@ -22,7 +22,7 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.jackhuang.hellominecraft.utils.functions.DoneListener0;
|
||||
import org.jackhuang.hellominecraft.utils.functions.NonConsumer;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,7 @@ import org.jackhuang.hellominecraft.HMCLog;
|
||||
public class TaskList extends Thread {
|
||||
|
||||
List<Task> taskQueue = Collections.synchronizedList(new ArrayList());
|
||||
ArrayList<DoneListener0> allDone = new ArrayList();
|
||||
ArrayList<NonConsumer> allDone = new ArrayList();
|
||||
ArrayList<DoingDoneListener<Task>> taskListener = new ArrayList();
|
||||
|
||||
int totTask = 0;
|
||||
@@ -47,7 +47,7 @@ public class TaskList extends Thread {
|
||||
taskQueue.clear();
|
||||
}
|
||||
|
||||
public void addAllDoneListener(DoneListener0 l) {
|
||||
public void addAllDoneListener(NonConsumer l) {
|
||||
allDone.add(l);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class TaskList extends Thread {
|
||||
for (Task taskQueue1 : taskQueue)
|
||||
executeTask(taskQueue1);
|
||||
if (shouldContinue)
|
||||
for (DoneListener0 d : allDone)
|
||||
for (NonConsumer d : allDone)
|
||||
d.onDone();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ package org.jackhuang.hellominecraft.tasks;
|
||||
import java.awt.EventQueue;
|
||||
import java.util.ArrayList;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.utils.functions.DoneListener0;
|
||||
import org.jackhuang.hellominecraft.utils.functions.NonConsumer;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.utils.MessageBox;
|
||||
import org.jackhuang.hellominecraft.utils.system.MessageBox;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
import org.jackhuang.hellominecraft.utils.SwingUtils;
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jackhuang.hellominecraft.utils.SwingUtils;
|
||||
* @author hyh
|
||||
*/
|
||||
public class TaskWindow extends javax.swing.JDialog
|
||||
implements ProgressProviderListener, DoneListener0, DoingDoneListener<Task> {
|
||||
implements ProgressProviderListener, NonConsumer, DoingDoneListener<Task> {
|
||||
|
||||
private static final TaskWindow instance = new TaskWindow();
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hyh
|
||||
*/
|
||||
public class Bytes {
|
||||
|
||||
public static String substring(String src, int start_idx, int end_idx) {
|
||||
byte[] b = src.getBytes();
|
||||
String tgt = "";
|
||||
for (int i = start_idx; i <= end_idx; i++) {
|
||||
tgt += (char) b[i];
|
||||
}
|
||||
return tgt;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils.tinystream;
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
|
||||
import org.jackhuang.hellominecraft.utils.functions.Consumer;
|
||||
import org.jackhuang.hellominecraft.utils.functions.Predicate;
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
* @param <T> EnumType
|
||||
*/
|
||||
public class EnumAdapter<T extends Enum> implements JsonSerializer<T>, JsonDeserializer<T> {
|
||||
T[] values;
|
||||
|
||||
public EnumAdapter(T[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(T src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return new JsonPrimitive(src.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
if(json.getAsInt() < values.length)
|
||||
return values[json.getAsInt()];
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
|
||||
import org.jackhuang.hellominecraft.utils.system.OS;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huang
|
||||
*/
|
||||
public class MD5Utils {
|
||||
|
||||
private static final char e[] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
'a', 'b', 'c', 'd', 'e', 'f'
|
||||
};
|
||||
|
||||
public static String hash(String type, String source) {
|
||||
try {
|
||||
StringBuilder stringbuilder;
|
||||
MessageDigest md = MessageDigest.getInstance(type);
|
||||
md.update(source.getBytes());
|
||||
byte[] bytes = md.digest();
|
||||
int s2 = bytes.length;
|
||||
stringbuilder = new StringBuilder(s2 << 1);
|
||||
for (int i1 = 0; i1 < s2; i1++) {
|
||||
stringbuilder.append(e[bytes[i1] >> 4 & 0xf]);
|
||||
stringbuilder.append(e[bytes[i1] & 0xf]);
|
||||
}
|
||||
|
||||
return stringbuilder.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
HMCLog.err("Failed to get md5", e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,15 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hyh
|
||||
* @param <K> K Type
|
||||
* @param <V> V Type
|
||||
*/
|
||||
public class Pair<K, V> {
|
||||
public class Pair<K, V> implements Map.Entry<K, V> {
|
||||
public K key;
|
||||
public V value;
|
||||
|
||||
@@ -28,5 +32,22 @@ public class Pair<K, V> {
|
||||
key = k;
|
||||
value = v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public K getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public V setValue(V value) {
|
||||
V t = this.value;
|
||||
this.value = value;
|
||||
return t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,15 @@ import java.util.StringTokenizer;
|
||||
*/
|
||||
public final class StrUtils {
|
||||
|
||||
public static String substring(String src, int start_idx, int end_idx) {
|
||||
byte[] b = src.getBytes();
|
||||
String tgt = "";
|
||||
for (int i = start_idx; i <= end_idx; i++) {
|
||||
tgt += (char) b[i];
|
||||
}
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static String makeCommand(List<String> cmd) {
|
||||
StringBuilder cmdbuf = new StringBuilder(120);
|
||||
for (int i = 0; i < cmd.size(); i++) {
|
||||
|
||||
@@ -16,8 +16,9 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
|
||||
import org.jackhuang.hellominecraft.utils.system.MessageBox;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.utils.functions.DoneListener0;
|
||||
import org.jackhuang.hellominecraft.utils.functions.NonConsumer;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
|
||||
/**
|
||||
@@ -29,9 +30,9 @@ public final class UpdateChecker extends Thread {
|
||||
public VersionNumber base;
|
||||
public String type;
|
||||
public boolean continueUpdate;
|
||||
public DoneListener0 dl;
|
||||
public NonConsumer dl;
|
||||
|
||||
public UpdateChecker(VersionNumber base, String type, boolean continueUpdate, DoneListener0 dl) {
|
||||
public UpdateChecker(VersionNumber base, String type, boolean continueUpdate, NonConsumer dl) {
|
||||
super("UpdateChecker");
|
||||
this.base = base;
|
||||
this.type = type;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
|
||||
import org.jackhuang.hellominecraft.utils.system.MessageBox;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import java.awt.Desktop;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
package org.jackhuang.hellominecraft.utils.code;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
package org.jackhuang.hellominecraft.utils.code;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
package org.jackhuang.hellominecraft.utils.code;
|
||||
|
||||
import org.jackhuang.hellominecraft.utils.code.Hex;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.MessageDigest;
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
package org.jackhuang.hellominecraft.utils.code;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
@@ -19,6 +19,6 @@ package org.jackhuang.hellominecraft.utils.functions;
|
||||
/**
|
||||
* @author hyh
|
||||
*/
|
||||
public interface DoneListener2<V, V2> {
|
||||
public interface BiConsumer<V, V2> {
|
||||
void onDone(V value, V2 value2);
|
||||
}
|
||||
@@ -20,7 +20,7 @@ package org.jackhuang.hellominecraft.utils.functions;
|
||||
*
|
||||
* @author hyh
|
||||
*/
|
||||
public class FalseDoneListener implements DoneListener0Return<Boolean> {
|
||||
public class FalseFunction implements NonFunction<Boolean> {
|
||||
|
||||
@Override
|
||||
public Boolean onDone() {
|
||||
@@ -20,6 +20,6 @@ package org.jackhuang.hellominecraft.utils.functions;
|
||||
*
|
||||
* @author hyh
|
||||
*/
|
||||
public interface DoneListener0 {
|
||||
public interface NonConsumer {
|
||||
void onDone();
|
||||
}
|
||||
@@ -20,6 +20,6 @@ package org.jackhuang.hellominecraft.utils.functions;
|
||||
*
|
||||
* @author hyh
|
||||
*/
|
||||
public interface DoneListener0Return<T> {
|
||||
public interface NonFunction<T> {
|
||||
T onDone();
|
||||
}
|
||||
@@ -20,6 +20,6 @@ package org.jackhuang.hellominecraft.utils.functions;
|
||||
*
|
||||
* @author hyh
|
||||
*/
|
||||
public interface DoneListener3<V1, V2, V3> {
|
||||
public interface TriConsumer<V1, V2, V3> {
|
||||
void onDone(V1 v1, V2 v2, V3 v3);
|
||||
}
|
||||
@@ -20,11 +20,11 @@ package org.jackhuang.hellominecraft.utils.functions;
|
||||
*
|
||||
* @author hyh
|
||||
*/
|
||||
public class TrueDoneListener implements DoneListener0Return<Boolean> {
|
||||
public class TrueFunction implements NonFunction<Boolean> {
|
||||
|
||||
public static final TrueDoneListener instance = new TrueDoneListener();
|
||||
public static final TrueFunction instance = new TrueFunction();
|
||||
|
||||
private TrueDoneListener(){}
|
||||
private TrueFunction(){}
|
||||
|
||||
@Override
|
||||
public Boolean onDone() {
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
package org.jackhuang.hellominecraft.utils.system;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
@@ -26,6 +26,8 @@ import java.io.InputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import org.jackhuang.hellominecraft.utils.IOUtils;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
|
||||
/**
|
||||
* 文件压缩/解压类
|
||||
@@ -14,8 +14,9 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
package org.jackhuang.hellominecraft.utils.system;
|
||||
|
||||
import org.jackhuang.hellominecraft.utils.system.ProcessManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -14,8 +14,9 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
package org.jackhuang.hellominecraft.utils.system;
|
||||
|
||||
import org.jackhuang.hellominecraft.utils.system.Platform;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -24,6 +25,8 @@ import java.io.InputStreamReader;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.utils.FileUtils;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
package org.jackhuang.hellominecraft.utils.system;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
package org.jackhuang.hellominecraft.utils.system;
|
||||
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
package org.jackhuang.hellominecraft.utils.system;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
package org.jackhuang.hellominecraft.utils.system;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -14,13 +14,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
package org.jackhuang.hellominecraft.utils.system;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import org.jackhuang.hellominecraft.HMCLog;
|
||||
import org.jackhuang.hellominecraft.utils.EventHandler;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils.tinystream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import org.jackhuang.hellominecraft.utils.functions.BiFunction;
|
||||
import org.jackhuang.hellominecraft.utils.functions.Consumer;
|
||||
import org.jackhuang.hellominecraft.utils.functions.Function;
|
||||
import org.jackhuang.hellominecraft.utils.functions.Predicate;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public class Stream<T> {
|
||||
|
||||
List<T> internal;
|
||||
|
||||
public Stream(Collection<T> internal) {
|
||||
this.internal = new ArrayList<>(internal);
|
||||
}
|
||||
|
||||
protected Stream() {
|
||||
}
|
||||
|
||||
protected static <T> Stream<T> noneCopyOf(List<T> a) {
|
||||
Stream<T> b = new Stream<>();
|
||||
b.internal = a;
|
||||
return b;
|
||||
}
|
||||
|
||||
protected static <T> Stream<T> of(Collection<T> a) {
|
||||
return new Stream<>(a);
|
||||
}
|
||||
|
||||
public Stream<T> forEach(Consumer<? super T> p) {
|
||||
for (T t : internal) p.accept(t);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Stream<T> filter(Predicate<? super T> p) {
|
||||
ArrayList<T> newList = new ArrayList<>();
|
||||
forEach(a -> {
|
||||
if (p.apply(a)) newList.add(a);
|
||||
});
|
||||
internal = newList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int count() {
|
||||
return internal.size();
|
||||
}
|
||||
|
||||
public Stream<T> distinct() {
|
||||
internal = new ArrayList<>(new HashSet<>(internal));
|
||||
return this;
|
||||
}
|
||||
|
||||
public <R> Stream<R> map(Function<? super T, ? extends R> func) {
|
||||
List<R> newList = new ArrayList<>(internal.size());
|
||||
forEach(a -> newList.add(func.apply(a)));
|
||||
return of(newList);
|
||||
}
|
||||
|
||||
public Stream<T> sorted(Comparator<? super T> c) {
|
||||
Collections.sort(internal, c);
|
||||
return this;
|
||||
}
|
||||
|
||||
public <U> U reduce(U identity, BiFunction<U, T, U> accumulator) {
|
||||
for (T t : internal) identity = accumulator.apply(identity, t);
|
||||
return identity;
|
||||
}
|
||||
|
||||
public boolean anyMatch(Predicate<? super T> p) {
|
||||
return map(t -> p.apply(t)).<Boolean>reduce(false, (a, b) -> a | b);
|
||||
}
|
||||
|
||||
public boolean allMatch(Predicate<? super T> p) {
|
||||
return map(t -> p.apply(t)).<Boolean>reduce(true, (a, b) -> a & b);
|
||||
}
|
||||
|
||||
public T findFirst() {
|
||||
return internal.isEmpty() ? null : internal.get(0);
|
||||
}
|
||||
|
||||
public Stream<T> skip(int c) {
|
||||
internal = internal.subList(c+1, internal.size());
|
||||
return this;
|
||||
}
|
||||
|
||||
public Stream<T> limit(int c) {
|
||||
internal = internal.subList(0, c);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program.
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils;
|
||||
package org.jackhuang.hellominecraft.version;
|
||||
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.jackhuang.hellominecraft.views;
|
||||
|
||||
import org.jackhuang.hellominecraft.C;
|
||||
import org.jackhuang.hellominecraft.utils.functions.DoneListener0;
|
||||
import org.jackhuang.hellominecraft.utils.functions.DoneListener0Return;
|
||||
import org.jackhuang.hellominecraft.utils.functions.NonConsumer;
|
||||
import org.jackhuang.hellominecraft.utils.functions.NonFunction;
|
||||
import org.jackhuang.hellominecraft.utils.DoubleOutputStream;
|
||||
import org.jackhuang.hellominecraft.utils.LauncherPrintStream;
|
||||
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||
@@ -32,8 +32,8 @@ import org.jackhuang.hellominecraft.utils.Utils;
|
||||
public class LogWindow extends javax.swing.JFrame {
|
||||
|
||||
boolean movingEnd;
|
||||
DoneListener0Return<Boolean> listener;
|
||||
DoneListener0 terminateGameListener;
|
||||
NonFunction<Boolean> listener;
|
||||
NonConsumer terminateGameListener;
|
||||
|
||||
/**
|
||||
* Creates new form LogWindow
|
||||
@@ -250,11 +250,11 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
log(StrUtils.getStackTrace(t));
|
||||
}
|
||||
|
||||
public void setExit(DoneListener0Return<Boolean> exit) {
|
||||
public void setExit(NonFunction<Boolean> exit) {
|
||||
this.listener = exit;
|
||||
}
|
||||
|
||||
public void setTerminateGame(DoneListener0 l) {
|
||||
public void setTerminateGame(NonConsumer l) {
|
||||
this.terminateGameListener = l;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user