Class GsonUtils
java.lang.Object
org.spongepowered.plugin.metadata.util.GsonUtils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
applyIfValid
(JsonObject obj, T value, Predicate<T> validator, BiConsumer<JsonObject, T> consumer) static <T extends JsonElement>
voidconsumeIfPresent
(JsonObject obj, String key, Consumer<T> consumer) static <T> Optional<T>
get
(JsonObject obj, String key, Function<JsonElement, T> valFunc) static <T,
V extends Collection<T>>
Vread
(JsonArray in, TypeAdapter<T> adapter, Supplier<V> collector) read
(JsonObject in, Function<JsonElement, Object> valFunc, Supplier<Map<String, Object>> collector) static <T> JsonArray
write
(TypeAdapter<T> adapter, Collection<T> value) static JsonObject
static <T> void
writeIfPresent
(JsonObject out, String key, Optional<T> value) static <T> void
writeIfPresent
(JsonWriter out, String name, Optional<T> value)
-
Constructor Details
-
GsonUtils
public GsonUtils()
-
-
Method Details
-
read
public static <T,V extends Collection<T>> V read(JsonArray in, TypeAdapter<T> adapter, Supplier<V> collector) -
read
-
write
-
write
-
writeIfPresent
public static <T> void writeIfPresent(JsonWriter out, String name, Optional<T> value) throws IOException - Throws:
IOException
-
writeIfPresent
-
consumeIfPresent
public static <T extends JsonElement> void consumeIfPresent(JsonObject obj, String key, Consumer<T> consumer) -
applyIfValid
public static <T> void applyIfValid(JsonObject obj, T value, Predicate<T> validator, BiConsumer<JsonObject, T> consumer) -
get
-