Class GsonUtils


  • public final class GsonUtils
    extends Object
    • Constructor Detail

      • GsonUtils

        public GsonUtils()
    • 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)
      • 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.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)
      • get

        public static <T> Optional<T> get​(com.google.gson.JsonObject obj,
                                          String key,
                                          Function<com.google.gson.JsonElement,​T> valFunc)