[New] Added PolicyHandler.getPolicyTypes() and .getPolicyKeysByType()
This commit is contained in:
parent
dacc890e8c
commit
b6e9fb6b99
|
@ -19,7 +19,10 @@ import java.io.File;
|
|||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import li.strolch.agent.api.ComponentContainer;
|
||||
import li.strolch.agent.api.StrolchComponent;
|
||||
|
@ -71,6 +74,24 @@ public class DefaultPolicyHandler extends StrolchComponent implements PolicyHand
|
|||
super.initialize(configuration);
|
||||
}
|
||||
|
||||
public Set<String> getPolicyTypes() {
|
||||
return new HashSet<>(this.classByTypeMap.keySet());
|
||||
}
|
||||
|
||||
public Set<String> getPolicyKeysByType(String type) {
|
||||
Map<String, Class<? extends StrolchPolicy>> byType = this.classByTypeMap.getMap(type);
|
||||
if (byType == null)
|
||||
return Collections.emptySet();
|
||||
return new HashSet<>(byType.keySet());
|
||||
}
|
||||
|
||||
public Set<String> getPolicyKeysByType(Class<?> clazz) {
|
||||
Map<String, Class<? extends StrolchPolicy>> byType = this.classByTypeMap.getMap(clazz.getSimpleName());
|
||||
if (byType == null)
|
||||
return Collections.emptySet();
|
||||
return new HashSet<>(byType.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends StrolchPolicy> T getPolicy(PolicyDef policyDef, StrolchTransaction tx) {
|
||||
DBC.PRE.assertNotNull("policyDef must not be null!", policyDef);
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
package li.strolch.policy;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import li.strolch.model.policy.PolicyDef;
|
||||
import li.strolch.model.policy.PolicyDefVisitor;
|
||||
import li.strolch.persistence.api.StrolchTransaction;
|
||||
|
@ -32,6 +34,33 @@ import li.strolch.persistence.api.StrolchTransaction;
|
|||
*/
|
||||
public interface PolicyHandler {
|
||||
|
||||
/**
|
||||
* The type of policies known by this {@link PolicyHandler}
|
||||
*
|
||||
* @return types of policies known by this {@link PolicyHandler}
|
||||
*/
|
||||
Set<String> getPolicyTypes();
|
||||
|
||||
/**
|
||||
* Returns the keys defined for the given policy type
|
||||
*
|
||||
* @param type
|
||||
* the type of policy for which to return the keys
|
||||
*
|
||||
* @return the keys defined for the given policy type
|
||||
*/
|
||||
Set<String> getPolicyKeysByType(Class<?> type);
|
||||
|
||||
/**
|
||||
* Returns the keys defined for the given policy type
|
||||
*
|
||||
* @param type
|
||||
* the type of policy for which to return the keys
|
||||
*
|
||||
* @return the keys defined for the given policy type
|
||||
*/
|
||||
Set<String> getPolicyKeysByType(String type);
|
||||
|
||||
/**
|
||||
* Instantiates the actual policy by resolving the {@link PolicyDef} using a {@link PolicyDefVisitor}
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue