Class GsonUtil
java.lang.Object
net.jacobpeterson.jet.openapiannotationsplugin.gson.GsonUtil
GsonUtil is a utility class for Gson.-
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.gson.JsonElementcombine(com.google.gson.JsonElement a, com.google.gson.JsonElement b) Recursively combines the givenaJsonObjectorJsonArraywith the givenbJsonObjectorJsonArrayinto a newJsonObjectorJsonArray.static voidwalk(com.google.gson.JsonElement root, Function<LinkedList<Map.Entry<String, com.google.gson.JsonElement>>, Boolean> walker) Recursively walks the givenJsonElementtree.
-
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 givenaJsonObjectorJsonArraywith the givenbJsonObjectorJsonArrayinto a newJsonObjectorJsonArray.- Parameters:
a- aJsonElementb- aJsonElement- Returns:
- the combined
JsonElement - Throws:
IllegalArgumentException- thrown for illegal combinations (e.g. duplicate keys withJsonPrimitivevalues, or ifais aJsonArrayandbis aJsonObject)
-
walk
public static void walk(com.google.gson.JsonElement root, Function<LinkedList<Map.Entry<String, com.google.gson.JsonElement>>, Boolean> walker) Recursively walks the givenJsonElementtree.- Parameters:
root- the rootJsonElementwalker- the walkerFunctionthat receives the current tree stack and returns abooleanof whether to walk the entry at the top of the stack
-