@Internal public abstract class AbstractBeanDefinitionBuilder extends java.lang.Object implements BeanElementBuilder
BeanElementBuilder
interface that should be implemented by downstream language specific implementations.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 java.lang.annotation.Annotation> |
annotate(AnnotationMetadata annotationMetadata,
java.lang.String annotationType,
java.util.function.Consumer<AnnotationValueBuilder<T>> consumer)
Add an annotation to the given metadata.
|
<T extends java.lang.annotation.Annotation> |
annotate(java.lang.String annotationType,
java.util.function.Consumer<AnnotationValueBuilder<T>> consumer)
Annotate this element with the given annotation type.
|
BeanDefinitionWriter |
build()
Build the bean definition writer.
|
BeanElementBuilder |
createWith(MethodElement element)
Specifies the bean will created with the given method element.
|
AnnotationMetadata |
getAnnotationMetadata()
Supplies the metadata.
|
ClassElement |
getBeanType() |
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() |
protected abstract void |
removeAnnotation(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(AnnotationMetadata annotationMetadata,
java.util.function.Predicate<AnnotationValue<T>> predicate)
Remove an annotation if it matches the given condition.
|
<T extends java.lang.annotation.Annotation> |
removeAnnotationIf(java.util.function.Predicate<AnnotationValue<T>> predicate)
Removes all annotations that pass the given predicate.
|
protected abstract void |
removeStereotype(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 |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
annotate, annotate, annotate, qualifier, qualifier, removeAnnotation, removeStereotype, scope, scope
getDescription, getDescription, getDocumentation, 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, 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, isTrue, isTrue, longValue, longValue, stringValue, stringValue, stringValue, stringValue, stringValues, stringValues, stringValues, stringValues, synthesize, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByType
getValues, hasDeclaredStereotype, isAnnotationPresent, isDeclaredAnnotationPresent
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullable
protected AbstractBeanDefinitionBuilder(Element originatingElement, ClassElement beanType, ConfigurationMetadataBuilder<?> metadataBuilder, VisitorContext visitorContext)
originatingElement
- The originating elementbeanType
- The bean typemetadataBuilder
- the metadata buildervisitorContext
- the visitor contextpublic BeanElementBuilder inject()
BeanElementBuilder
inject
in interface BeanElementBuilder
@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 types@NonNull public BeanElementBuilder withMethods(@NonNull ElementQuery<MethodElement> methods, @NonNull java.util.function.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 java.util.function.Consumer<BeanFieldElement> beanFields)
BeanElementBuilder
withFields
in interface BeanElementBuilder
fields
- The ElementQuery
to locate fields.beanFields
- The bean fields@NonNull public BeanElementBuilder withParameters(java.util.function.Consumer<BeanParameterElement[]> parameters)
BeanElementBuilder
withParameters
in interface BeanElementBuilder
parameters
- The parameters@NonNull public java.lang.String getName()
public boolean isProtected()
isProtected
in interface Element
public boolean isPublic()
@NonNull public java.lang.Object getNativeType()
Element
getNativeType
in interface Element
@NonNull public <T extends java.lang.annotation.Annotation> BeanElementBuilder annotate(@NonNull java.lang.String annotationType, @NonNull java.util.function.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 BeanElementBuilder removeAnnotation(@NonNull java.lang.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 java.lang.annotation.Annotation> BeanElementBuilder removeAnnotationIf(@NonNull java.util.function.Predicate<AnnotationValue<T>> predicate)
Element
removeAnnotationIf
in interface BeanElementBuilder
removeAnnotationIf
in interface Element
T
- The annotation generic typepredicate
- The predicatepublic BeanElementBuilder removeStereotype(@NonNull java.lang.String annotationType)
Element
removeStereotype
in interface BeanElementBuilder
removeStereotype
in interface Element
annotationType
- The annotation type@Nullable public BeanDefinitionWriter build()
protected abstract <T extends java.lang.annotation.Annotation> void annotate(AnnotationMetadata annotationMetadata, java.lang.String annotationType, java.util.function.Consumer<AnnotationValueBuilder<T>> consumer)
T
- The annotation generic typeannotationMetadata
- The annotation metadataannotationType
- the annotation typeconsumer
- The builderprotected abstract void removeStereotype(AnnotationMetadata annotationMetadata, java.lang.String annotationType)
annotationMetadata
- The metadataannotationType
- The stereotypeprotected abstract <T extends java.lang.annotation.Annotation> void removeAnnotationIf(AnnotationMetadata annotationMetadata, java.util.function.Predicate<AnnotationValue<T>> predicate)
T
- The annotation typeannotationMetadata
- The metadatapredicate
- The predicateprotected abstract void removeAnnotation(AnnotationMetadata annotationMetadata, java.lang.String annotationType)
annotationMetadata
- The metadataannotationType
- The type