use of io.micronaut.inject.ast.ParameterElement in project micronaut-core by micronaut-projects.
the class BeanDefinitionWriter method applyConfigurationInjectionIfNecessary.
private void applyConfigurationInjectionIfNecessary(MethodElement constructor) {
final boolean isRecordConfig = isRecordConfig(constructor);
if (isRecordConfig || constructor.hasAnnotation(ConfigurationInject.class)) {
final List<String> injectionTypes = Arrays.asList(Property.class.getName(), Value.class.getName(), Parameter.class.getName(), AnnotationUtil.QUALIFIER, AnnotationUtil.INJECT);
if (isRecordConfig) {
final List<PropertyElement> beanProperties = constructor.getDeclaringType().getBeanProperties();
final ParameterElement[] parameters = constructor.getParameters();
if (beanProperties.size() == parameters.length) {
for (int i = 0; i < parameters.length; i++) {
ParameterElement parameter = parameters[i];
final PropertyElement bp = beanProperties.get(i);
final AnnotationMetadata beanPropertyMetadata = bp.getAnnotationMetadata();
AnnotationMetadata annotationMetadata = parameter.getAnnotationMetadata();
if (injectionTypes.stream().noneMatch(beanPropertyMetadata::hasStereotype)) {
processConfigurationConstructorParameter(parameter, annotationMetadata);
}
if (annotationMetadata.hasStereotype(ANN_CONSTRAINT)) {
setValidated(true);
}
}
} else {
processConfigurationInjectionConstructor(constructor, injectionTypes);
}
} else {
processConfigurationInjectionConstructor(constructor, injectionTypes);
}
}
}
use of io.micronaut.inject.ast.ParameterElement in project micronaut-core by micronaut-projects.
the class BeanDefinitionWriter method visitExecutableMethod.
/**
* Visit a method that is to be made executable allow invocation of said method without reflection.
*
* @param declaringType The declaring type of the method. Either a Class or a string representing the
* name of the type
* @param methodElement The method element
* @param interceptedProxyClassName The intercepted proxy class name
* @param interceptedProxyBridgeMethodName The intercepted proxy bridge method name
* @return The index of a new method.
*/
public int visitExecutableMethod(TypedElement declaringType, MethodElement methodElement, String interceptedProxyClassName, String interceptedProxyBridgeMethodName) {
AnnotationMetadata annotationMetadata = methodElement.getAnnotationMetadata();
DefaultAnnotationMetadata.contributeDefaults(this.annotationMetadata, annotationMetadata);
for (ParameterElement parameterElement : methodElement.getSuspendParameters()) {
DefaultAnnotationMetadata.contributeDefaults(this.annotationMetadata, parameterElement.getAnnotationMetadata());
DefaultAnnotationMetadata.contributeRepeatable(this.annotationMetadata, parameterElement.getGenericType());
}
if (executableMethodsDefinitionWriter == null) {
executableMethodsDefinitionWriter = new ExecutableMethodsDefinitionWriter(beanDefinitionName, getBeanDefinitionReferenceClassName(), originatingElements);
}
return executableMethodsDefinitionWriter.visitExecutableMethod(declaringType, methodElement, interceptedProxyClassName, interceptedProxyBridgeMethodName);
}
Aggregations