Search in sources :

Example 1 with Predicate

use of org.apache.felix.ipojo.manipulator.spi.Predicate in project felix by apache.

the class Predicates method onlySupportedElements.

/**
 * Restrict to the supported {@link ElementType}(s) of the annotation (use the @Target, if provided).
 * @param annotationType annotation to explore
 */
public static Predicate onlySupportedElements(final Class<? extends Annotation> annotationType) {
    Target target = annotationType.getAnnotation(Target.class);
    if (target == null) {
        return alwaysTrue();
    }
    Collection<Predicate> supportedTypes = new HashSet<Predicate>();
    for (ElementType type : target.value()) {
        supportedTypes.add(on(type));
    }
    return or(supportedTypes);
}
Also used : Target(java.lang.annotation.Target) ElementType(java.lang.annotation.ElementType) Predicate(org.apache.felix.ipojo.manipulator.spi.Predicate) HashSet(java.util.HashSet)

Aggregations

ElementType (java.lang.annotation.ElementType)1 Target (java.lang.annotation.Target)1 HashSet (java.util.HashSet)1 Predicate (org.apache.felix.ipojo.manipulator.spi.Predicate)1