Search in sources :

Example 1 with BeanPropertyContext

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

the class AbstractNestedRuntimeBeanNode method visitProperties.

protected void visitProperties(PropertyVisitor visitor, final Queue<RuntimeBeanNode<?>> queue, final RuntimeBeanNodeFactory nodeFactory, TypeValidationContext validationContext) {
    TypeMetadata typeMetadata = getTypeMetadata();
    typeMetadata.visitValidationFailures(getPropertyName(), validationContext);
    for (PropertyMetadata propertyMetadata : typeMetadata.getPropertiesMetadata()) {
        PropertyAnnotationHandler annotationHandler = typeMetadata.getAnnotationHandlerFor(propertyMetadata);
        if (annotationHandler.shouldVisit(visitor)) {
            String propertyName = getQualifiedPropertyName(propertyMetadata.getPropertyName());
            PropertyValue value = new BeanPropertyValue(getBean(), propertyMetadata.getGetterMethod());
            annotationHandler.visitPropertyValue(propertyName, value, propertyMetadata, visitor, new BeanPropertyContext() {

                @Override
                public void addNested(String propertyName, Object bean) {
                    queue.add(nodeFactory.create(AbstractNestedRuntimeBeanNode.this, propertyName, bean));
                }
            });
        }
    }
}
Also used : TypeMetadata(org.gradle.api.internal.tasks.properties.TypeMetadata) PropertyAnnotationHandler(org.gradle.api.internal.tasks.properties.annotations.PropertyAnnotationHandler) BeanPropertyContext(org.gradle.api.internal.tasks.properties.BeanPropertyContext) PropertyMetadata(org.gradle.internal.reflect.PropertyMetadata) PropertyValue(org.gradle.api.internal.tasks.properties.PropertyValue)

Example 2 with BeanPropertyContext

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

the class AbstractNestedRuntimeBeanNode method visitProperties.

public void visitProperties(PropertyVisitor visitor, PropertySpecFactory specFactory, final Queue<RuntimeBeanNode<?>> queue, final RuntimeBeanNodeFactory nodeFactory) {
    TypeMetadata typeMetadata = getTypeMetadata();
    for (final PropertyMetadata propertyMetadata : typeMetadata.getPropertiesMetadata()) {
        PropertyValueVisitor propertyValueVisitor = propertyMetadata.getPropertyValueVisitor();
        if (propertyValueVisitor == null) {
            continue;
        }
        String propertyName = getQualifiedPropertyName(propertyMetadata.getFieldName());
        PropertyValue propertyValue = new DefaultPropertyValue(propertyName, propertyMetadata.getAnnotations(), getBean(), propertyMetadata.getMethod());
        propertyValueVisitor.visitPropertyValue(propertyValue, visitor, specFactory, new BeanPropertyContext() {

            @Override
            public void addNested(String propertyName, Object bean) {
                queue.add(nodeFactory.create(AbstractNestedRuntimeBeanNode.this, propertyName, bean));
            }
        });
    }
}
Also used : TypeMetadata(org.gradle.api.internal.tasks.properties.TypeMetadata) BeanPropertyContext(org.gradle.api.internal.tasks.properties.BeanPropertyContext) PropertyMetadata(org.gradle.api.internal.tasks.properties.PropertyMetadata) PropertyValue(org.gradle.api.internal.tasks.properties.PropertyValue) PropertyValueVisitor(org.gradle.api.internal.tasks.properties.PropertyValueVisitor)

Aggregations

BeanPropertyContext (org.gradle.api.internal.tasks.properties.BeanPropertyContext)2 PropertyValue (org.gradle.api.internal.tasks.properties.PropertyValue)2 TypeMetadata (org.gradle.api.internal.tasks.properties.TypeMetadata)2 PropertyMetadata (org.gradle.api.internal.tasks.properties.PropertyMetadata)1 PropertyValueVisitor (org.gradle.api.internal.tasks.properties.PropertyValueVisitor)1 PropertyAnnotationHandler (org.gradle.api.internal.tasks.properties.annotations.PropertyAnnotationHandler)1 PropertyMetadata (org.gradle.internal.reflect.PropertyMetadata)1