Class GsonUtils
- java.lang.Object
-
- org.spongepowered.plugin.metadata.util.GsonUtils
-
public final class GsonUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description GsonUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> voidapplyIfValid(com.google.gson.JsonObject obj, T value, Predicate<T> validator, BiConsumer<com.google.gson.JsonObject,T> consumer)static <T extends com.google.gson.JsonElement>
voidconsumeIfPresent(com.google.gson.JsonObject obj, String key, Consumer<T> consumer)static <T> Optional<T>get(com.google.gson.JsonObject obj, String key, Function<com.google.gson.JsonElement,T> valFunc)static <T,V extends Collection<T>>
Vread(com.google.gson.JsonArray in, com.google.gson.TypeAdapter<T> adapter, Supplier<V> collector)static Map<String,Object>read(com.google.gson.JsonObject in, Function<com.google.gson.JsonElement,Object> valFunc, Supplier<Map<String,Object>> collector)static <T> com.google.gson.JsonArraywrite(com.google.gson.TypeAdapter<T> adapter, Collection<T> value)static com.google.gson.JsonObjectwrite(Function<Object,com.google.gson.JsonElement> valFunc, Map<String,Object> value)static <T> voidwriteIfPresent(com.google.gson.JsonObject out, String key, Optional<T> value)static <T> voidwriteIfPresent(com.google.gson.stream.JsonWriter out, String name, Optional<T> value)
-
-
-
Method Detail
-
read
public static <T,V extends Collection<T>> V read(com.google.gson.JsonArray in, com.google.gson.TypeAdapter<T> adapter, Supplier<V> collector)
-
read
public static Map<String,Object> read(com.google.gson.JsonObject in, Function<com.google.gson.JsonElement,Object> valFunc, Supplier<Map<String,Object>> collector)
-
write
public static <T> com.google.gson.JsonArray write(com.google.gson.TypeAdapter<T> adapter, Collection<T> value)
-
write
public static com.google.gson.JsonObject write(Function<Object,com.google.gson.JsonElement> valFunc, Map<String,Object> value)
-
writeIfPresent
public static <T> void writeIfPresent(com.google.gson.stream.JsonWriter out, String name, Optional<T> value) throws IOException- Throws:
IOException
-
writeIfPresent
public static <T> void writeIfPresent(com.google.gson.JsonObject out, String key, Optional<T> value)
-
consumeIfPresent
public static <T extends com.google.gson.JsonElement> void consumeIfPresent(com.google.gson.JsonObject obj, String key, Consumer<T> consumer)
-
applyIfValid
public static <T> void applyIfValid(com.google.gson.JsonObject obj, T value, Predicate<T> validator, BiConsumer<com.google.gson.JsonObject,T> consumer)
-
-