[Minor] Added PolicyContainer.getPolicyDef(Class)
This commit is contained in:
parent
a7a33e4e0c
commit
d385025609
|
@ -129,6 +129,11 @@ public class Order extends AbstractStrolchRootElement implements StrolchRootElem
|
||||||
return this.policyDefs;
|
return this.policyDefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PolicyDef getPolicyDef(Class<?> clazz) {
|
||||||
|
return getPolicyDefs().getPolicyDef(clazz.getSimpleName());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PolicyDef getPolicyDef(String type) {
|
public PolicyDef getPolicyDef(String type) {
|
||||||
return getPolicyDefs().getPolicyDef(type);
|
return getPolicyDefs().getPolicyDef(type);
|
||||||
|
|
|
@ -18,7 +18,7 @@ public interface PolicyContainer {
|
||||||
* @return the reference to the {@link PolicyDefs}
|
* @return the reference to the {@link PolicyDefs}
|
||||||
*
|
*
|
||||||
* @throws StrolchPolicyException
|
* @throws StrolchPolicyException
|
||||||
* if no {@link PolicyDefs} are available
|
* if no {@link PolicyDefs} are available
|
||||||
*/
|
*/
|
||||||
public PolicyDefs getPolicyDefs() throws StrolchPolicyException;
|
public PolicyDefs getPolicyDefs() throws StrolchPolicyException;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public interface PolicyContainer {
|
||||||
* Returns true if this container has the {@link PolicyDef} with the given type, false if not
|
* Returns true if this container has the {@link PolicyDef} with the given type, false if not
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
* the type of policy def to return
|
* the type of policy def to return
|
||||||
*
|
*
|
||||||
* @return true if this container has the {@link PolicyDef} with the given type, false if not
|
* @return true if this container has the {@link PolicyDef} with the given type, false if not
|
||||||
*/
|
*/
|
||||||
|
@ -41,17 +41,27 @@ public interface PolicyContainer {
|
||||||
* Returns the {@link PolicyDef} for the given type
|
* Returns the {@link PolicyDef} for the given type
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
* the type of policy def to return
|
* the type of policy def to return
|
||||||
*
|
*
|
||||||
* @return the policy def of the given type
|
* @return the policy def of the given type
|
||||||
*/
|
*/
|
||||||
public PolicyDef getPolicyDef(String type);
|
public PolicyDef getPolicyDef(String type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the {@link PolicyDef} for the given class
|
||||||
|
*
|
||||||
|
* @param clazz
|
||||||
|
* the type of policy def to return
|
||||||
|
*
|
||||||
|
* @return the policy def of the given class
|
||||||
|
*/
|
||||||
|
public PolicyDef getPolicyDef(Class<?> clazz);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the reference to the {@link PolicyDefs}
|
* Set the reference to the {@link PolicyDefs}
|
||||||
*
|
*
|
||||||
* @param policyDefs
|
* @param policyDefs
|
||||||
* the {@link PolicyDefs} to set
|
* the {@link PolicyDefs} to set
|
||||||
*/
|
*/
|
||||||
public void setPolicyDefs(PolicyDefs policyDefs);
|
public void setPolicyDefs(PolicyDefs policyDefs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,6 +162,11 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
|
||||||
return this.policyDefs;
|
return this.policyDefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PolicyDef getPolicyDef(Class<?> clazz) {
|
||||||
|
return getPolicyDefs().getPolicyDef(clazz.getSimpleName());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PolicyDef getPolicyDef(String type) {
|
public PolicyDef getPolicyDef(String type) {
|
||||||
return getPolicyDefs().getPolicyDef(type);
|
return getPolicyDefs().getPolicyDef(type);
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param resourceId
|
* @param resourceId
|
||||||
* the id of the {@link Resource} the {@link Action} acts on
|
* the id of the {@link Resource} the {@link Action} acts on
|
||||||
*/
|
*/
|
||||||
public void setResourceId(String resourceId) {
|
public void setResourceId(String resourceId) {
|
||||||
this.resourceId = resourceId;
|
this.resourceId = resourceId;
|
||||||
|
@ -107,7 +107,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param state
|
* @param state
|
||||||
* the target <code>State</code> of the a<code>Action</code>
|
* the target <code>State</code> of the a<code>Action</code>
|
||||||
*/
|
*/
|
||||||
public void setState(State state) {
|
public void setState(State state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
@ -122,6 +122,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param resourceType
|
* @param resourceType
|
||||||
|
* the resource type
|
||||||
*/
|
*/
|
||||||
public void setResourceType(String resourceType) {
|
public void setResourceType(String resourceType) {
|
||||||
this.resourceType = resourceType;
|
this.resourceType = resourceType;
|
||||||
|
@ -137,8 +138,8 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param add
|
* @param change
|
||||||
* <code>IValueChange</code> to be applied to the <code>Resource</code>
|
* <code>IValueChange</code> to be applied to the <code>Resource</code>
|
||||||
*
|
*
|
||||||
* @return <tt>true</tt> (as specified by {@link Collection#add})
|
* @return <tt>true</tt> (as specified by {@link Collection#add})
|
||||||
*/
|
*/
|
||||||
|
@ -158,7 +159,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
||||||
|
|
||||||
public Iterator<IValueChange<? extends IValue<?>>> changesIterator() {
|
public Iterator<IValueChange<? extends IValue<?>>> changesIterator() {
|
||||||
if (this.changes == null)
|
if (this.changes == null)
|
||||||
return Collections.<IValueChange<? extends IValue<?>>> emptyList().iterator();
|
return Collections.<IValueChange<? extends IValue<?>>>emptyList().iterator();
|
||||||
return this.changes.iterator();
|
return this.changes.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +213,11 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
||||||
return this.policyDefs != null;
|
return this.policyDefs != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PolicyDef getPolicyDef(Class<?> clazz) {
|
||||||
|
return getPolicyDefs().getPolicyDef(clazz.getSimpleName());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPolicyDef(String type) {
|
public boolean hasPolicyDef(String type) {
|
||||||
return this.policyDefs != null && policyDefs.hasPolicyDef(type);
|
return this.policyDefs != null && policyDefs.hasPolicyDef(type);
|
||||||
|
|
|
@ -15,6 +15,11 @@
|
||||||
*/
|
*/
|
||||||
package li.strolch.model.activity;
|
package li.strolch.model.activity;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import li.strolch.exception.StrolchException;
|
import li.strolch.exception.StrolchException;
|
||||||
import li.strolch.exception.StrolchModelException;
|
import li.strolch.exception.StrolchModelException;
|
||||||
import li.strolch.exception.StrolchPolicyException;
|
import li.strolch.exception.StrolchPolicyException;
|
||||||
|
@ -27,11 +32,6 @@ import li.strolch.model.visitor.IActivityElementVisitor;
|
||||||
import li.strolch.model.visitor.StrolchElementVisitor;
|
import li.strolch.model.visitor.StrolchElementVisitor;
|
||||||
import li.strolch.utils.dbc.DBC;
|
import li.strolch.utils.dbc.DBC;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameterized object grouping a collection of {@link Activity} and {@link Action} objects defining the process to be
|
* Parameterized object grouping a collection of {@link Activity} and {@link Action} objects defining the process to be
|
||||||
* scheduled
|
* scheduled
|
||||||
|
@ -61,11 +61,11 @@ public class Activity extends AbstractStrolchRootElement
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* the id
|
* the id
|
||||||
* @param name
|
* @param name
|
||||||
* the name
|
* the name
|
||||||
* @param type
|
* @param type
|
||||||
* the type
|
* the type
|
||||||
*/
|
*/
|
||||||
public Activity(String id, String name, String type, TimeOrdering timeOrdering) {
|
public Activity(String id, String name, String type, TimeOrdering timeOrdering) {
|
||||||
super(id, name, type);
|
super(id, name, type);
|
||||||
|
@ -130,10 +130,10 @@ public class Activity extends AbstractStrolchRootElement
|
||||||
* i.e. {@link Action} or {@link Activity}
|
* i.e. {@link Action} or {@link Activity}
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* the id of the element to check for
|
* the id of the element to check for
|
||||||
*
|
*
|
||||||
* @return true if this {@link Activity} contains a child with the given id. The element instance type is ignored,
|
* @return true if this {@link Activity} contains a child with the given id. The element instance type is ignored,
|
||||||
* i.e. {@link Action} or {@link Activity}
|
* i.e. {@link Action} or {@link Activity}
|
||||||
*/
|
*/
|
||||||
public boolean hasElement(String id) {
|
public boolean hasElement(String id) {
|
||||||
return this.elements != null && this.elements.containsKey(id);
|
return this.elements != null && this.elements.containsKey(id);
|
||||||
|
@ -143,6 +143,7 @@ public class Activity extends AbstractStrolchRootElement
|
||||||
* add an activity element to the <code>LinkedHashMap</code> of <code>IActivityElements</code>
|
* add an activity element to the <code>LinkedHashMap</code> of <code>IActivityElements</code>
|
||||||
*
|
*
|
||||||
* @param activityElement
|
* @param activityElement
|
||||||
|
*
|
||||||
* @return the element added
|
* @return the element added
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -169,7 +170,7 @@ public class Activity extends AbstractStrolchRootElement
|
||||||
* Removes the element with the given id and returns it, if it exists
|
* Removes the element with the given id and returns it, if it exists
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* the id of the element to remove
|
* the id of the element to remove
|
||||||
*
|
*
|
||||||
* @return the removed element, or null if it does not exist
|
* @return the removed element, or null if it does not exist
|
||||||
*/
|
*/
|
||||||
|
@ -185,7 +186,8 @@ public class Activity extends AbstractStrolchRootElement
|
||||||
* get <code>IActivityElement</code> by id
|
* get <code>IActivityElement</code> by id
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* the id of the <code>IActivityElement</code>
|
* the id of the <code>IActivityElement</code>
|
||||||
|
*
|
||||||
* @return IActivityElement
|
* @return IActivityElement
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -319,7 +321,7 @@ public class Activity extends AbstractStrolchRootElement
|
||||||
* Returns all the actions in the entire hierarchy with the given state
|
* Returns all the actions in the entire hierarchy with the given state
|
||||||
*
|
*
|
||||||
* @param state
|
* @param state
|
||||||
* the state of the action to return
|
* the state of the action to return
|
||||||
*
|
*
|
||||||
* @return the list of actions with the given state
|
* @return the list of actions with the given state
|
||||||
*/
|
*/
|
||||||
|
@ -342,7 +344,7 @@ public class Activity extends AbstractStrolchRootElement
|
||||||
* Returns all the actions in the entire hierarchy with the given type
|
* Returns all the actions in the entire hierarchy with the given type
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
* the type of action to return
|
* the type of action to return
|
||||||
*
|
*
|
||||||
* @return the list of actions with the given type
|
* @return the list of actions with the given type
|
||||||
*/
|
*/
|
||||||
|
@ -366,7 +368,7 @@ public class Activity extends AbstractStrolchRootElement
|
||||||
*/
|
*/
|
||||||
public Iterator<Entry<String, IActivityElement>> elementIterator() {
|
public Iterator<Entry<String, IActivityElement>> elementIterator() {
|
||||||
if (this.elements == null)
|
if (this.elements == null)
|
||||||
return Collections.<String, IActivityElement> emptyMap().entrySet().iterator();
|
return Collections.<String, IActivityElement>emptyMap().entrySet().iterator();
|
||||||
return this.elements.entrySet().iterator();
|
return this.elements.entrySet().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +377,7 @@ public class Activity extends AbstractStrolchRootElement
|
||||||
*/
|
*/
|
||||||
public Stream<Entry<String, IActivityElement>> elementStream() {
|
public Stream<Entry<String, IActivityElement>> elementStream() {
|
||||||
if (this.elements == null)
|
if (this.elements == null)
|
||||||
return Collections.<String, IActivityElement> emptyMap().entrySet().stream();
|
return Collections.<String, IActivityElement>emptyMap().entrySet().stream();
|
||||||
return this.elements.entrySet().stream();
|
return this.elements.entrySet().stream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,6 +421,11 @@ public class Activity extends AbstractStrolchRootElement
|
||||||
return this.policyDefs;
|
return this.policyDefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PolicyDef getPolicyDef(Class<?> clazz) {
|
||||||
|
return getPolicyDefs().getPolicyDef(clazz.getSimpleName());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PolicyDef getPolicyDef(String type) {
|
public PolicyDef getPolicyDef(String type) {
|
||||||
return getPolicyDefs().getPolicyDef(type);
|
return getPolicyDefs().getPolicyDef(type);
|
||||||
|
|
Loading…
Reference in New Issue