mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-17 01:15:52 +01:00
Run IntelliJ IDEA code formatter
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
package emu.grasscutter.utils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import emu.grasscutter.data.common.DynamicFloat;
|
||||
import emu.grasscutter.utils.JsonAdapters.DynamicFloatAdapter;
|
||||
import emu.grasscutter.utils.JsonAdapters.EnumTypeAdapterFactory;
|
||||
import emu.grasscutter.utils.JsonAdapters.IntListAdapter;
|
||||
import emu.grasscutter.utils.JsonAdapters.PositionAdapter;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -11,17 +23,6 @@ import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import emu.grasscutter.data.common.DynamicFloat;
|
||||
import emu.grasscutter.utils.JsonAdapters.*;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
|
||||
public final class JsonUtils {
|
||||
static final Gson gson = new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
@@ -76,18 +77,18 @@ public final class JsonUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T1,T2> Map<T1,T2> loadToMap(Reader fileReader, Class<T1> keyType, Class<T2> valueType) throws IOException {
|
||||
public static <T1, T2> Map<T1, T2> loadToMap(Reader fileReader, Class<T1> keyType, Class<T2> valueType) throws IOException {
|
||||
return gson.fromJson(fileReader, TypeToken.getParameterized(Map.class, keyType, valueType).getType());
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static <T1,T2> Map<T1,T2> loadToMap(String filename, Class<T1> keyType, Class<T2> valueType) throws IOException {
|
||||
public static <T1, T2> Map<T1, T2> loadToMap(String filename, Class<T1> keyType, Class<T2> valueType) throws IOException {
|
||||
try (InputStreamReader fileReader = new InputStreamReader(new FileInputStream(Utils.toFilePath(filename)), StandardCharsets.UTF_8)) {
|
||||
return loadToMap(fileReader, keyType, valueType);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T1,T2> Map<T1,T2> loadToMap(Path filename, Class<T1> keyType, Class<T2> valueType) throws IOException {
|
||||
public static <T1, T2> Map<T1, T2> loadToMap(Path filename, Class<T1> keyType, Class<T2> valueType) throws IOException {
|
||||
try (var fileReader = Files.newBufferedReader(filename, StandardCharsets.UTF_8)) {
|
||||
return loadToMap(fileReader, keyType, valueType);
|
||||
}
|
||||
@@ -95,6 +96,7 @@ public final class JsonUtils {
|
||||
|
||||
/**
|
||||
* Safely JSON decodes a given string.
|
||||
*
|
||||
* @param jsonData The JSON-encoded data.
|
||||
* @return JSON decoded data, or null if an exception occurred.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user