[New] Added PolicyContainer.hasPolicyDef(Class) and .addOrUpdate(PolicyDef)
This commit is contained in:
parent
177596571b
commit
206b1f019b
|
@ -24,6 +24,7 @@ import li.strolch.model.Locator.LocatorBuilder;
|
|||
import li.strolch.model.policy.PolicyDef;
|
||||
import li.strolch.model.policy.PolicyDefs;
|
||||
import li.strolch.model.visitor.StrolchElementVisitor;
|
||||
import li.strolch.utils.dbc.DBC;
|
||||
import li.strolch.utils.iso8601.ISO8601;
|
||||
|
||||
/**
|
||||
|
@ -199,6 +200,11 @@ public class Order extends AbstractStrolchRootElement implements StrolchRootElem
|
|||
return this.policyDefs != null && policyDefs.hasPolicyDef(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPolicyDef(Class<?> clazz) {
|
||||
return this.policyDefs != null && this.policyDefs.hasPolicyDef(clazz.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPolicyDefs(PolicyDefs policyDefs) {
|
||||
assertNotReadonly();
|
||||
|
@ -206,6 +212,17 @@ public class Order extends AbstractStrolchRootElement implements StrolchRootElem
|
|||
this.policyDefs.setParent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOrUpdate(PolicyDef policyDef) {
|
||||
assertNotReadonly();
|
||||
DBC.PRE.assertNotNull("policyDef", policyDef);
|
||||
if (this.policyDefs == null) {
|
||||
this.policyDefs = new PolicyDefs();
|
||||
this.policyDefs.setParent(this);
|
||||
}
|
||||
this.policyDefs.addOrUpdate(policyDef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order getClone() {
|
||||
return getClone(false);
|
||||
|
|
|
@ -37,6 +37,16 @@ public interface PolicyContainer {
|
|||
*/
|
||||
boolean hasPolicyDef(String type);
|
||||
|
||||
/**
|
||||
* Returns true if this container has the {@link PolicyDef} with the given type, false if not
|
||||
*
|
||||
* @param clazz
|
||||
* the type of policy def to return
|
||||
*
|
||||
* @return true if this container has the {@link PolicyDef} with the given type, false if not
|
||||
*/
|
||||
boolean hasPolicyDef(Class<?> clazz);
|
||||
|
||||
/**
|
||||
* Returns the {@link PolicyDef} for the given type
|
||||
*
|
||||
|
@ -88,4 +98,12 @@ public interface PolicyContainer {
|
|||
* the {@link PolicyDefs} to set
|
||||
*/
|
||||
void setPolicyDefs(PolicyDefs policyDefs);
|
||||
|
||||
/**
|
||||
* Add or update the given {@link PolicyDef} to this container
|
||||
*
|
||||
* @param policyDef
|
||||
* the {@link PolicyDef} to add or update
|
||||
*/
|
||||
void addOrUpdate(PolicyDef policyDef);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import li.strolch.model.policy.PolicyDefs;
|
|||
import li.strolch.model.timedstate.StrolchTimedState;
|
||||
import li.strolch.model.timevalue.IValue;
|
||||
import li.strolch.model.visitor.StrolchElementVisitor;
|
||||
import li.strolch.utils.dbc.DBC;
|
||||
|
||||
/**
|
||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||
|
@ -273,7 +274,12 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
|
|||
|
||||
@Override
|
||||
public boolean hasPolicyDef(String type) {
|
||||
return this.policyDefs != null && policyDefs.hasPolicyDef(type);
|
||||
return this.policyDefs != null && this.policyDefs.hasPolicyDef(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPolicyDef(Class<?> clazz) {
|
||||
return this.policyDefs != null && this.policyDefs.hasPolicyDef(clazz.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -283,6 +289,17 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
|
|||
this.policyDefs.setParent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOrUpdate(PolicyDef policyDef) {
|
||||
assertNotReadonly();
|
||||
DBC.PRE.assertNotNull("policyDef", policyDef);
|
||||
if (this.policyDefs == null) {
|
||||
this.policyDefs = new PolicyDefs();
|
||||
this.policyDefs.setParent(this);
|
||||
}
|
||||
this.policyDefs.addOrUpdate(policyDef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource getClone() {
|
||||
return getClone(false);
|
||||
|
|
|
@ -32,6 +32,7 @@ import li.strolch.model.policy.PolicyDefs;
|
|||
import li.strolch.model.timevalue.IValue;
|
||||
import li.strolch.model.timevalue.IValueChange;
|
||||
import li.strolch.model.visitor.StrolchElementVisitor;
|
||||
import li.strolch.utils.dbc.DBC;
|
||||
|
||||
/**
|
||||
* An {@link Action} represents a single step within an {@link Activity}, that is, one that is not further decomposed
|
||||
|
@ -280,6 +281,11 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
|||
return this.policyDefs != null && policyDefs.hasPolicyDef(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPolicyDef(Class<?> clazz) {
|
||||
return this.policyDefs != null && this.policyDefs.hasPolicyDef(clazz.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPolicyDefs(PolicyDefs policyDefs) {
|
||||
assertNotReadonly();
|
||||
|
@ -287,6 +293,17 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
|||
this.policyDefs.setParent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOrUpdate(PolicyDef policyDef) {
|
||||
assertNotReadonly();
|
||||
DBC.PRE.assertNotNull("policyDef", policyDef);
|
||||
if (this.policyDefs == null) {
|
||||
this.policyDefs = new PolicyDefs();
|
||||
this.policyDefs.setParent(this);
|
||||
}
|
||||
this.policyDefs.addOrUpdate(policyDef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locator getLocator() {
|
||||
LocatorBuilder lb = new LocatorBuilder();
|
||||
|
|
|
@ -557,6 +557,11 @@ public class Activity extends AbstractStrolchRootElement
|
|||
return this.policyDefs != null && policyDefs.hasPolicyDef(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPolicyDef(Class<?> clazz) {
|
||||
return this.policyDefs != null && this.policyDefs.hasPolicyDef(clazz.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPolicyDefs(PolicyDefs policyDefs) {
|
||||
assertNotReadonly();
|
||||
|
@ -564,6 +569,17 @@ public class Activity extends AbstractStrolchRootElement
|
|||
this.policyDefs.setParent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOrUpdate(PolicyDef policyDef) {
|
||||
assertNotReadonly();
|
||||
DBC.PRE.assertNotNull("policyDef", policyDef);
|
||||
if (this.policyDefs == null) {
|
||||
this.policyDefs = new PolicyDefs();
|
||||
this.policyDefs.setParent(this);
|
||||
}
|
||||
this.policyDefs.addOrUpdate(policyDef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locator getLocator() {
|
||||
if (this.locator == null) {
|
||||
|
|
Loading…
Reference in New Issue