package io.gitlab.jfronny.respackopts; import io.gitlab.jfronny.gson.*; import io.gitlab.jfronny.muscript.compiler.expr.*; import io.gitlab.jfronny.respackopts.gson.*; import io.gitlab.jfronny.respackopts.gson.entry.*; import io.gitlab.jfronny.respackopts.model.tree.*; public class TemplateTree { private static final Gson GSON = new GsonBuilder() .registerTypeAdapter(ConfigEnumEntry.class, new EnumEntrySerializer()) .registerTypeAdapter(ConfigNumericEntry.class, new NumericEntrySerializer()) .registerTypeAdapter(ConfigBooleanEntry.class, new BooleanEntrySerializer()) .registerTypeAdapter(ConfigBranch.class, new ConfigBranchSerializer()) .registerTypeAdapter(Expr.class, new ExprDeserializer()) .registerTypeAdapter(StringExpr.class, new StringExprDeserializer()) .registerTypeAdapter(BoolExpr.class, new BoolExprDeserializer()) .setLenient() .setPrettyPrinting() .create(); public static ConfigBranch getBranch() { return GSON.fromJson(""" { "boolean": true, "boolean2": false, "number1": 0, "number2": 0.5, "number3": { "type": "slider", "default": 2, "min": 0, "max": 4 }, "enum": [ "enum1", "enum2", "enum3" ], "subBranch": { "boolean3": true, "boolean4": false } } """, ConfigBranch.class); } }