Class GsonUtil

java.lang.Object
net.jacobpeterson.jet.openapiannotationsplugin.gson.GsonUtil

@NullMarked public final class GsonUtil extends Object
GsonUtil is a utility class for Gson.
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.google.gson.JsonElement
    combine(com.google.gson.JsonElement a, com.google.gson.JsonElement b)
    Recursively combines the given a JsonObject or JsonArray with the given b JsonObject or JsonArray into a new JsonObject or JsonArray.
    static void
    walk(com.google.gson.JsonElement root, Function<LinkedList<Map.Entry<String, com.google.gson.JsonElement>>, Boolean> walker)
    Recursively walks the given JsonElement tree.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • combine

      public static com.google.gson.JsonElement combine(com.google.gson.JsonElement a, com.google.gson.JsonElement b) throws IllegalArgumentException
      Recursively combines the given a JsonObject or JsonArray with the given b JsonObject or JsonArray into a new JsonObject or JsonArray.
      Parameters:
      a - a JsonElement
      b - a JsonElement
      Returns:
      the combined JsonElement
      Throws:
      IllegalArgumentException - thrown for illegal combinations (e.g. duplicate keys with JsonPrimitive values, or if a is a JsonArray and b is a JsonObject)
    • walk

      public static void walk(com.google.gson.JsonElement root, Function<LinkedList<Map.Entry<String, com.google.gson.JsonElement>>, Boolean> walker)
      Recursively walks the given JsonElement tree.
      Parameters:
      root - the root JsonElement
      walker - the walker Function that receives the current tree stack and returns a boolean of whether to walk the entry at the top of the stack