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 ca047b481..1f2d8b674 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 @@ -140,6 +140,24 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement return parameter; } + /** + * Returns a list of all the {@link Parameter Parameters} with the given interpretation + * + * @param bagKey + * the key of the {@link ParameterBag} from which the {@link Parameter} is to be returned + * @param interpretation + * the interpretation for which the parameters are to be returned + * + * @return the parameters with the given interpretation + */ + public List> getParametersByInterpretation(String bagKey, String interpretation) { + ParameterBag bag = getParameterBag(bagKey); + if (bag == null) + return Collections.emptyList(); + + return bag.getParametersByInterpretation(interpretation); + } + /** * Adds a new {@link Parameter} to the {@link ParameterBag} with the given key * 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 f8274c4ff..39e3ffbf9 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 @@ -23,6 +23,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import li.strolch.exception.StrolchException; import li.strolch.exception.StrolchModelException; @@ -172,6 +173,23 @@ public abstract class ParameterizedElement extends AbstractStrolchElement { return new ArrayList<>(this.parameterMap.values()); } + /** + * Returns a list of all the {@link Parameter Parameters} with the given interpretation + * + * @param interpretation + * the interpretation for which the parameters are to be returned + * + * @return the parameters with the given interpretation + */ + public List> getParametersByInterpretation(String interpretation) { + if (this.parameterMap == null) { + return Collections.emptyList(); + } + + return this.parameterMap.values().stream().filter(p -> p.getInterpretation().equals(interpretation)) + .collect(Collectors.toList()); + } + /** * Returns true, if the this {@link ParameterizedElement} has any {@link Parameter Parameters}, false otherwise *