[New] Added IActivityElement.findPolicy()
This commit is contained in:
parent
d06cce1bb9
commit
83a947e04b
|
@ -343,6 +343,27 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
||||||
return parameter;
|
return parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PolicyDef findPolicy(Class<?> clazz, PolicyDef defaultDef) throws StrolchModelException {
|
||||||
|
return findPolicy(clazz.getSimpleName(), defaultDef);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PolicyDef findPolicy(String className, PolicyDef defaultDef) throws StrolchModelException {
|
||||||
|
if (hasPolicyDef(className))
|
||||||
|
return getPolicyDef(className);
|
||||||
|
|
||||||
|
if (this.parent == null) {
|
||||||
|
if (defaultDef != null)
|
||||||
|
return defaultDef;
|
||||||
|
|
||||||
|
String msg = "The PolicyDef {0} does not exist";
|
||||||
|
throw new StrolchModelException(MessageFormat.format(msg, className));
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.parent.findPolicy(className, defaultDef);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T accept(StrolchElementVisitor<T> visitor) {
|
public <T> T accept(StrolchElementVisitor<T> visitor) {
|
||||||
return visitor.visitAction(this);
|
return visitor.visitAction(this);
|
||||||
|
|
|
@ -601,6 +601,27 @@ public class Activity extends AbstractStrolchRootElement
|
||||||
return parameter;
|
return parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PolicyDef findPolicy(Class<?> clazz, PolicyDef defaultDef) throws StrolchModelException {
|
||||||
|
return findPolicy(clazz.getSimpleName(), defaultDef);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PolicyDef findPolicy(String className, PolicyDef defaultDef) throws StrolchModelException {
|
||||||
|
if (hasPolicyDef(className))
|
||||||
|
return getPolicyDef(className);
|
||||||
|
|
||||||
|
if (this.parent == null) {
|
||||||
|
if (defaultDef != null)
|
||||||
|
return defaultDef;
|
||||||
|
|
||||||
|
String msg = "The PolicyDef {0} does not exist";
|
||||||
|
throw new StrolchModelException(MessageFormat.format(msg, className));
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.parent.findPolicy(className, defaultDef);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParent(Activity activity) {
|
public void setParent(Activity activity) {
|
||||||
assertNotReadonly();
|
assertNotReadonly();
|
||||||
|
|
|
@ -20,6 +20,7 @@ import li.strolch.model.GroupedParameterizedElement;
|
||||||
import li.strolch.model.State;
|
import li.strolch.model.State;
|
||||||
import li.strolch.model.StrolchElement;
|
import li.strolch.model.StrolchElement;
|
||||||
import li.strolch.model.parameter.Parameter;
|
import li.strolch.model.parameter.Parameter;
|
||||||
|
import li.strolch.model.policy.PolicyDef;
|
||||||
import li.strolch.model.visitor.StrolchElementVisitor;
|
import li.strolch.model.visitor.StrolchElementVisitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,14 +84,52 @@ public interface IActivityElement extends StrolchElement {
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* If the parameter does not exist and {@code assertExists} is true, then an
|
* If the parameter does not exist and {@code assertExists} is true, then a {@link StrolchModelException} is thrown
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* @see GroupedParameterizedElement#getParameter(String, String, boolean)
|
|
||||||
*/
|
*/
|
||||||
<U, T extends Parameter<U>> T findParameter(String bagKey, String paramKey, boolean assertExists)
|
<U, T extends Parameter<U>> T findParameter(String bagKey, String paramKey, boolean assertExists)
|
||||||
throws StrolchModelException;
|
throws StrolchModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Checks if this element contains the {@link PolicyDef}, or otherwise queries its parent, until the root element is
|
||||||
|
* reached.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* If the policy def does not exist and no default policy is passed, then a {@link StrolchModelException} is thrown
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param className
|
||||||
|
* the class name of the policy to find
|
||||||
|
* @param defaultDef
|
||||||
|
* default {@link PolicyDef} to return if not found
|
||||||
|
*
|
||||||
|
* @throws StrolchModelException
|
||||||
|
* if no default policy, and policy not found
|
||||||
|
*/
|
||||||
|
PolicyDef findPolicy(String className, PolicyDef defaultDef) throws StrolchModelException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Checks if this element contains the {@link PolicyDef}, or otherwise queries its parent, until the root element is
|
||||||
|
* reached.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
* If the policy def does not exist and no default policy is passed, then a {@link StrolchModelException} is thrown
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param clazz
|
||||||
|
* the class of the policy to find
|
||||||
|
* @param defaultDef
|
||||||
|
* default {@link PolicyDef} to return if not found
|
||||||
|
*
|
||||||
|
* @throws StrolchModelException
|
||||||
|
* if no default policy, and policy not found
|
||||||
|
*/
|
||||||
|
PolicyDef findPolicy(Class<?> clazz, PolicyDef defaultDef) throws StrolchModelException;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Activity getParent();
|
Activity getParent();
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package li.strolch.model.activity;
|
||||||
|
|
||||||
public interface TimeOrderingVisitor {
|
public interface TimeOrderingVisitor {
|
||||||
|
|
||||||
public void visitSeries(Activity activity);
|
void visitSeries(Activity activity);
|
||||||
|
|
||||||
public void visitParallel(Activity activity);
|
void visitParallel(Activity activity);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue