[Minor] Added PolicyContainer.getPolicyDef(Class)
This commit is contained in:
parent
a7a33e4e0c
commit
d385025609
|
@ -1,12 +1,12 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -129,6 +129,11 @@ public class Order extends AbstractStrolchRootElement implements StrolchRootElem
|
|||
return this.policyDefs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyDef getPolicyDef(Class<?> clazz) {
|
||||
return getPolicyDefs().getPolicyDef(clazz.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyDef getPolicyDef(String type) {
|
||||
return getPolicyDefs().getPolicyDef(type);
|
||||
|
|
|
@ -7,18 +7,18 @@ import li.strolch.model.policy.PolicyDefs;
|
|||
/**
|
||||
* A {@link PolicyContainer} has a reference to {@link PolicyDefs} on which Policy configurations are stored for the
|
||||
* given object
|
||||
*
|
||||
*
|
||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||
*/
|
||||
public interface PolicyContainer {
|
||||
|
||||
/**
|
||||
* Returns the reference to the {@link PolicyDefs}
|
||||
*
|
||||
*
|
||||
* @return the reference to the {@link PolicyDefs}
|
||||
*
|
||||
*
|
||||
* @throws StrolchPolicyException
|
||||
* if no {@link PolicyDefs} are available
|
||||
* if no {@link PolicyDefs} are available
|
||||
*/
|
||||
public PolicyDefs getPolicyDefs() throws StrolchPolicyException;
|
||||
|
||||
|
@ -29,29 +29,39 @@ public interface PolicyContainer {
|
|||
|
||||
/**
|
||||
* Returns true if this container has the {@link PolicyDef} with the given type, false if not
|
||||
*
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public boolean hasPolicyDef(String type);
|
||||
|
||||
/**
|
||||
* Returns the {@link PolicyDef} for the given 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
|
||||
*/
|
||||
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}
|
||||
*
|
||||
*
|
||||
* @param policyDefs
|
||||
* the {@link PolicyDefs} to set
|
||||
* the {@link PolicyDefs} to set
|
||||
*/
|
||||
public void setPolicyDefs(PolicyDefs policyDefs);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*
|
||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -162,6 +162,11 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
|
|||
return this.policyDefs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyDef getPolicyDef(Class<?> clazz) {
|
||||
return getPolicyDefs().getPolicyDef(clazz.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyDef getPolicyDef(String type) {
|
||||
return getPolicyDefs().getPolicyDef(type);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*
|
||||
* Copyright 2015 Martin Smock <martin.smock@bluewin.ch>
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -43,7 +43,7 @@ import li.strolch.model.visitor.IActivityElementVisitor;
|
|||
* An {@link Action} represents a single step within an {@link Activity}, that is, one that is not further decomposed
|
||||
* within the {@link Activity}. A {@link Activity} applies {@link IValueChange} objects at the start and end time of the
|
||||
* {@link Activity}.
|
||||
*
|
||||
*
|
||||
* @author Martin Smock <martin.smock@bluewin.ch>
|
||||
*/
|
||||
public class Action extends GroupedParameterizedElement implements IActivityElement, PolicyContainer {
|
||||
|
@ -91,7 +91,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
|||
|
||||
/**
|
||||
* @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) {
|
||||
this.resourceId = resourceId;
|
||||
|
@ -107,7 +107,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
|||
|
||||
/**
|
||||
* @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) {
|
||||
this.state = state;
|
||||
|
@ -122,6 +122,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
|||
|
||||
/**
|
||||
* @param resourceType
|
||||
* the resource type
|
||||
*/
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
|
@ -129,7 +130,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
|||
|
||||
/**
|
||||
* Returns true if this {@link Action} contains any {@link IValueChange changes}, false if not
|
||||
*
|
||||
*
|
||||
* @return true if this {@link Action} contains any {@link IValueChange changes}, false if not
|
||||
*/
|
||||
public boolean hasChanges() {
|
||||
|
@ -137,9 +138,9 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
|||
}
|
||||
|
||||
/**
|
||||
* @param add
|
||||
* <code>IValueChange</code> to be applied to the <code>Resource</code>
|
||||
*
|
||||
* @param change
|
||||
* <code>IValueChange</code> to be applied to the <code>Resource</code>
|
||||
*
|
||||
* @return <tt>true</tt> (as specified by {@link Collection#add})
|
||||
*/
|
||||
public boolean addChange(IValueChange<? extends IValue<?>> change) {
|
||||
|
@ -158,7 +159,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
|||
|
||||
public Iterator<IValueChange<? extends IValue<?>>> changesIterator() {
|
||||
if (this.changes == null)
|
||||
return Collections.<IValueChange<? extends IValue<?>>> emptyList().iterator();
|
||||
return Collections.<IValueChange<? extends IValue<?>>>emptyList().iterator();
|
||||
return this.changes.iterator();
|
||||
}
|
||||
|
||||
|
@ -212,6 +213,11 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
|||
return this.policyDefs != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyDef getPolicyDef(Class<?> clazz) {
|
||||
return getPolicyDefs().getPolicyDef(clazz.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPolicyDef(String type) {
|
||||
return this.policyDefs != null && policyDefs.hasPolicyDef(type);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*
|
||||
* Copyright 2015 Martin Smock <martin.smock@bluewin.ch>
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -15,6 +15,11 @@
|
|||
*/
|
||||
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.StrolchModelException;
|
||||
import li.strolch.exception.StrolchPolicyException;
|
||||
|
@ -27,15 +32,10 @@ import li.strolch.model.visitor.IActivityElementVisitor;
|
|||
import li.strolch.model.visitor.StrolchElementVisitor;
|
||||
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
|
||||
* scheduled
|
||||
*
|
||||
*
|
||||
* @author Martin Smock <martin.smock@bluewin.ch>
|
||||
*/
|
||||
public class Activity extends AbstractStrolchRootElement
|
||||
|
@ -61,11 +61,11 @@ public class Activity extends AbstractStrolchRootElement
|
|||
* Default constructor
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* the id
|
||||
* @param name
|
||||
* the name
|
||||
* the name
|
||||
* @param type
|
||||
* the type
|
||||
* the type
|
||||
*/
|
||||
public Activity(String id, String name, String type, TimeOrdering timeOrdering) {
|
||||
super(id, name, type);
|
||||
|
@ -118,7 +118,7 @@ public class Activity extends AbstractStrolchRootElement
|
|||
|
||||
/**
|
||||
* Returns true if this {@link Activity} contains any children i.e. any of {@link Action} or {@link Activity}
|
||||
*
|
||||
*
|
||||
* @return true if this {@link Activity} contains any children i.e. any of {@link Action} or {@link Activity}
|
||||
*/
|
||||
public boolean hasElements() {
|
||||
|
@ -128,12 +128,12 @@ public class Activity extends AbstractStrolchRootElement
|
|||
/**
|
||||
* Returns 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}
|
||||
*
|
||||
*
|
||||
* @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,
|
||||
* i.e. {@link Action} or {@link Activity}
|
||||
* i.e. {@link Action} or {@link Activity}
|
||||
*/
|
||||
public boolean hasElement(String id) {
|
||||
return this.elements != null && this.elements.containsKey(id);
|
||||
|
@ -141,8 +141,9 @@ public class Activity extends AbstractStrolchRootElement
|
|||
|
||||
/**
|
||||
* add an activity element to the <code>LinkedHashMap</code> of <code>IActivityElements</code>
|
||||
*
|
||||
*
|
||||
* @param activityElement
|
||||
*
|
||||
* @return the element added
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -167,10 +168,10 @@ public class Activity extends AbstractStrolchRootElement
|
|||
|
||||
/**
|
||||
* Removes the element with the given id and returns it, if it exists
|
||||
*
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -183,9 +184,10 @@ public class Activity extends AbstractStrolchRootElement
|
|||
|
||||
/**
|
||||
* get <code>IActivityElement</code> by id
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* the id of the <code>IActivityElement</code>
|
||||
* the id of the <code>IActivityElement</code>
|
||||
*
|
||||
* @return IActivityElement
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -297,7 +299,7 @@ public class Activity extends AbstractStrolchRootElement
|
|||
|
||||
/**
|
||||
* Returns all the actions as a flat list
|
||||
*
|
||||
*
|
||||
* @return the list of actions
|
||||
*/
|
||||
public List<Action> getActionsAsFlatList() {
|
||||
|
@ -317,10 +319,10 @@ public class Activity extends AbstractStrolchRootElement
|
|||
|
||||
/**
|
||||
* Returns all the actions in the entire hierarchy with the given 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
|
||||
*/
|
||||
public List<Action> getActionsWithState(State state) {
|
||||
|
@ -340,10 +342,10 @@ public class Activity extends AbstractStrolchRootElement
|
|||
|
||||
/**
|
||||
* Returns all the actions in the entire hierarchy with the given type
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* the type of action to return
|
||||
*
|
||||
* the type of action to return
|
||||
*
|
||||
* @return the list of actions with the given type
|
||||
*/
|
||||
public List<Action> getActionsByType(String type) {
|
||||
|
@ -366,7 +368,7 @@ public class Activity extends AbstractStrolchRootElement
|
|||
*/
|
||||
public Iterator<Entry<String, IActivityElement>> elementIterator() {
|
||||
if (this.elements == null)
|
||||
return Collections.<String, IActivityElement> emptyMap().entrySet().iterator();
|
||||
return Collections.<String, IActivityElement>emptyMap().entrySet().iterator();
|
||||
return this.elements.entrySet().iterator();
|
||||
}
|
||||
|
||||
|
@ -375,7 +377,7 @@ public class Activity extends AbstractStrolchRootElement
|
|||
*/
|
||||
public Stream<Entry<String, IActivityElement>> elementStream() {
|
||||
if (this.elements == null)
|
||||
return Collections.<String, IActivityElement> emptyMap().entrySet().stream();
|
||||
return Collections.<String, IActivityElement>emptyMap().entrySet().stream();
|
||||
return this.elements.entrySet().stream();
|
||||
}
|
||||
|
||||
|
@ -419,6 +421,11 @@ public class Activity extends AbstractStrolchRootElement
|
|||
return this.policyDefs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyDef getPolicyDef(Class<?> clazz) {
|
||||
return getPolicyDefs().getPolicyDef(clazz.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolicyDef getPolicyDef(String type) {
|
||||
return getPolicyDefs().getPolicyDef(type);
|
||||
|
|
Loading…
Reference in New Issue