[New] Added ParameterBagContainer.isRelationEmpty() and cleanup

This commit is contained in:
Robert von Burg 2022-07-07 12:09:01 +02:00
parent 76ca062cb7
commit a4aaedf4ed
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
2 changed files with 25 additions and 32 deletions

View File

@ -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)

View File

@ -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