Class CriterionPredicateRegistry<T>
- java.lang.Object
-
- net.shibboleth.utilities.java.support.resolver.CriterionPredicateRegistry<T>
-
- Type Parameters:
T- the target type which the returned predicates evaluate
public class CriterionPredicateRegistry<T> extends Object
A registry which manages mappings from types ofCriterionto types ofPredicatewhich can evaluate that criterion's data against a particular target type.Each predicate's implementation that is registered MUST implement a single-arg constructor which takes an instance of the
Criterionto be evaluated. The predicate instance is instantiated reflectively based on this requirement.
-
-
Constructor Summary
Constructors Constructor Description CriterionPredicateRegistry()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearRegistry()Clear all mappings from the registry.voidderegister(Class<? extends Criterion> criterionClass)Deregister a criterion-evaluator mapping.Predicate<T>getPredicate(Criterion criterion)Get an instance ofPredicatewhich can evaluate the supplied criterion's requirements against a target of the specified type.voidloadMappings(String classpathResource)Load criterion -> predicate mappings from a classpath resource.voidloadMappings(Properties mappings)Load a set of criterion -> predicate mappings from the supplied properties set.protected Class<? extends Predicate<T>>lookup(Class<? extends Criterion> clazz)Lookup the predicate class type which is registered for the specified Criterion class.voidregister(Class<? extends Criterion> criterionClass, Class<? extends Predicate<T>> predicateClass)Register aPredicateclass for a criterion class.
-
-
-
Method Detail
-
getPredicate
@Nullable public Predicate<T> getPredicate(@Nonnull Criterion criterion) throws ResolverException
Get an instance ofPredicatewhich can evaluate the supplied criterion's requirements against a target of the specified type.- Parameters:
criterion- the criterion to be evaluated- Returns:
- an predicate instance representing the specified criterion's requirements
- Throws:
ResolverException- thrown if there is an error reflectively instantiating a new instance of the predicate type based on class information stored in the registry
-
lookup
@Nullable protected Class<? extends Predicate<T>> lookup(@Nonnull Class<? extends Criterion> clazz)
Lookup the predicate class type which is registered for the specified Criterion class.- Parameters:
clazz- the Criterion class subtype to lookup- Returns:
- the registered predicate class type
-
register
public void register(@Nonnull Class<? extends Criterion> criterionClass, @Nonnull Class<? extends Predicate<T>> predicateClass)Register aPredicateclass for a criterion class.- Parameters:
criterionClass- class subtype ofCriterionpredicateClass- the predicate class type
-
deregister
public void deregister(@Nonnull Class<? extends Criterion> criterionClass)Deregister a criterion-evaluator mapping.- Parameters:
criterionClass- class subtype ofCriterion
-
clearRegistry
public void clearRegistry()
Clear all mappings from the registry.
-
loadMappings
public void loadMappings(@Nonnull String classpathResource)Load criterion -> predicate mappings from a classpath resource.- Parameters:
classpathResource- the classpath resource path from which to load mapping properites
-
loadMappings
public void loadMappings(@Nonnull Properties mappings)Load a set of criterion -> predicate mappings from the supplied properties set.- Parameters:
mappings- properties set where the key is the criterion class name, the value is the predicate class name
-
-