diff --git a/li.strolch.model/src/main/java/li/strolch/model/StrolchRootElement.java b/li.strolch.model/src/main/java/li/strolch/model/StrolchRootElement.java index 3ada789d2..4c4161f77 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/StrolchRootElement.java +++ b/li.strolch.model/src/main/java/li/strolch/model/StrolchRootElement.java @@ -15,8 +15,7 @@ */ package li.strolch.model; -import static li.strolch.model.StrolchModelConstants.INTERPRETATION_NONE; -import static li.strolch.model.StrolchModelConstants.UOM_NONE; +import static li.strolch.model.StrolchModelConstants.*; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -207,6 +206,28 @@ public interface StrolchRootElement extends StrolchElement, PolicyContainer, Par return this.getClass() == Activity.class; } + /** + * Set or add a parameter to this element from a {@link JsonObject} to the {@link ParameterBag} with the id + * {StrolchModelConstants#BAG_PARAMETERS} + * + * @param jsonObject + * the object from which to get the value + * @param paramId + * the ID of the parameter on which to set the value, and also the Json reference ID + * @param paramName + * the name of the parameter, if the parameter is to be created + * @param type + * the type of Parameter to create + * @param ignoreOnEmpty + * if true, and the json object is missing the field, then the parameter is not changed, otherwise the parameter + * is cleared if the json field is missing or null + */ + default void setOrAddParamFromFlatJson(JsonObject jsonObject, String paramId, String paramName, + StrolchValueType type, boolean ignoreOnEmpty) { + setOrAddParamFromFlatJson(jsonObject, BAG_PARAMETERS, TYPE_PARAMETERS, TYPE_PARAMETERS, paramId, paramName, + INTERPRETATION_NONE, UOM_NONE, type, ignoreOnEmpty); + } + /** * Set or add a parameter to this element from a {@link JsonObject} *