From 648a47890c7aced58c27a7db78e4c5b43dbf6c88 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Wed, 20 Jan 2021 18:21:05 +0100 Subject: [PATCH] [New] Added ParameterizedElement.streamStringList() --- .../strolch/model/ParameterBagContainer.java | 15 +++++++++++++++ .../li/strolch/model/ParameterizedElement.java | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) 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 990bdd2cb..77a0c8b56 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 @@ -1238,6 +1238,21 @@ public interface ParameterBagContainer extends StrolchElement { */ List getRelationIds(String paramKey) throws StrolchModelException; + /** + * Returns a stream over the values of the {@link StringListParameter} with the given key from the {@link + * ParameterBag} with the ID {@link StrolchModelConstants#BAG_RELATIONS}, if the {@link Parameter} or the {@link + * ParameterBag} does not exist, then a {@link StrolchModelException} is thrown + * + * @param paramKey + * the key of the {@link StringParameter} for which the value is to be returned + * + * @return a stream over the the parameter's values + * + * @throws StrolchModelException + * if the parameter does not exist + */ + Stream streamRelationIds(String paramKey) throws StrolchModelException; + /** * Sets the value of the {@link StringParameter} with the given key on the {@link ParameterBag} with the ID {@link * StrolchModelConstants#BAG_RELATIONS}, if the {@link Parameter} or the {@link ParameterBag} does not exist, then a 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 e2913c620..e5dbae75c 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 @@ -271,6 +271,24 @@ public abstract class ParameterizedElement extends AbstractStrolchElement { return param.getValue(); } + /** + * Returns a {@link Stream} over the elements of the {@link StringListParameter} with the given paramKey + * + * @param paramKey + * the key of the parameter for which to return the value + * + * @return a stream over the values of the parameter with the given paramKey + * + * @throws StrolchModelException + * if the parameter does not exist + */ + public Stream streamStringList(String paramKey) throws StrolchModelException { + StringListParameter param = getParameter(paramKey, false); + if (param == null) + return Stream.empty(); + return param.streamValues(); + } + /** * Returns the value of the {@link IntegerListParameter} with the given paramKey *