use of io.micronaut.inject.annotation.MutableAnnotationMetadata in project micronaut-core by micronaut-projects.
the class BeanDefinitionWriter method pushInvokeGetPropertyPlaceholderValueForField.
private void pushInvokeGetPropertyPlaceholderValueForField(GeneratorAdapter injectMethodVisitor, FieldElement fieldElement, String value) {
// load 'this'
injectMethodVisitor.loadThis();
// 1st argument load BeanResolutionContext
injectMethodVisitor.loadArg(0);
// 2nd argument load BeanContext
injectMethodVisitor.loadArg(1);
// 3rd argument the method index
MutableAnnotationMetadata mutableAnnotationMetadata = ((MutableAnnotationMetadata) fieldElement.getAnnotationMetadata()).clone();
removeAnnotations(mutableAnnotationMetadata, PropertySource.class.getName(), Property.class.getName());
if (keepConfPropInjectPoints) {
resolveFieldArgument(injectMethodVisitor, currentFieldIndex);
} else {
pushCreateArgument(beanFullClassName, beanDefinitionType, classWriter, injectMethodVisitor, fieldElement.getName(), fieldElement.getGenericType(), mutableAnnotationMetadata, fieldElement.getGenericType().getTypeArguments(), new HashMap<>(), loadTypeMethods);
}
// 4th property value
injectMethodVisitor.push(value);
pushInvokeMethodOnSuperClass(injectMethodVisitor, GET_PROPERTY_PLACEHOLDER_VALUE_FOR_FIELD);
// cast the return value to the correct type
pushCastToType(injectMethodVisitor, fieldElement.getType());
}
use of io.micronaut.inject.annotation.MutableAnnotationMetadata in project micronaut-core by micronaut-projects.
the class BeanDefinitionWriter method pushInvokeGetPropertyValueForSetter.
private void pushInvokeGetPropertyValueForSetter(GeneratorAdapter injectMethodVisitor, String setterName, ParameterElement entry, String value) {
// load 'this'
injectMethodVisitor.loadThis();
// 1st argument load BeanResolutionContext
injectMethodVisitor.loadArg(0);
// 2nd argument load BeanContext
injectMethodVisitor.loadArg(1);
// 3rd argument the method name
injectMethodVisitor.push(setterName);
AnnotationMetadata annotationMetadata;
if (entry.getAnnotationMetadata() instanceof MutableAnnotationMetadata) {
annotationMetadata = ((MutableAnnotationMetadata) entry.getAnnotationMetadata()).clone();
removeAnnotations(annotationMetadata, PropertySource.class.getName(), Property.class.getName());
} else {
annotationMetadata = entry.getAnnotationMetadata();
}
// 4th argument the argument
if (keepConfPropInjectPoints) {
resolveMethodArgument(injectMethodVisitor, currentMethodIndex, 0);
} else {
pushCreateArgument(beanFullClassName, beanDefinitionType, classWriter, injectMethodVisitor, entry.getName(), entry.getGenericType(), annotationMetadata, entry.getGenericType().getTypeArguments(), new HashMap<>(), loadTypeMethods);
}
// 5th property value
injectMethodVisitor.push(value);
// 6 cli property name
injectMethodVisitor.push(getCliPrefix(entry.getName()));
pushInvokeMethodOnSuperClass(injectMethodVisitor, GET_PROPERTY_VALUE_FOR_SETTER);
// cast the return value to the correct type
pushCastToType(injectMethodVisitor, entry);
}
use of io.micronaut.inject.annotation.MutableAnnotationMetadata in project micronaut-core by micronaut-projects.
the class BeanDefinitionWriter method pushInvokeGetPropertyPlaceholderValueForSetter.
private void pushInvokeGetPropertyPlaceholderValueForSetter(GeneratorAdapter injectMethodVisitor, String setterName, ParameterElement entry, String value) {
// load 'this'
injectMethodVisitor.loadThis();
// 1st argument load BeanResolutionContext
injectMethodVisitor.loadArg(0);
// 2nd argument load BeanContext
injectMethodVisitor.loadArg(1);
// 3rd argument the method name
injectMethodVisitor.push(setterName);
// 4th argument the argument
AnnotationMetadata annotationMetadata;
if (entry.getAnnotationMetadata() instanceof MutableAnnotationMetadata) {
annotationMetadata = ((MutableAnnotationMetadata) entry.getAnnotationMetadata()).clone();
removeAnnotations(annotationMetadata, PropertySource.class.getName(), Property.class.getName());
} else {
annotationMetadata = entry.getAnnotationMetadata();
}
if (keepConfPropInjectPoints) {
resolveMethodArgument(injectMethodVisitor, currentMethodIndex, 0);
} else {
pushCreateArgument(beanFullClassName, beanDefinitionType, classWriter, injectMethodVisitor, entry.getName(), entry.getGenericType(), annotationMetadata, entry.getGenericType().getTypeArguments(), new HashMap<>(), loadTypeMethods);
}
// 5th property value
injectMethodVisitor.push(value);
// 6 cli property name
injectMethodVisitor.push(getCliPrefix(entry.getName()));
pushInvokeMethodOnSuperClass(injectMethodVisitor, GET_PROPERTY_PLACEHOLDER_VALUE_FOR_SETTER);
// cast the return value to the correct type
pushCastToType(injectMethodVisitor, entry);
}
use of io.micronaut.inject.annotation.MutableAnnotationMetadata in project micronaut-core by micronaut-projects.
the class ReflectParameterElement method annotate.
@NonNull
@Override
public <T extends Annotation> Element annotate(@NonNull String annotationType, @NonNull Consumer<AnnotationValueBuilder<T>> consumer) {
if (annotationMetadata == AnnotationMetadata.EMPTY_METADATA) {
final MutableAnnotationMetadata mutableAnnotationMetadata = new MutableAnnotationMetadata();
this.annotationMetadata = mutableAnnotationMetadata;
AnnotationValueBuilder<T> builder = AnnotationValue.builder(annotationType);
consumer.accept(builder);
mutableAnnotationMetadata.addDeclaredAnnotation(annotationType, builder.build().getValues());
} else {
AnnotationValueBuilder<T> builder = AnnotationValue.builder(annotationType);
consumer.accept(builder);
this.annotationMetadata = DefaultAnnotationMetadata.mutateMember(annotationMetadata, annotationType, builder.build().getValues());
}
return this;
}
use of io.micronaut.inject.annotation.MutableAnnotationMetadata in project micronaut-core by micronaut-projects.
the class BeanDefinitionWriter method pushInvokeGetPropertyValueForField.
private void pushInvokeGetPropertyValueForField(GeneratorAdapter injectMethodVisitor, FieldElement fieldElement, String value) {
// load 'this'
injectMethodVisitor.loadThis();
// 1st argument load BeanResolutionContext
injectMethodVisitor.loadArg(0);
// 2nd argument load BeanContext
injectMethodVisitor.loadArg(1);
// 3rd argument the method index
MutableAnnotationMetadata mutableAnnotationMetadata = ((MutableAnnotationMetadata) fieldElement.getAnnotationMetadata()).clone();
removeAnnotations(mutableAnnotationMetadata, PropertySource.class.getName(), Property.class.getName());
if (keepConfPropInjectPoints) {
resolveFieldArgument(injectMethodVisitor, currentFieldIndex);
} else {
pushCreateArgument(beanFullClassName, beanDefinitionType, classWriter, injectMethodVisitor, fieldElement.getName(), fieldElement.getGenericType(), mutableAnnotationMetadata, fieldElement.getGenericType().getTypeArguments(), new HashMap<>(), loadTypeMethods);
}
// 4th property value
injectMethodVisitor.push(value);
// 5th cli property name
injectMethodVisitor.push(getCliPrefix(fieldElement.getName()));
pushInvokeMethodOnSuperClass(injectMethodVisitor, GET_PROPERTY_VALUE_FOR_FIELD);
// cast the return value to the correct type
pushCastToType(injectMethodVisitor, fieldElement.getType());
}
Aggregations