Search in sources :

Example 1 with NoOpPropertyAnnotationHandler

use of org.gradle.api.internal.tasks.properties.annotations.NoOpPropertyAnnotationHandler in project gradle by gradle.

the class InspectionSchemeFactory method inspectionScheme.

/**
 * Creates a new {@link InspectionScheme} with the given annotations enabled and using the given instantiation scheme.
 */
public InspectionScheme inspectionScheme(Collection<Class<? extends Annotation>> annotations, Collection<Class<? extends Annotation>> propertyModifiers, InstantiationScheme instantiationScheme) {
    ImmutableList.Builder<PropertyAnnotationHandler> propertyHandlers = ImmutableList.builderWithExpectedSize(annotations.size());
    for (Class<? extends Annotation> annotation : annotations) {
        PropertyAnnotationHandler propertyHandler = allKnownPropertyHandlers.get(annotation);
        if (propertyHandler == null) {
            throw new IllegalArgumentException(String.format("@%s is not a registered property type annotation.", annotation.getSimpleName()));
        }
        propertyHandlers.add(propertyHandler);
    }
    for (Class<? extends Annotation> annotation : instantiationScheme.getInjectionAnnotations()) {
        if (!annotations.contains(annotation)) {
            propertyHandlers.add(new NoOpPropertyAnnotationHandler(annotation));
        }
    }
    return new InspectionSchemeImpl(allKnownTypeHandlers, propertyHandlers.build(), propertyModifiers, typeAnnotationMetadataStore, cacheFactory);
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) PropertyAnnotationHandler(org.gradle.api.internal.tasks.properties.annotations.PropertyAnnotationHandler) NoOpPropertyAnnotationHandler(org.gradle.api.internal.tasks.properties.annotations.NoOpPropertyAnnotationHandler) NoOpPropertyAnnotationHandler(org.gradle.api.internal.tasks.properties.annotations.NoOpPropertyAnnotationHandler)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 NoOpPropertyAnnotationHandler (org.gradle.api.internal.tasks.properties.annotations.NoOpPropertyAnnotationHandler)1 PropertyAnnotationHandler (org.gradle.api.internal.tasks.properties.annotations.PropertyAnnotationHandler)1