51 lines
1.9 KiB
Java
51 lines
1.9 KiB
Java
package io.gitlab.jfronny.respackopts.test;
|
|
|
|
import io.gitlab.jfronny.gson.Gson;
|
|
import io.gitlab.jfronny.gson.GsonBuilder;
|
|
import io.gitlab.jfronny.muscript.ast.*;
|
|
import io.gitlab.jfronny.respackopts.gson.*;
|
|
import io.gitlab.jfronny.respackopts.gson.entry.*;
|
|
import io.gitlab.jfronny.respackopts.model.Condition;
|
|
import io.gitlab.jfronny.respackopts.model.tree.*;
|
|
|
|
public class TestArgs {
|
|
public 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())
|
|
.registerTypeAdapter(Condition.class, new ConditionDeserializer())
|
|
.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);
|
|
}
|
|
}
|