@Internal public abstract class AbstractBeanDefinitionBuilder extends java.lang.Object implements BeanElementBuilder
BeanElementBuilder interface that should be implemented by downstream language specific implementations.| Modifier and Type | Field and Description |
|---|---|
protected ConfigurationMetadataBuilder<?> |
metadataBuilder |
protected VisitorContext |
visitorContext |
EMPTY_ELEMENT_ARRAY| Modifier | Constructor and Description |
|---|---|
protected |
AbstractBeanDefinitionBuilder(Element originatingElement,
ClassElement beanType,
ConfigurationMetadataBuilder<?> metadataBuilder,
VisitorContext visitorContext)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract <T extends java.lang.annotation.Annotation> |
annotate(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
io.micronaut.core.annotation.AnnotationValue<T> annotationValue)
Add an annotation to the given metadata.
|
protected abstract <T extends java.lang.annotation.Annotation> |
annotate(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
java.lang.String annotationType,
java.util.function.Consumer<io.micronaut.core.annotation.AnnotationValueBuilder<T>> consumer)
Add an annotation to the given metadata.
|
<T extends java.lang.annotation.Annotation> |
annotate(io.micronaut.core.annotation.AnnotationValue<T> annotationValue)
Annotate this element with the given annotation type.
|
<T extends java.lang.annotation.Annotation> |
annotate(java.lang.String annotationType,
java.util.function.Consumer<io.micronaut.core.annotation.AnnotationValueBuilder<T>> consumer)
Annotate this element with the given annotation type.
|
BeanDefinitionWriter |
build()
Build the bean definition writer.
|
protected BeanDefinitionWriter |
createBeanDefinitionWriter() |
protected abstract AbstractBeanDefinitionBuilder |
createChildBean(FieldElement producerField)
Creates a child bean for the given producer field.
|
protected abstract AbstractBeanDefinitionBuilder |
createChildBean(MethodElement producerMethod)
Creates a child bean for the given producer method.
|
BeanElementBuilder |
createWith(MethodElement element)
Specifies the bean will created with the given method element.
|
io.micronaut.core.annotation.AnnotationMetadata |
getAnnotationMetadata() |
ClassElement |
getBeanType() |
java.util.List<AbstractBeanDefinitionBuilder> |
getChildBeans()
Any child bean definitions.
|
java.lang.String |
getName() |
java.lang.Object |
getNativeType()
Returns the native underlying type.
|
Element |
getOriginatingElement() |
BeanElementBuilder |
inject()
Dependency inject this bean.
|
boolean |
isProtected() |
boolean |
isPublic() |
<E extends MemberElement> |
produceBeans(ElementQuery<E> methodsOrFields,
java.util.function.Consumer<BeanElementBuilder> childBeanBuilder)
Produce additional beans from the given methods.
|
protected abstract void |
removeAnnotation(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
java.lang.String annotationType)
Remove an annotation for the given name.
|
BeanElementBuilder |
removeAnnotation(java.lang.String annotationType)
Removes an annotation of the given type from the element.
|
protected abstract <T extends java.lang.annotation.Annotation> |
removeAnnotationIf(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
java.util.function.Predicate<io.micronaut.core.annotation.AnnotationValue<T>> predicate)
Remove an annotation if it matches the given condition.
|
<T extends java.lang.annotation.Annotation> |
removeAnnotationIf(java.util.function.Predicate<io.micronaut.core.annotation.AnnotationValue<T>> predicate)
Removes all annotations that pass the given predicate.
|
protected abstract void |
removeStereotype(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
java.lang.String annotationType)
Remove a stereotype from the given metadata.
|
BeanElementBuilder |
removeStereotype(java.lang.String annotationType)
Removes a stereotype of the given name from the element.
|
BeanElementBuilder |
typeArguments(ClassElement... types)
Fills the type arguments for the bean with the given types.
|
BeanElementBuilder |
typeArgumentsForType(ClassElement type,
ClassElement... types)
Fills the type arguments for the given interface or super class with the given types.
|
BeanElementBuilder |
typed(ClassElement... types)
Alters the exposed types for the bean limiting the exposed type to the given types.
|
BeanElementBuilder |
withConstructor(java.util.function.Consumer<BeanConstructorElement> constructorElement)
Allows configuring the bean constructor.
|
BeanElementBuilder |
withFields(ElementQuery<FieldElement> fields,
java.util.function.Consumer<BeanFieldElement> beanFields)
Allows configuring fields of the bean.
|
BeanElementBuilder |
withMethods(ElementQuery<MethodElement> methods,
java.util.function.Consumer<BeanMethodElement> beanMethods)
Allows configuring methods of the bean.
|
BeanElementBuilder |
withParameters(java.util.function.Consumer<BeanParameterElement[]> parameters)
Allows configuring the parameters for the current constructor.
|
static void |
writeBeanDefinitionBuilders(ClassWriterOutputVisitor classWriterOutputVisitor,
java.util.List<AbstractBeanDefinitionBuilder> beanDefinitionBuilders) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitannotate, annotate, annotate, getDeclaringElement, getProducingElement, produceBeans, qualifier, qualifier, removeAnnotation, removeStereotype, scope, scopegetDescription, getDescription, getDocumentation, getModifiers, getSimpleName, isAbstract, isFinal, isPackagePrivate, isPrivate, isStaticbooleanValue, 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, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, 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, synthesizeDeclaredAnnotationsByTypeprotected final ConfigurationMetadataBuilder<?> metadataBuilder
protected final VisitorContext visitorContext
protected AbstractBeanDefinitionBuilder(Element originatingElement, ClassElement beanType, ConfigurationMetadataBuilder<?> metadataBuilder, VisitorContext visitorContext)
originatingElement - The originating elementbeanType - The bean typemetadataBuilder - the metadata buildervisitorContext - the visitor context@Internal public static void writeBeanDefinitionBuilders(ClassWriterOutputVisitor classWriterOutputVisitor, java.util.List<AbstractBeanDefinitionBuilder> beanDefinitionBuilders) throws java.io.IOException
java.io.IOExceptionpublic BeanElementBuilder inject()
BeanElementBuilderinject in interface BeanElementBuilderpublic java.util.List<AbstractBeanDefinitionBuilder> getChildBeans()
@NonNull public Element getOriginatingElement()
getOriginatingElement in interface BeanElementBuilder@NonNull public ClassElement getBeanType()
getBeanType in interface BeanElementBuilder@NonNull public io.micronaut.core.annotation.AnnotationMetadata getAnnotationMetadata()
getAnnotationMetadata in interface io.micronaut.core.annotation.AnnotationMetadataProvider@NonNull public BeanElementBuilder createWith(@NonNull MethodElement element)
BeanElementBuilderClassElement.getPrimaryConstructor().
Note that the method can be a one of the following:
createWith in interface BeanElementBuilderelement - The element@NonNull public BeanElementBuilder typed(ClassElement... types)
BeanElementBuildertyped in interface BeanElementBuildertypes - 1 or more types to expose@NonNull public BeanElementBuilder typeArguments(@NonNull ClassElement... types)
BeanElementBuildertypeArguments in interface BeanElementBuildertypeArguments in interface ConfigurableElementtypes - The types@NonNull public BeanElementBuilder typeArgumentsForType(ClassElement type, @NonNull ClassElement... types)
BeanElementBuildertypeArgumentsForType in interface BeanElementBuildertype - The type or interface. If null, results in a no-optypes - The typespublic BeanElementBuilder withConstructor(java.util.function.Consumer<BeanConstructorElement> constructorElement)
BeanElementBuilderwithConstructor in interface BeanElementBuilderconstructorElement - The constructor element@NonNull public BeanElementBuilder withMethods(@NonNull ElementQuery<MethodElement> methods, @NonNull java.util.function.Consumer<BeanMethodElement> beanMethods)
BeanElementBuilderwithMethods in interface BeanElementBuildermethods - The ElementQuery to locate selected methods.beanMethods - A consumer that receives each BeanMethodElement@NonNull public BeanElementBuilder withFields(@NonNull ElementQuery<FieldElement> fields, @NonNull java.util.function.Consumer<BeanFieldElement> beanFields)
BeanElementBuilderwithFields in interface BeanElementBuilderfields - The ElementQuery to locate fields.beanFields - The bean fields@NonNull public BeanElementBuilder withParameters(java.util.function.Consumer<BeanParameterElement[]> parameters)
BeanElementBuilderwithParameters in interface BeanElementBuilderparameters - The parameters@NonNull public java.lang.String getName()
public boolean isProtected()
isProtected in interface Elementpublic boolean isPublic()
@NonNull public java.lang.Object getNativeType()
ElementgetNativeType in interface Element@NonNull public <T extends java.lang.annotation.Annotation> BeanElementBuilder annotate(@NonNull java.lang.String annotationType, @NonNull java.util.function.Consumer<io.micronaut.core.annotation.AnnotationValueBuilder<T>> consumer)
Elementannotate in interface BeanElementBuilderannotate in interface ElementT - The annotation generic typeannotationType - The annotation typeconsumer - A function that receives the AnnotationValueBuilderpublic <T extends java.lang.annotation.Annotation> Element annotate(io.micronaut.core.annotation.AnnotationValue<T> annotationValue)
Elementpublic BeanElementBuilder removeAnnotation(@NonNull java.lang.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 BeanElementBuilderremoveAnnotation in interface ElementannotationType - The annotation typepublic <T extends java.lang.annotation.Annotation> BeanElementBuilder removeAnnotationIf(@NonNull java.util.function.Predicate<io.micronaut.core.annotation.AnnotationValue<T>> predicate)
ElementremoveAnnotationIf in interface BeanElementBuilderremoveAnnotationIf in interface ElementT - The annotation generic typepredicate - The predicatepublic BeanElementBuilder removeStereotype(@NonNull java.lang.String annotationType)
ElementremoveStereotype in interface BeanElementBuilderremoveStereotype in interface ElementannotationType - The annotation typepublic <E extends MemberElement> BeanElementBuilder produceBeans(ElementQuery<E> methodsOrFields, java.util.function.Consumer<BeanElementBuilder> childBeanBuilder)
BeanElementBuilderproduceBeans in interface BeanElementBuilderE - A type variable tomethodsOrFields - The ElementQuery representing the methods or fieldschildBeanBuilder - Configure the child bean builder@NonNull protected abstract AbstractBeanDefinitionBuilder createChildBean(FieldElement producerField)
producerField - The producer field@NonNull protected abstract AbstractBeanDefinitionBuilder createChildBean(MethodElement producerMethod)
producerMethod - The producer method@Nullable public BeanDefinitionWriter build()
protected BeanDefinitionWriter createBeanDefinitionWriter()
protected abstract <T extends java.lang.annotation.Annotation> void annotate(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
java.lang.String annotationType,
java.util.function.Consumer<io.micronaut.core.annotation.AnnotationValueBuilder<T>> consumer)
T - The annotation generic typeannotationMetadata - The annotation metadataannotationType - the annotation typeconsumer - The builderprotected abstract <T extends java.lang.annotation.Annotation> void annotate(@NonNull
io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
@NonNull
io.micronaut.core.annotation.AnnotationValue<T> annotationValue)
T - The annotation generic typeannotationMetadata - The annotation metadataannotationValue - The valueprotected abstract void removeStereotype(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
java.lang.String annotationType)
annotationMetadata - The metadataannotationType - The stereotypeprotected abstract <T extends java.lang.annotation.Annotation> void removeAnnotationIf(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
java.util.function.Predicate<io.micronaut.core.annotation.AnnotationValue<T>> predicate)
T - The annotation typeannotationMetadata - The metadatapredicate - The predicateprotected abstract void removeAnnotation(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
java.lang.String annotationType)
annotationMetadata - The metadataannotationType - The type