[New] Added IActivityElement.findRelationParam()

This commit is contained in:
Robert von Burg 2020-03-19 08:24:53 +01:00
parent c4ea66ee2e
commit 8e976673f0
3 changed files with 52 additions and 3 deletions

View File

@ -16,6 +16,7 @@
package li.strolch.model.activity;
import static li.strolch.model.StrolchModelConstants.BAG_RELATIONS;
import static li.strolch.utils.helper.StringHelper.isNotEmpty;
import java.text.MessageFormat;
@ -345,6 +346,16 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
return end;
}
@Override
public <U, T extends Parameter<U>> T findRelationParam(String paramKey) {
return findParameter(BAG_RELATIONS, paramKey);
}
@Override
public <U, T extends Parameter<U>> T findRelationParam(String paramKey, boolean assertExists) {
return findParameter(BAG_RELATIONS, paramKey, assertExists);
}
@Override
public <U, T extends Parameter<U>> T findParameter(String bagKey, String paramKey) {

View File

@ -15,6 +15,8 @@
*/
package li.strolch.model.activity;
import static li.strolch.model.StrolchModelConstants.BAG_RELATIONS;
import java.text.MessageFormat;
import java.util.*;
import java.util.Map.Entry;
@ -611,6 +613,16 @@ public class Activity extends AbstractStrolchRootElement
return visitor.visitActivity(this);
}
@Override
public <U, T extends Parameter<U>> T findRelationParam(String paramKey) {
return findParameter(BAG_RELATIONS, paramKey);
}
@Override
public <U, T extends Parameter<U>> T findRelationParam(String paramKey, boolean assertExists) {
return findParameter(BAG_RELATIONS, paramKey, assertExists);
}
@SuppressWarnings("unchecked")
@Override
public <U, T extends Parameter<U>> T findParameter(String bagKey, String paramKey) {

View File

@ -18,9 +18,7 @@ package li.strolch.model.activity;
import java.util.function.Predicate;
import li.strolch.exception.StrolchModelException;
import li.strolch.model.GroupedParameterizedElement;
import li.strolch.model.State;
import li.strolch.model.StrolchElement;
import li.strolch.model.*;
import li.strolch.model.parameter.Parameter;
import li.strolch.model.policy.PolicyDef;
import li.strolch.model.visitor.StrolchElementVisitor;
@ -65,6 +63,34 @@ public interface IActivityElement extends StrolchElement {
*/
void setParent(Activity activity);
/**
* <p>
* Checks if this element contains the {@link Parameter} on the {@link ParameterBag} with the id {@link
* StrolchModelConstants#BAG_RELATIONS}, or otherwise queries its parent, until the root element is reached.
* </p>
*
* <p>
* If the parameter does not exist, null is returned
* </p>
*
* @see GroupedParameterizedElement#getRelationParam(String)
*/
<U, T extends Parameter<U>> T findRelationParam(String paramKey);
/**
* <p>
* Checks if this element contains the {@link Parameter} on the {@link ParameterBag} with the id {@link
* StrolchModelConstants#BAG_RELATIONS}, or otherwise queries its parent, until the root element is reached.
* </p>
*
* <p>
* If the parameter does not exist and {@code assertExists} is true, then a {@link StrolchModelException} is thrown
* </p>
*
* @see GroupedParameterizedElement#getRelationParam(String, boolean)
*/
<U, T extends Parameter<U>> T findRelationParam(String paramKey, boolean assertExists);
/**
* <p>
* Checks if this element contains the {@link Parameter}, or otherwise queries its parent, until the root element is