diff --git a/li.strolch.model/src/main/java/li/strolch/model/GroupedParameterizedElement.java b/li.strolch.model/src/main/java/li/strolch/model/GroupedParameterizedElement.java index 2d9a405f6..be86b52da 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/GroupedParameterizedElement.java +++ b/li.strolch.model/src/main/java/li/strolch/model/GroupedParameterizedElement.java @@ -275,6 +275,17 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement defaultBag().setString(paramKey, value); } + @Override + public void setString(String paramKey, Enum value) throws StrolchModelException { + defaultBag().setString(paramKey, value.name()); + } + + @Override + public void setString(String bagKey, String paramKey, Enum value) throws StrolchModelException { + ParameterBag bag = getParameterBag(bagKey, true); + bag.setString(paramKey, value.name()); + } + @Override public void setString(String bagKey, String paramKey, String value) throws StrolchModelException { ParameterBag bag = getParameterBag(bagKey, true); diff --git a/li.strolch.model/src/main/java/li/strolch/model/ParameterBagContainer.java b/li.strolch.model/src/main/java/li/strolch/model/ParameterBagContainer.java index 228ac2770..990bdd2cb 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/ParameterBagContainer.java +++ b/li.strolch.model/src/main/java/li/strolch/model/ParameterBagContainer.java @@ -423,6 +423,20 @@ public interface ParameterBagContainer extends StrolchElement { */ void setString(String paramKey, String value) throws StrolchModelException; + /** + * Sets the given enum's name value on the {@link StringParameter} with the given paramKey on the {@link + * ParameterBag} with the ID {@link StrolchModelConstants#BAG_PARAMETERS} + * + * @param paramKey + * the key of the parameter for which to return the value + * @param value + * the value to set on the parameter + * + * @throws StrolchModelException + * if the parameter does not exist + */ + void setString(String paramKey, Enum value) throws StrolchModelException; + /** * Sets the given value on the {@link StringParameter} with the given paramKey on the {@link ParameterBag} with the * given bagKey @@ -439,6 +453,22 @@ public interface ParameterBagContainer extends StrolchElement { */ void setString(String bagKey, String paramKey, String value) throws StrolchModelException; + /** + * Sets the given enum's name value on the {@link StringParameter} with the given paramKey on the {@link + * ParameterBag} with the given bagKey + * + * @param bagKey + * the key from which {@link ParameterBag} to get the parameter + * @param paramKey + * the key of the parameter for which to return the value + * @param value + * the value to set on the parameter + * + * @throws StrolchModelException + * if the parameter does not exist + */ + void setString(String bagKey, String paramKey, Enum value) throws StrolchModelException; + /** * Sets the given value on the {@link BooleanParameter} with the given paramKey on the {@link ParameterBag} with the * ID {@link StrolchModelConstants#BAG_PARAMETERS} diff --git a/li.strolch.model/src/main/java/li/strolch/model/ParameterizedElement.java b/li.strolch.model/src/main/java/li/strolch/model/ParameterizedElement.java index d09246584..e2913c620 100644 --- a/li.strolch.model/src/main/java/li/strolch/model/ParameterizedElement.java +++ b/li.strolch.model/src/main/java/li/strolch/model/ParameterizedElement.java @@ -344,6 +344,25 @@ public abstract class ParameterizedElement extends AbstractStrolchElement { param.setValue(value); } + /** + * Sets the given enum's name value on the {@link StringParameter} with the given paramKey + * + * @param paramKey + * the key of the parameter for which to return the value + * @param value + * the value to set on the parameter + * + * @throws StrolchModelException + * if the parameter does not exist + */ + public void setString(String paramKey, Enum value) throws StrolchModelException { + StringParameter param = getParameter(paramKey, false); + if (param == null) + addParameter(new StringParameter(paramKey, paramKey, value)); + else + param.setValue(value.name()); + } + /** * Sets the given value on the {@link BooleanParameter} with the given paramKey *