Search in sources :

Example 1 with AnnotationUtils

use of io.micronaut.annotation.processing.AnnotationUtils in project micronaut-core by micronaut-projects.

the class JavaClassElement method getDefaultConstructor.

@Override
public Optional<MethodElement> getDefaultConstructor() {
    final AnnotationUtils annotationUtils = visitorContext.getAnnotationUtils();
    final ModelUtils modelUtils = visitorContext.getModelUtils();
    ExecutableElement method = modelUtils.defaultStaticCreatorFor(classElement, annotationUtils);
    if (method == null) {
        if (isInner() && !isStatic()) {
            // only static inner classes can be constructed
            return Optional.empty();
        }
        method = modelUtils.defaultConstructorFor(classElement);
    }
    return createMethodElement(annotationUtils, method);
}
Also used : ModelUtils(io.micronaut.annotation.processing.ModelUtils) JavaModelUtils(io.micronaut.inject.processing.JavaModelUtils) AnnotationUtils(io.micronaut.annotation.processing.AnnotationUtils) ExecutableElement(javax.lang.model.element.ExecutableElement)

Example 2 with AnnotationUtils

use of io.micronaut.annotation.processing.AnnotationUtils in project micronaut-core by micronaut-projects.

the class JavaClassElement method getPrimaryConstructor.

@NonNull
@Override
public Optional<MethodElement> getPrimaryConstructor() {
    final AnnotationUtils annotationUtils = visitorContext.getAnnotationUtils();
    final ModelUtils modelUtils = visitorContext.getModelUtils();
    ExecutableElement method = modelUtils.staticCreatorFor(classElement, annotationUtils);
    if (method == null) {
        if (isInner() && !isStatic()) {
            // only static inner classes can be constructed
            return Optional.empty();
        }
        method = modelUtils.concreteConstructorFor(classElement, annotationUtils);
    }
    return createMethodElement(annotationUtils, method);
}
Also used : ModelUtils(io.micronaut.annotation.processing.ModelUtils) JavaModelUtils(io.micronaut.inject.processing.JavaModelUtils) AnnotationUtils(io.micronaut.annotation.processing.AnnotationUtils) ExecutableElement(javax.lang.model.element.ExecutableElement) NonNull(io.micronaut.core.annotation.NonNull)

Example 3 with AnnotationUtils

use of io.micronaut.annotation.processing.AnnotationUtils in project micronaut-core by micronaut-projects.

the class AbstractJavaElement method annotate.

@Override
public <T extends Annotation> io.micronaut.inject.ast.Element annotate(AnnotationValue<T> annotationValue) {
    ArgumentUtils.requireNonNull("annotationValue", annotationValue);
    AnnotationUtils annotationUtils = visitorContext.getAnnotationUtils();
    this.annotationMetadata = annotationUtils.newAnnotationBuilder().annotate(annotationMetadata, annotationValue);
    updateMetadataCaches();
    return this;
}
Also used : AnnotationUtils(io.micronaut.annotation.processing.AnnotationUtils)

Example 4 with AnnotationUtils

use of io.micronaut.annotation.processing.AnnotationUtils in project micronaut-core by micronaut-projects.

the class JavaBeanDefinitionBuilder method removeStereotype.

@Override
protected void removeStereotype(AnnotationMetadata annotationMetadata, String annotationType) {
    ArgumentUtils.requireNonNull("annotationType", annotationType);
    AnnotationUtils annotationUtils = javaVisitorContext.getAnnotationUtils();
    annotationUtils.newAnnotationBuilder().removeStereotype(annotationMetadata, annotationType);
}
Also used : AnnotationUtils(io.micronaut.annotation.processing.AnnotationUtils)

Example 5 with AnnotationUtils

use of io.micronaut.annotation.processing.AnnotationUtils in project micronaut-core by micronaut-projects.

the class AbstractJavaElement method removeStereotype.

@Override
public io.micronaut.inject.ast.Element removeStereotype(@NonNull String annotationType) {
    ArgumentUtils.requireNonNull("annotationType", annotationType);
    try {
        AnnotationUtils annotationUtils = visitorContext.getAnnotationUtils();
        this.annotationMetadata = annotationUtils.newAnnotationBuilder().removeStereotype(annotationMetadata, annotationType);
        return this;
    } finally {
        updateMetadataCaches();
    }
}
Also used : AnnotationUtils(io.micronaut.annotation.processing.AnnotationUtils)

Aggregations

AnnotationUtils (io.micronaut.annotation.processing.AnnotationUtils)12 ModelUtils (io.micronaut.annotation.processing.ModelUtils)2 NonNull (io.micronaut.core.annotation.NonNull)2 JavaModelUtils (io.micronaut.inject.processing.JavaModelUtils)2 ExecutableElement (javax.lang.model.element.ExecutableElement)2