@Internal public class BeanDefinitionWriter extends AbstractClassFileWriter implements BeanDefinitionVisitor, BeanElement, Toggleable
Responsible for building BeanDefinition instances at compile time. Uses ASM build the class definition.
Should be used from AST frameworks to build bean definitions from source code data.
For example:
BeanDefinitionWriter writer = new BeanDefinitionWriter("my.package", "MyClass", "javax.inject.Singleton", true)
writer.visitBeanDefinitionConstructor()
writer.visitFieldInjectionPoint("my.Qualifier", false, "my.package.MyDependency", "myfield" )
writer.visitBeanDefinitionEnd()
writer.writeTo(new File(..))
BeanDefinition| Modifier and Type | Class and Description |
|---|---|
static class |
BeanDefinitionWriter.MethodVisitData
Data used when visiting method.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
CLASS_SUFFIX |
static String |
OMIT_CONFPROP_INJECTION_POINTS |
ARRAY_PATTERN, CONSTRUCTOR_NAME, DEFAULT_MAX_STACK, DESCRIPTOR_DEFAULT_CONSTRUCTOR, METHOD_CREATE_ARGUMENT_SIMPLE, METHOD_CREATE_TYPE_VARIABLE_SIMPLE, METHOD_DEFAULT_CONSTRUCTOR, METHOD_GENERIC_PLACEHOLDER_SIMPLE, originatingElements, TYPE_ARGUMENT, TYPE_ARGUMENT_ARRAY, TYPE_CLASS, TYPE_GENERATED, TYPE_OBJECT, ZERO_ARGUMENTS_CONSTANTPROXY_SUFFIXEMPTY_ELEMENT_ARRAYCLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBEREMPTYAALOAD, AASTORE, ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_MANDATED, ACC_MODULE, ACC_NATIVE, ACC_OPEN, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_RECORD, ACC_STATIC, ACC_STATIC_PHASE, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_TRANSITIVE, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASM10_EXPERIMENTAL, ASM4, ASM5, ASM6, ASM7, ASM8, ASM9, ASTORE, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DMUL, DNEG, DOUBLE, DREM, DRETURN, DSTORE, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F_APPEND, F_CHOP, F_FULL, F_NEW, F_SAME, F_SAME1, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FLOAT, FMUL, FNEG, FREM, FRETURN, FSTORE, FSUB, GETFIELD, GETSTATIC, GOTO, H_GETFIELD, H_GETSTATIC, H_INVOKEINTERFACE, H_INVOKESPECIAL, H_INVOKESTATIC, H_INVOKEVIRTUAL, H_NEWINVOKESPECIAL, H_PUTFIELD, H_PUTSTATIC, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, IMUL, INEG, INSTANCEOF, INTEGER, INVOKEDYNAMIC, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISUB, IUSHR, IXOR, JSR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDIV, LLOAD, LMUL, LNEG, LONG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, NULL, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, SOURCE_DEPRECATED, SOURCE_MASK, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, TOP, UNINITIALIZED_THIS, V_PREVIEW, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7, V1_8, V10, V11, V12, V13, V14, V15, V16, V17, V18, V9| Constructor and Description |
|---|
BeanDefinitionWriter(ClassElement classElement,
ConfigurationMetadataBuilder<?> metadataBuilder,
VisitorContext visitorContext)
Creates a bean definition writer.
|
BeanDefinitionWriter(ClassElement classElement,
OriginatingElements originatingElements,
ConfigurationMetadataBuilder<?> metadataBuilder,
VisitorContext visitorContext)
Creates a bean definition writer.
|
BeanDefinitionWriter(Element beanProducingElement,
OriginatingElements originatingElements,
ConfigurationMetadataBuilder<?> metadataBuilder,
VisitorContext visitorContext,
Integer uniqueIdentifier)
Creates a bean definition writer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
accept(ClassWriterOutputVisitor visitor)
Accept a ClassWriterOutputVisitor to write this writer to disk.
|
BeanElementBuilder |
addAssociatedBean(ClassElement type,
VisitorContext visitorContext)
This method adds an associated bean using this class element as the originating element.
|
<T extends Annotation> |
annotate(String annotationType,
Consumer<AnnotationValueBuilder<T>> consumer)
Annotate this element with the given annotation type.
|
AnnotationMetadata |
getAnnotationMetadata()
Supplies the metadata.
|
String |
getBeanDefinitionName() |
String |
getBeanDefinitionReferenceClassName() |
String |
getBeanSimpleName() |
String |
getBeanTypeName() |
Set<ClassElement> |
getBeanTypes()
The type names produced by the bean.
|
org.objectweb.asm.ClassVisitor |
getClassWriter() |
ClassElement |
getDeclaringClass()
Returns the declaring
ClassElement which may differ
from the BeanElement.getBeanTypes() in the case of factory beans. |
ExecutableMethodsDefinitionWriter |
getExecutableMethodsWriter()
Returns
ExecutableMethodsDefinitionWriter of one exists. |
Collection<Element> |
getInjectionPoints()
Returns all of the injection points for the bean.
|
Optional<org.objectweb.asm.Type> |
getInterceptedType() |
String |
getName() |
Object |
getNativeType()
Returns the native underlying type.
|
Element[] |
getOriginatingElements() |
String |
getPackageName() |
List<BeanDefinitionWriter.MethodVisitData> |
getPostConstructMethodVisits() |
Element |
getProducingElement()
The element that produces the bean, this could be a
ClassElement for regular beans,
or either a MethodElement or FieldElement for factory beans. |
org.objectweb.asm.Type |
getProvidedType()
The provided type of the bean.
|
Collection<String> |
getQualifiers() |
Optional<String> |
getScope()
The scope of the bean.
|
ClassElement[] |
getTypeArguments() |
boolean |
isAbstract() |
boolean |
isEnabled() |
boolean |
isInterface() |
boolean |
isProtected() |
boolean |
isPublic() |
boolean |
isSingleton() |
boolean |
isValidated() |
Element |
removeAnnotation(String annotationType)
Removes an annotation of the given type from the element.
|
<T extends Annotation> |
removeAnnotationIf(Predicate<AnnotationValue<T>> predicate)
Removes all annotations that pass the given predicate.
|
Element |
removeStereotype(String annotationType)
Removes a stereotype of the given name from the element.
|
boolean |
requiresMethodProcessing()
By default, when the
BeanContext is started, the
BeanDefinition.getExecutableMethods() are not processed by registered
ExecutableMethodProcessor instances unless this method returns true. |
void |
setInterceptedType(String typeName)
Sets the name of the intercepted type.
|
void |
setRequiresMethodProcessing(boolean shouldPreProcess)
Sets whether the
BeanType.requiresMethodProcessing() returns true. |
void |
setValidated(boolean validated)
Make the bean definition as validated by javax.validation.
|
byte[] |
toByteArray() |
String |
toString() |
void |
visitAnnotationMemberPropertyInjectionPoint(TypedElement annotationMemberBeanType,
String annotationMemberProperty,
String requiredValue,
String notEqualsValue)
Visits an annotation injection point.
|
void |
visitBeanDefinitionConstructor(MethodElement constructor,
boolean requiresReflection,
VisitorContext visitorContext)
Visits the constructor used to create the bean definition.
|
void |
visitBeanDefinitionEnd()
Finalize the bean definition to the given output stream.
|
void |
visitBeanDefinitionInterface(Class<? extends BeanDefinition> interfaceType)
Visit a marker interface on the generated bean definition.
|
void |
visitBeanFactoryField(ClassElement factoryClass,
FieldElement factoryField)
In the case where the produced class is produced by a factory field annotated with
Bean this method should be called. |
void |
visitBeanFactoryMethod(ClassElement factoryClass,
MethodElement factoryMethod)
In the case where the produced class is produced by a factory method annotated with
Bean this method should be called. |
void |
visitConfigBuilderDurationMethod(String prefix,
ClassElement returnType,
String methodName,
String path)
Visit a configuration builder method that accepts a long and a TimeUnit.
|
void |
visitConfigBuilderEnd()
Finalize a configuration builder field.
|
void |
visitConfigBuilderField(ClassElement type,
String field,
AnnotationMetadata annotationMetadata,
ConfigurationMetadataBuilder metadataBuilder,
boolean isInterface)
Begin defining a configuration builder.
|
void |
visitConfigBuilderMethod(ClassElement type,
String methodName,
AnnotationMetadata annotationMetadata,
ConfigurationMetadataBuilder metadataBuilder,
boolean isInterface)
Begin defining a configuration builder.
|
void |
visitConfigBuilderMethod(String prefix,
ClassElement returnType,
String methodName,
ClassElement paramType,
Map<String,ClassElement> generics,
String path)
Visit a configuration builder method.
|
void |
visitDefaultConstructor(AnnotationMetadata annotationMetadata,
VisitorContext visitorContext)
Visits the constructor used to create the bean definition in the case where no constructor is present.
|
int |
visitExecutableMethod(TypedElement declaringType,
MethodElement methodElement,
String interceptedProxyClassName,
String interceptedProxyBridgeMethodName)
Visit a method that is to be made executable allow invocation of said method without reflection.
|
int |
visitExecutableMethod(TypedElement declaringBean,
MethodElement methodElement,
VisitorContext visitorContext)
Visit a method that is to be made executable allow invocation of said method without reflection.
|
void |
visitFieldInjectionPoint(TypedElement declaringType,
FieldElement fieldElement,
boolean requiresReflection)
Visits a field injection point.
|
void |
visitFieldValue(TypedElement declaringType,
FieldElement fieldElement,
boolean requiresReflection,
boolean isOptional)
Visits a field injection point.
|
void |
visitMethodInjectionPoint(TypedElement declaringType,
MethodElement methodElement,
boolean requiresReflection,
VisitorContext visitorContext)
Visits a method injection point.
|
void |
visitPostConstructMethod(TypedElement declaringType,
MethodElement methodElement,
boolean requiresReflection,
VisitorContext visitorContext)
Visits a method injection point.
|
void |
visitPreDestroyMethod(TypedElement declaringType,
MethodElement methodElement,
boolean requiresReflection,
VisitorContext visitorContext)
Visits a method injection point.
|
void |
visitSetterValue(TypedElement declaringType,
MethodElement methodElement,
boolean requiresReflection,
boolean isOptional)
Visits an injection point for a setter.
|
void |
visitSuperBeanDefinition(String name)
Alter the super class of this bean definition.
|
void |
visitSuperBeanDefinitionFactory(String beanName)
Alter the super class of this bean definition to use another factory bean.
|
void |
visitTypeArguments(Map<String,Map<String,ClassElement>> typeArguments)
Visits the type arguments for the bean.
|
addOriginatingElement, buildArgument, buildArgument, buildArgumentWithGenerics, buildArgumentWithGenerics, generateServiceDescriptor, getClassFileName, getConstructorDescriptor, getConstructorDescriptor, getConstructorDescriptor, getInternalName, getInternalNameForCast, getInternalNameForCast, getInternalNameForCast, getMethodDescriptor, getMethodDescriptor, getMethodDescriptor, getMethodDescriptor, getMethodDescriptorForReturnType, getMethodSignature, getObjectType, getOriginatingElement, getTypeDescriptor, getTypeDescriptor, getTypeDescriptor, getTypeDescriptor, getTypeReference, getTypeReferenceForName, getTypes, implementInterceptedTypeMethod, invokeConstructor, invokeInterfaceStaticMethod, invokeMethod, newClassWriterOutputVisitor, pushBoxPrimitiveIfNecessary, pushBoxPrimitiveIfNecessary, pushBoxPrimitiveIfNecessary, pushBuildArgumentsForMethod, pushCastToType, pushCastToType, pushCastToType, pushCreateArgument, pushMethodNameAndTypesArguments, pushNewArray, pushNewArray, pushNewInstance, pushReturnTypeArgument, pushReturnValue, pushStoreInArray, pushStoreInArray, pushStoreStringInArray, pushStoreTypeInArray, pushStringMapOf, pushTypeArgumentElements, returnVoid, startClass, startClass, startConstructor, startConstructor, startFinalClass, startProtectedMethod, startPublicClass, startPublicFinalClass, startPublicFinalMethodZeroArgs, startPublicMethod, startPublicMethod, startPublicMethodZeroArgs, startService, startService, visitStaticInitializer, writeBooleanMethod, writeClassToDisk, writeClassToDisk, writeToclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetOriginatingElement, writeToaddOriginatingElement, ofgetOriginatingElementannotate, annotate, annotate, annotate, getDescription, getDescription, getDocumentation, getModifiers, getSimpleName, isFinal, isPackagePrivate, isPrivate, isStatic, removeAnnotation, removeStereotypebooleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, doubleValue, doubleValue, doubleValue, enumValue, enumValue, enumValue, enumValue, enumValues, enumValues, enumValues, enumValues, findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, findRepeatableAnnotation, findRepeatableAnnotation, getAnnotation, getAnnotation, getAnnotationNameByStereotype, getAnnotationNameByStereotype, getAnnotationNames, getAnnotationNamesByStereotype, getAnnotationNamesByStereotype, getAnnotationType, getAnnotationType, getAnnotationTypeByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getStereotypeAnnotationNames, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, getValues, hasAnnotation, hasAnnotation, hasDeclaredAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasDeclaredStereotype, hasPropertyExpressions, hasSimpleAnnotation, hasSimpleDeclaredAnnotation, hasStereotype, hasStereotype, hasStereotype, hasStereotype, intValue, intValue, intValue, isAnnotationPresent, isDeclaredAnnotationPresent, isEmpty, isFalse, isFalse, isPresent, isPresent, isRepeatableAnnotation, isRepeatableAnnotation, isTrue, isTrue, longValue, longValue, stringValue, stringValue, stringValue, stringValue, stringValues, stringValues, stringValues, stringValues, synthesize, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByTypegetAnnotationValuesByName, getDeclaredAnnotationValuesByName, getValues, hasDeclaredStereotype, isAnnotationPresent, isDeclaredAnnotationPresentisDeclaredNonNull, isDeclaredNullable, isNonNull, isNullablepublic static final String OMIT_CONFPROP_INJECTION_POINTS
public static final String CLASS_SUFFIX
public BeanDefinitionWriter(ClassElement classElement, ConfigurationMetadataBuilder<?> metadataBuilder, VisitorContext visitorContext)
classElement - The class elementmetadataBuilder - The configuration metadata buildervisitorContext - The visitor contextpublic BeanDefinitionWriter(ClassElement classElement, OriginatingElements originatingElements, ConfigurationMetadataBuilder<?> metadataBuilder, VisitorContext visitorContext)
classElement - The class elementoriginatingElements - The originating elementsmetadataBuilder - The configuration metadata buildervisitorContext - The visitor contextpublic BeanDefinitionWriter(Element beanProducingElement, OriginatingElements originatingElements, ConfigurationMetadataBuilder<?> metadataBuilder, VisitorContext visitorContext, @Nullable Integer uniqueIdentifier)
beanProducingElement - The bean producing elementoriginatingElements - The originating elementsmetadataBuilder - The configuration metadata buildervisitorContext - The visitor contextuniqueIdentifier - An optional unique identifier to include in the bean namepublic boolean isEnabled()
isEnabled in interface Toggleable@Nullable public ExecutableMethodsDefinitionWriter getExecutableMethodsWriter()
ExecutableMethodsDefinitionWriter of one exists.ExecutableMethodsDefinitionWriter@NonNull public ClassElement[] getTypeArguments()
getTypeArguments in interface BeanDefinitionVisitor@NonNull public String getBeanDefinitionReferenceClassName()
getBeanDefinitionReferenceClassName in interface BeanDefinitionVisitorpublic final List<BeanDefinitionWriter.MethodVisitData> getPostConstructMethodVisits()
public org.objectweb.asm.ClassVisitor getClassWriter()
public boolean isInterface()
isInterface in interface BeanDefinitionVisitorpublic boolean isSingleton()
isSingleton in interface BeanDefinitionVisitorpublic void visitBeanDefinitionInterface(Class<? extends BeanDefinition> interfaceType)
BeanDefinitionVisitorvisitBeanDefinitionInterface in interface BeanDefinitionVisitorinterfaceType - The interface typepublic void visitSuperBeanDefinition(String name)
BeanDefinitionVisitorAbstractBeanDefinition.visitSuperBeanDefinition in interface BeanDefinitionVisitorname - The super typepublic void visitSuperBeanDefinitionFactory(String beanName)
BeanDefinitionVisitorvisitSuperBeanDefinitionFactory in interface BeanDefinitionVisitorbeanName - The bean namepublic String getBeanTypeName()
getBeanTypeName in interface BeanDefinitionVisitorpublic org.objectweb.asm.Type getProvidedType()
BeanDefinitionVisitorBeanDefinitionVisitor.getBeanTypeName(), except in the case of
factory beans which produce a different type.getProvidedType in interface BeanDefinitionVisitorpublic void setValidated(boolean validated)
BeanDefinitionVisitorsetValidated in interface BeanDefinitionVisitorvalidated - Whether the bean definition is validatedpublic void setInterceptedType(String typeName)
BeanDefinitionVisitorsetInterceptedType in interface BeanDefinitionVisitortypeName - The type namepublic Optional<org.objectweb.asm.Type> getInterceptedType()
getInterceptedType in interface BeanDefinitionVisitorpublic boolean isValidated()
isValidated in interface BeanDefinitionVisitorpublic String getBeanDefinitionName()
getBeanDefinitionName in interface BeanDefinitionVisitorpublic void visitBeanFactoryMethod(ClassElement factoryClass, MethodElement factoryMethod)
In the case where the produced class is produced by a factory method annotated with
Bean this method should be called.
factoryClass - The factory classfactoryMethod - The factory methodpublic void visitBeanFactoryField(ClassElement factoryClass, FieldElement factoryField)
In the case where the produced class is produced by a factory field annotated with
Bean this method should be called.
factoryClass - The factory classfactoryField - The factory fieldpublic void visitBeanDefinitionConstructor(MethodElement constructor, boolean requiresReflection, VisitorContext visitorContext)
visitBeanDefinitionConstructor in interface BeanDefinitionVisitorconstructor - The constructorrequiresReflection - Whether invoking the constructor requires reflectionvisitorContext - The visitor contextpublic void visitDefaultConstructor(AnnotationMetadata annotationMetadata, VisitorContext visitorContext)
BeanDefinitionVisitorvisitDefaultConstructor in interface BeanDefinitionVisitorannotationMetadata - The annotation metadata for the constructorvisitorContext - The visitor contextpublic void visitBeanDefinitionEnd()
visitBeanDefinitionEnd in interface BeanDefinitionVisitorpublic byte[] toByteArray()
public void accept(ClassWriterOutputVisitor visitor) throws IOException
AbstractClassFileWriteraccept in interface BeanDefinitionVisitoraccept in class AbstractClassFileWritervisitor - The ClassWriterOutputVisitorIOException - if there is an error writing to diskpublic void visitSetterValue(TypedElement declaringType, MethodElement methodElement, boolean requiresReflection, boolean isOptional)
BeanDefinitionVisitorvisitSetterValue in interface BeanDefinitionVisitordeclaringType - The declaring typemethodElement - The method elementrequiresReflection - Whether the setter requires reflectionisOptional - Whether the setter is optionalpublic void visitPostConstructMethod(TypedElement declaringType, MethodElement methodElement, boolean requiresReflection, VisitorContext visitorContext)
BeanDefinitionVisitorvisitPostConstructMethod in interface BeanDefinitionVisitordeclaringType - The declaring type of the method. Either a Class or a string representing
the name of the typemethodElement - The method elementrequiresReflection - Whether the method requires reflectionvisitorContext - The visitor contextpublic void visitPreDestroyMethod(TypedElement declaringType, MethodElement methodElement, boolean requiresReflection, VisitorContext visitorContext)
BeanDefinitionVisitorvisitPreDestroyMethod in interface BeanDefinitionVisitordeclaringType - The bean type of the methodmethodElement - The method elementrequiresReflection - Whether the method requires reflectionvisitorContext - The visitor contextpublic void visitMethodInjectionPoint(TypedElement declaringType, MethodElement methodElement, boolean requiresReflection, VisitorContext visitorContext)
BeanDefinitionVisitorvisitMethodInjectionPoint in interface BeanDefinitionVisitordeclaringType - The bean type of the methodmethodElement - The method elementrequiresReflection - Whether the method requires reflectionvisitorContext - The visitor contextpublic int visitExecutableMethod(TypedElement declaringBean, MethodElement methodElement, VisitorContext visitorContext)
BeanDefinitionVisitorvisitExecutableMethod in interface BeanDefinitionVisitordeclaringBean - The declaring bean of the method. Note this may differ from MemberElement.getDeclaringType() in the case of the method coming from a super class or interface.methodElement - The method elementvisitorContext - The visitor contextpublic int visitExecutableMethod(TypedElement declaringType, MethodElement methodElement, String interceptedProxyClassName, String interceptedProxyBridgeMethodName)
declaringType - The declaring type of the method. Either a Class or a string representing the
name of the typemethodElement - The method elementinterceptedProxyClassName - The intercepted proxy class nameinterceptedProxyBridgeMethodName - The intercepted proxy bridge method namepublic String getPackageName()
getPackageName in interface BeanDefinitionVisitorpublic String getBeanSimpleName()
getBeanSimpleName in interface BeanDefinitionVisitorpublic AnnotationMetadata getAnnotationMetadata()
AnnotationMetadataProviderAnnotationMetadata.EMPTY_METADATA.getAnnotationMetadata in interface AnnotationMetadataProvidergetAnnotationMetadata in interface BeanDefinitionVisitorpublic void visitConfigBuilderField(ClassElement type, String field, AnnotationMetadata annotationMetadata, ConfigurationMetadataBuilder metadataBuilder, boolean isInterface)
BeanDefinitionVisitorvisitConfigBuilderField in interface BeanDefinitionVisitortype - The type of the builderfield - The name of the field that represents the builderannotationMetadata - The annotation metadata associated with the fieldmetadataBuilder - The ConfigurationMetadataBuilderisInterface - Whether the builder type is an interface or notConfigurationBuilderpublic void visitConfigBuilderMethod(ClassElement type, String methodName, AnnotationMetadata annotationMetadata, ConfigurationMetadataBuilder metadataBuilder, boolean isInterface)
BeanDefinitionVisitorvisitConfigBuilderMethod in interface BeanDefinitionVisitortype - The type of the buildermethodName - The name of the method that returns the builderannotationMetadata - The annotation metadata associated with the fieldmetadataBuilder - The ConfigurationMetadataBuilderisInterface - Whether the builder type is an interface or notConfigurationBuilderpublic void visitConfigBuilderDurationMethod(String prefix, ClassElement returnType, String methodName, String path)
BeanDefinitionVisitorvisitConfigBuilderDurationMethod in interface BeanDefinitionVisitorprefix - The prefix used for the methodreturnType - The return typemethodName - The method namepath - The property pathConfigurationBuilderpublic void visitConfigBuilderMethod(String prefix, ClassElement returnType, String methodName, ClassElement paramType, Map<String,ClassElement> generics, String path)
BeanDefinitionVisitorvisitConfigBuilderMethod in interface BeanDefinitionVisitorprefix - The prefix used for the methodreturnType - The return typemethodName - The method nameparamType - The method typegenerics - The generic types of the methodpath - The property pathConfigurationBuilderpublic void visitConfigBuilderEnd()
BeanDefinitionVisitorvisitConfigBuilderEnd in interface BeanDefinitionVisitorConfigurationBuilderpublic void setRequiresMethodProcessing(boolean shouldPreProcess)
BeanDefinitionVisitorBeanType.requiresMethodProcessing() returns true.setRequiresMethodProcessing in interface BeanDefinitionVisitorshouldPreProcess - True if they should be pre-processedpublic void visitTypeArguments(Map<String,Map<String,ClassElement>> typeArguments)
BeanDefinitionVisitorvisitTypeArguments in interface BeanDefinitionVisitortypeArguments - The type argumentspublic boolean requiresMethodProcessing()
BeanDefinitionVisitorBeanContext is started, the
BeanDefinition.getExecutableMethods() are not processed by registered
ExecutableMethodProcessor instances unless this method returns true.requiresMethodProcessing in interface BeanDefinitionVisitorExecutable.processOnStartup()public void visitFieldInjectionPoint(TypedElement declaringType, FieldElement fieldElement, boolean requiresReflection)
BeanDefinitionVisitorvisitFieldInjectionPoint in interface BeanDefinitionVisitordeclaringType - The declaring type. Either a Class or a string representing the name of the typefieldElement - The field elementrequiresReflection - Whether accessing the field requires reflectionpublic void visitAnnotationMemberPropertyInjectionPoint(TypedElement annotationMemberBeanType, String annotationMemberProperty, @Nullable String requiredValue, @Nullable String notEqualsValue)
BeanDefinitionVisitorvisitAnnotationMemberPropertyInjectionPoint in interface BeanDefinitionVisitorannotationMemberBeanType - The type of the injected beanannotationMemberProperty - Required property of the injected beanrequiredValue - Required value of the bean property for the bean to be loadednotEqualsValue - The bean property value which should not be equal to present value for the bean to
be loadedpublic void visitFieldValue(TypedElement declaringType, FieldElement fieldElement, boolean requiresReflection, boolean isOptional)
BeanDefinitionVisitorvisitFieldValue in interface BeanDefinitionVisitordeclaringType - The declaring type. Either a Class or a string representing the name of the typefieldElement - The field elementrequiresReflection - Whether accessing the field requires reflectionisOptional - Is the value optionalpublic String getName()
public boolean isProtected()
isProtected in interface Elementpublic boolean isPublic()
public Object getNativeType()
ElementgetNativeType in interface Elementpublic Collection<Element> getInjectionPoints()
BeanElementFieldElement and MethodElement instances.getInjectionPoints in interface BeanElementpublic boolean isAbstract()
isAbstract in interface Elementpublic <T extends Annotation> Element annotate(String annotationType, Consumer<AnnotationValueBuilder<T>> consumer)
Elementannotate in interface ElementT - The annotation generic typeannotationType - The annotation typeconsumer - A function that receives the AnnotationValueBuilderpublic Element removeAnnotation(String annotationType)
ElementIf the annotation features any stereotypes these will also be removed unless there are other annotations that reference the stereotype to be removed.
In the case of repeatable annotations this method will remove all repeated annotations, effectively clearing out all declared repeated annotations of the given type.
removeAnnotation in interface ElementannotationType - The annotation typepublic <T extends Annotation> Element removeAnnotationIf(Predicate<AnnotationValue<T>> predicate)
ElementremoveAnnotationIf in interface ElementT - The annotation generic typepredicate - The predicatepublic Element removeStereotype(String annotationType)
ElementremoveStereotype in interface ElementannotationType - The annotation typepublic ClassElement getDeclaringClass()
BeanElementClassElement which may differ
from the BeanElement.getBeanTypes() in the case of factory beans.getDeclaringClass in interface BeanElementpublic Element getProducingElement()
BeanElementClassElement for regular beans,
or either a MethodElement or FieldElement for factory beans.getProducingElement in interface BeanElementpublic Set<ClassElement> getBeanTypes()
BeanElementgetBeanTypes in interface BeanElementpublic Optional<String> getScope()
BeanElementgetScope in interface BeanElementpublic Collection<String> getQualifiers()
getQualifiers in interface BeanElementpublic BeanElementBuilder addAssociatedBean(ClassElement type, VisitorContext visitorContext)
BeanElementNote that this method can only be called on classes being directly compiled by Micronaut. If the ClassElement is
loaded from pre-compiled code an UnsupportedOperationException will be thrown.
addAssociatedBean in interface BeanElementtype - The type of the beanvisitorContext - The visitor contextpublic Element[] getOriginatingElements()
getOriginatingElements in interface OriginatingElementsgetOriginatingElements in class AbstractClassFileWriter