[New] Added StrolchTransaction.getPolicy(PolicyContainer, Class<T>) to simplify getting policies
This commit is contained in:
parent
87804809f3
commit
7904bb45d7
|
@ -418,6 +418,12 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
|||
return this.container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends StrolchPolicy> T getPolicy(PolicyContainer element, Class<T> clazz) {
|
||||
PolicyDef policyDef = element.getPolicyDef(clazz);
|
||||
return getContainer().getComponent(PolicyHandler.class).getPolicy(policyDef, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public <T extends StrolchPolicy> T getPolicy(PolicyDef policyDef) {
|
||||
|
|
|
@ -229,6 +229,20 @@ public interface StrolchTransaction extends AutoCloseable {
|
|||
*/
|
||||
ComponentContainer getContainer();
|
||||
|
||||
/**
|
||||
* Instantiates the policy using the given {@link Class} to retrieve the {@link PolicyDef} from the given element
|
||||
*
|
||||
* @param element
|
||||
* the element from which to retrieve the {@link PolicyDef
|
||||
* @param <T>
|
||||
* the type of policy to return
|
||||
*
|
||||
* @return the policy
|
||||
* @param clazz
|
||||
* the type of policy to return
|
||||
*/
|
||||
<T extends StrolchPolicy> T getPolicy(PolicyContainer element, Class<T> clazz);
|
||||
|
||||
/**
|
||||
* Instantiates the policy using the given {@link PolicyDef}
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue