perf: 优化代码
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
package cn.hamster3.mc.plugin.core.common.util;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class CaseUtils {
|
||||
private CaseUtils() {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T caseObject(Object o) {
|
||||
return (T) o;
|
||||
}
|
||||
}
|
@@ -8,7 +8,6 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@@ -65,7 +64,8 @@ public final class CommonUtils {
|
||||
*/
|
||||
@NotNull
|
||||
public static String replaceColorCode(@Nullable String string, @NotNull String defaultValue) {
|
||||
return replaceColorCode(Objects.requireNonNullElse(string, defaultValue));
|
||||
if (string == null) return defaultValue;
|
||||
return string.replace("&", "§");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,5 +171,9 @@ public final class CommonUtils {
|
||||
return list;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T caseObject(Object o) {
|
||||
return (T) o;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,52 +0,0 @@
|
||||
package cn.hamster3.mc.plugin.core.common.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>A convenience class to represent name-value pairs.</p>
|
||||
*/
|
||||
@SuppressWarnings({"unused", "ClassCanBeRecord"})
|
||||
public class Pair<K, V> implements Serializable {
|
||||
/**
|
||||
* Key of this <code>Pair</code>.
|
||||
*/
|
||||
@NotNull
|
||||
private final K key;
|
||||
|
||||
/**
|
||||
* Value of this <code>Pair</code>.
|
||||
*/
|
||||
@NotNull
|
||||
private final V value;
|
||||
|
||||
public Pair(@NotNull K key, @NotNull V value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public K getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public V getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Pair<?, ?> pair = (Pair<?, ?>) o;
|
||||
return key.equals(pair.key) && value.equals(pair.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(key, value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user