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 b5551e54e..5ad334f68 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 @@ -261,35 +261,6 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement return this.parameterBagMap != null && this.parameterBagMap.containsKey(bagKey); } - @Override - public boolean hasParameter(String paramKey) { - if (this.parameterBagMap == null) - return false; - ParameterBag bag = this.parameterBagMap.get(BAG_PARAMETERS); - return bag != null && bag.hasParameter(paramKey); - } - - @Override - public boolean hasRelation(String paramKey) { - if (this.parameterBagMap == null) - return false; - ParameterBag bag = this.parameterBagMap.get(BAG_RELATIONS); - if (bag == null) - return false; - return bag.hasParameter(paramKey); - } - - @Override - public boolean isRelationSet(String paramKey) { - if (this.parameterBagMap == null) - return false; - ParameterBag bag = this.parameterBagMap.get(BAG_RELATIONS); - if (bag == null) - return false; - StringParameter relationP = bag.getParameter(paramKey); - return relationP != null && relationP.isSet(); - } - @Override public boolean hasParameter(String bagKey, String paramKey) { if (this.parameterBagMap == null) 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 175f4de42..175c049ba 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 @@ -2051,7 +2051,9 @@ public interface ParameterBagContainer extends StrolchElement { * bagKey. False is returned if the {@link ParameterBag} does not exist, or the {@link Parameter} does not exist on * the {@link ParameterBag} */ - boolean hasParameter(String paramKey); + default boolean hasParameter(String paramKey) { + return hasParameter(BAG_PARAMETERS, paramKey); + } /** * Returns true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the id @@ -2064,7 +2066,9 @@ public interface ParameterBagContainer extends StrolchElement { * bagKey. False is returned if the {@link ParameterBag} does not exist, or the {@link Parameter} does not exist on * the {@link ParameterBag} */ - boolean hasRelation(String paramKey); + default boolean hasRelation(String paramKey) { + return hasParameter(BAG_RELATIONS, paramKey); + } /** * Returns true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the id @@ -2077,7 +2081,25 @@ public interface ParameterBagContainer extends StrolchElement { * bagKey and the value of the parameter is also set, i.e. not empty. False is returned if the {@link ParameterBag} does not exist, the {@link Parameter} does not exist on * the {@link ParameterBag}, or the value of the parameter is empty */ - boolean isRelationSet(String paramKey); + default boolean isRelationSet(String paramKey) { + StringParameter relationP = getParameter(BAG_RELATIONS, paramKey); + return relationP != null && relationP.isSet(); + } + + /** + * Returns true if the {@link Parameter} with the given paramKey does not exist on the {@link ParameterBag} with the id + * {@link StrolchModelConstants#BAG_RELATIONS} or if the value of the parameter is empty + * + * @param paramKey + * the key of the {@link Parameter} to be found + * + * @return true if the {@link Parameter} with the given paramKey does not exist on the {@link ParameterBag} with the id + * {@link StrolchModelConstants#BAG_RELATIONS} or if the value of the parameter is empty + */ + default boolean isRelationEmpty(String paramKey) { + StringParameter relationP = getParameter(BAG_RELATIONS, paramKey); + return relationP == null || relationP.isEmpty(); + } /** * Returns true if the {@link Parameter} with the given paramKey exists on the {@link ParameterBag} with the given