[New] Added PolicyHandler.isPolicyDefAvailable()
This commit is contained in:
parent
368247726b
commit
8e3b22b3e3
|
@ -81,6 +81,7 @@ public class DefaultPolicyHandler extends StrolchComponent implements PolicyHand
|
|||
|
||||
@Override
|
||||
public <T extends StrolchPolicy> T getPolicy(PolicyDef policyDef, StrolchTransaction tx) {
|
||||
DBC.PRE.assertNotNull("policyDef must not be null!", policyDef);
|
||||
DBC.PRE.assertNotNull("tx must not be null!", tx);
|
||||
try {
|
||||
|
||||
|
@ -94,6 +95,19 @@ public class DefaultPolicyHandler extends StrolchComponent implements PolicyHand
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPolicyDefAvailable(PolicyDef policyDef) {
|
||||
DBC.PRE.assertNotNull("policyDef must not be null!", policyDef);
|
||||
|
||||
if (policyDef instanceof KeyPolicyDef)
|
||||
return this.classByTypeMap.containsElement(policyDef.getType(), policyDef.getValue());
|
||||
|
||||
if (policyDef instanceof JavaPolicyDef)
|
||||
return true;
|
||||
|
||||
throw new IllegalArgumentException("Unhandled PolicyDev instance " + policyDef.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Class<T> visit(JavaPolicyDef policyDef) throws ClassNotFoundException {
|
||||
String value = policyDef.getValue();
|
||||
|
|
|
@ -53,5 +53,15 @@ public interface PolicyHandler {
|
|||
*
|
||||
* @return the instantiated instance of the referenced policy
|
||||
*/
|
||||
public <T extends StrolchPolicy> T getPolicy(PolicyDef policyDef, StrolchTransaction tx);
|
||||
<T extends StrolchPolicy> T getPolicy(PolicyDef policyDef, StrolchTransaction tx);
|
||||
|
||||
/**
|
||||
* Returns true, if the policy definition is known
|
||||
*
|
||||
* @param policyDef
|
||||
* the policy definition to check for
|
||||
*
|
||||
* @return true if the policy definition is known, false otherwise
|
||||
*/
|
||||
boolean isPolicyDefAvailable(PolicyDef policyDef);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue