@Internal public abstract class AbstractBeanDefinitionBuilder extends 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
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBER
EMPTY
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 Annotation> |
annotate(AnnotationMetadata annotationMetadata,
AnnotationValue<T> annotationValue)
Add an annotation to the given metadata.
|
protected abstract <T extends Annotation> |
annotate(AnnotationMetadata annotationMetadata,
String annotationType,
Consumer<AnnotationValueBuilder<T>> consumer)
Add an annotation to the given metadata.
|
<T extends Annotation> |
annotate(AnnotationValue<T> annotationValue)
Annotate this element with the given annotation type.
|
<T extends Annotation> |
annotate(String annotationType,
Consumer<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.
|
AnnotationMetadata |
getAnnotationMetadata()
Supplies the metadata.
|
ClassElement |
getBeanType() |
List<AbstractBeanDefinitionBuilder> |
getChildBeans()
Any child bean definitions.
|
String |
getName() |
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,
Consumer<BeanElementBuilder> childBeanBuilder)
Produce additional beans from the given methods.
|
protected abstract void |
removeAnnotation(AnnotationMetadata annotationMetadata,
String annotationType)
Remove an annotation for the given name.
|
BeanElementBuilder |
removeAnnotation(String annotationType)
Removes an annotation of the given type from the element.
|
protected abstract <T extends Annotation> |
removeAnnotationIf(AnnotationMetadata annotationMetadata,
Predicate<AnnotationValue<T>> predicate)
Remove an annotation if it matches the given condition.
|
<T extends Annotation> |
removeAnnotationIf(Predicate<AnnotationValue<T>> predicate)
Removes all annotations that pass the given predicate.
|
protected abstract void |
removeStereotype(AnnotationMetadata annotationMetadata,
String annotationType)
Remove a stereotype from the given metadata.
|
BeanElementBuilder |
removeStereotype(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(Consumer<BeanConstructorElement> constructorElement)
Allows configuring the bean constructor.
|
BeanElementBuilder |
withFields(ElementQuery<FieldElement> fields,
Consumer<BeanFieldElement> beanFields)
Allows configuring fields of the bean.
|
BeanElementBuilder |
withMethods(ElementQuery<MethodElement> methods,
Consumer<BeanMethodElement> beanMethods)
Allows configuring methods of the bean.
|
BeanElementBuilder |
withParameters(Consumer<BeanParameterElement[]> parameters)
Allows configuring the parameters for the current constructor.
|
static void |
writeBeanDefinitionBuilders(ClassWriterOutputVisitor classWriterOutputVisitor,
List<AbstractBeanDefinitionBuilder> beanDefinitionBuilders) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
annotate, annotate, annotate, getDeclaringElement, getProducingElement, produceBeans, qualifier, qualifier, removeAnnotation, removeStereotype, scope, scope
getDescription, getDescription, getDocumentation, getModifiers, getSimpleName, isAbstract, isFinal, isPackagePrivate, isPrivate, isStatic
booleanValue, 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, synthesizeDeclaredAnnotationsByType
getAnnotationValuesByName, getDeclaredAnnotationValuesByName, getValues, hasDeclaredStereotype, isAnnotationPresent, isDeclaredAnnotationPresent
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullable
protected 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, List<AbstractBeanDefinitionBuilder> beanDefinitionBuilders) throws IOException
IOException
public BeanElementBuilder inject()
BeanElementBuilder
inject
in interface BeanElementBuilder
public List<AbstractBeanDefinitionBuilder> getChildBeans()
@NonNull public Element getOriginatingElement()
getOriginatingElement
in interface BeanElementBuilder
@NonNull public ClassElement getBeanType()
getBeanType
in interface BeanElementBuilder
@NonNull public AnnotationMetadata getAnnotationMetadata()
AnnotationMetadataProvider
AnnotationMetadata.EMPTY_METADATA
.getAnnotationMetadata
in interface AnnotationMetadataProvider
AnnotationMetadata
@NonNull public BeanElementBuilder createWith(@NonNull MethodElement element)
BeanElementBuilder
ClassElement.getPrimaryConstructor()
.
Note that the method can be a one of the following:
createWith
in interface BeanElementBuilder
element
- The element@NonNull public BeanElementBuilder typed(ClassElement... types)
BeanElementBuilder
typed
in interface BeanElementBuilder
types
- 1 or more types to expose@NonNull public BeanElementBuilder typeArguments(@NonNull ClassElement... types)
BeanElementBuilder
typeArguments
in interface BeanElementBuilder
typeArguments
in interface ConfigurableElement
types
- The types@NonNull public BeanElementBuilder typeArgumentsForType(ClassElement type, @NonNull ClassElement... types)
BeanElementBuilder
typeArgumentsForType
in interface BeanElementBuilder
type
- The type or interface. If null, results in a no-optypes
- The typespublic BeanElementBuilder withConstructor(Consumer<BeanConstructorElement> constructorElement)
BeanElementBuilder
withConstructor
in interface BeanElementBuilder
constructorElement
- The constructor element@NonNull public BeanElementBuilder withMethods(@NonNull ElementQuery<MethodElement> methods, @NonNull Consumer<BeanMethodElement> beanMethods)
BeanElementBuilder
withMethods
in interface BeanElementBuilder
methods
- The ElementQuery
to locate selected methods.beanMethods
- A consumer that receives each BeanMethodElement
@NonNull public BeanElementBuilder withFields(@NonNull ElementQuery<FieldElement> fields, @NonNull Consumer<BeanFieldElement> beanFields)
BeanElementBuilder
withFields
in interface BeanElementBuilder
fields
- The ElementQuery
to locate fields.beanFields
- The bean fields@NonNull public BeanElementBuilder withParameters(Consumer<BeanParameterElement[]> parameters)
BeanElementBuilder
withParameters
in interface BeanElementBuilder
parameters
- The parameterspublic boolean isProtected()
isProtected
in interface Element
public boolean isPublic()
@NonNull public Object getNativeType()
Element
getNativeType
in interface Element
@NonNull public <T extends Annotation> BeanElementBuilder annotate(@NonNull String annotationType, @NonNull Consumer<AnnotationValueBuilder<T>> consumer)
Element
annotate
in interface BeanElementBuilder
annotate
in interface Element
T
- The annotation generic typeannotationType
- The annotation typeconsumer
- A function that receives the AnnotationValueBuilder
public <T extends Annotation> Element annotate(AnnotationValue<T> annotationValue)
Element
public BeanElementBuilder removeAnnotation(@NonNull String annotationType)
Element
If 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 BeanElementBuilder
removeAnnotation
in interface Element
annotationType
- The annotation typepublic <T extends Annotation> BeanElementBuilder removeAnnotationIf(@NonNull Predicate<AnnotationValue<T>> predicate)
Element
removeAnnotationIf
in interface BeanElementBuilder
removeAnnotationIf
in interface Element
T
- The annotation generic typepredicate
- The predicatepublic BeanElementBuilder removeStereotype(@NonNull String annotationType)
Element
removeStereotype
in interface BeanElementBuilder
removeStereotype
in interface Element
annotationType
- The annotation typepublic <E extends MemberElement> BeanElementBuilder produceBeans(ElementQuery<E> methodsOrFields, Consumer<BeanElementBuilder> childBeanBuilder)
BeanElementBuilder
produceBeans
in interface BeanElementBuilder
E
- 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 Annotation> void annotate(AnnotationMetadata annotationMetadata, String annotationType, Consumer<AnnotationValueBuilder<T>> consumer)
T
- The annotation generic typeannotationMetadata
- The annotation metadataannotationType
- the annotation typeconsumer
- The builderprotected abstract <T extends Annotation> void annotate(@NonNull AnnotationMetadata annotationMetadata, @NonNull AnnotationValue<T> annotationValue)
T
- The annotation generic typeannotationMetadata
- The annotation metadataannotationValue
- The valueprotected abstract void removeStereotype(AnnotationMetadata annotationMetadata, String annotationType)
annotationMetadata
- The metadataannotationType
- The stereotypeprotected abstract <T extends Annotation> void removeAnnotationIf(AnnotationMetadata annotationMetadata, Predicate<AnnotationValue<T>> predicate)
T
- The annotation typeannotationMetadata
- The metadatapredicate
- The predicateprotected abstract void removeAnnotation(AnnotationMetadata annotationMetadata, String annotationType)
annotationMetadata
- The metadataannotationType
- The type