[New] Added IActivityElement.findObjectivesParam()

This commit is contained in:
Robert von Burg 2023-02-24 14:10:42 +01:00
parent 76b3ae3c26
commit 2b05225459
Signed by: eitch
GPG Key ID: 75DB9C85C74331F7
3 changed files with 104 additions and 4 deletions

View File

@ -16,7 +16,9 @@
package li.strolch.model.activity;
import static li.strolch.model.StrolchModelConstants.BAG_PARAMETERS;
import static li.strolch.model.StrolchModelConstants.BAG_RELATIONS;
import static li.strolch.model.StrolchModelConstants.PolicyConstants.BAG_OBJECTIVES;
import static li.strolch.utils.helper.StringHelper.isNotEmpty;
import static li.strolch.utils.helper.StringHelper.trimOrEmpty;
@ -409,6 +411,16 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
return end;
}
@Override
public <U, T extends Parameter<U>> T findObjectivesParam(String paramKey) {
return findParameter(BAG_OBJECTIVES, paramKey);
}
@Override
public <U, T extends Parameter<U>> T findObjectivesParam(String paramKey, boolean assertExists) {
return findParameter(BAG_OBJECTIVES, paramKey, assertExists);
}
@Override
public <U, T extends Parameter<U>> T findRelationParam(String paramKey) {
return findParameter(BAG_RELATIONS, paramKey);
@ -419,6 +431,16 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
return findParameter(BAG_RELATIONS, paramKey, assertExists);
}
@Override
public <U, T extends Parameter<U>> T findParameter(String paramKey) {
return findParameter(BAG_PARAMETERS, paramKey);
}
@Override
public <U, T extends Parameter<U>> T findParameter(String paramKey, boolean assertExists) {
return findParameter(BAG_PARAMETERS, paramKey, assertExists);
}
@Override
public <U, T extends Parameter<U>> T findParameter(String bagKey, String paramKey) {

View File

@ -16,7 +16,9 @@
package li.strolch.model.activity;
import static java.util.stream.Collectors.toList;
import static li.strolch.model.StrolchModelConstants.BAG_PARAMETERS;
import static li.strolch.model.StrolchModelConstants.BAG_RELATIONS;
import static li.strolch.model.StrolchModelConstants.PolicyConstants.BAG_OBJECTIVES;
import static li.strolch.utils.collections.CollectionsHelper.singletonCollector;
import java.text.MessageFormat;
@ -771,6 +773,16 @@ public class Activity extends AbstractStrolchRootElement
return visitor.visitActivity(this);
}
@Override
public <U, T extends Parameter<U>> T findObjectivesParam(String paramKey) {
return findParameter(BAG_OBJECTIVES, paramKey);
}
@Override
public <U, T extends Parameter<U>> T findObjectivesParam(String paramKey, boolean assertExists) {
return findParameter(BAG_OBJECTIVES, paramKey, assertExists);
}
@Override
public <U, T extends Parameter<U>> T findRelationParam(String paramKey) {
return findParameter(BAG_RELATIONS, paramKey);
@ -782,6 +794,15 @@ public class Activity extends AbstractStrolchRootElement
}
@Override
public <U, T extends Parameter<U>> T findParameter(String paramKey) {
return findParameter(BAG_PARAMETERS, paramKey);
}
@Override
public <U, T extends Parameter<U>> T findParameter(String paramKey, boolean assertExists) {
return findParameter(BAG_PARAMETERS, paramKey, assertExists);
}
public <U, T extends Parameter<U>> T findParameter(String bagKey, String paramKey) {
T parameter = getParameter(bagKey, paramKey);

View File

@ -18,6 +18,7 @@ package li.strolch.model.activity;
import java.util.function.Predicate;
import li.strolch.exception.StrolchModelException;
import li.strolch.exception.StrolchPolicyException;
import li.strolch.model.*;
import li.strolch.model.parameter.Parameter;
import li.strolch.model.policy.PolicyDef;
@ -65,8 +66,8 @@ public interface IActivityElement extends StrolchElement {
/**
* <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.
* 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>
@ -79,8 +80,8 @@ public interface IActivityElement extends StrolchElement {
/**
* <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.
* 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>
@ -91,6 +92,62 @@ public interface IActivityElement extends StrolchElement {
*/
<U, T extends Parameter<U>> T findRelationParam(String paramKey, boolean assertExists);
/**
* <p>
* Checks if this element contains the {@link Parameter} on the {@link ParameterBag} with the id
* {@link StrolchModelConstants.PolicyConstants#BAG_OBJECTIVES}, 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#getParameter(String)
*/
<U, T extends Parameter<U>> T findObjectivesParam(String paramKey);
/**
* <p>
* Checks if this element contains the {@link Parameter} on the {@link ParameterBag} with the id
* {@link StrolchModelConstants.PolicyConstants#BAG_OBJECTIVES}, 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#getParameter(String, String, boolean)
*/
<U, T extends Parameter<U>> T findObjectivesParam(String paramKey, boolean assertExists);
/**
* <p>
* Checks if this element contains the {@link Parameter} on the default parameter bag, 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#getParameter(String)
*/
<U, T extends Parameter<U>> T findParameter(String paramKey);
/**
* <p>
* Checks if this element contains the {@link Parameter} on the default parameter bag, 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>
*/
<U, T extends Parameter<U>> T findParameter(String paramKey, boolean assertExists) throws StrolchModelException;
/**
* <p>
* Checks if this element contains the {@link Parameter}, or otherwise queries its parent, until the root element is