Interface BeanElementBuilder
- All Superinterfaces:
AnnotatedElement, AnnotationMetadata, AnnotationMetadataDelegate, AnnotationMetadataProvider, AnnotationSource, ConfigurableElement, Described, Element, MutableAnnotationMetadataDelegate<Element>, Named
- All Known Implementing Classes:
AbstractBeanDefinitionBuilder
Interface for defining beans at compilation time from an originating element.
- Since:
- 3.0.0
- Author:
- graemerocher
-
Field Summary
Fields inherited from interface AnnotationMetadata
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBERFields inherited from interface AnnotationSource
EMPTYFields inherited from interface Element
EMPTY_ELEMENT_ARRAYFields inherited from interface MutableAnnotationMetadataDelegate
EMPTY -
Method Summary
Modifier and TypeMethodDescriptiondefault <T extends Annotation>
BeanElementBuilderAnnotate this element with the given annotation type.default <T extends Annotation>
BeanElementBuilderannotate(Class<T> annotationType, Consumer<AnnotationValueBuilder<T>> consumer) Annotate this element with the given annotation type.default BeanElementBuilderAnnotate this element with the given annotation type.default <T extends Annotation>
BeanElementBuilderannotate(String annotationType, Consumer<AnnotationValueBuilder<T>> consumer) Annotate this element with the given annotation type.createWith(MethodElement element) Specifies the bean will be created with the given method element.default ClassElementReturns the class that declares the bean.default Elementinject()Dependency inject this bean.default BeanElementBuilderintercept(AnnotationValue<?>... annotationValue) Intercept the bean.default <E extends MemberElement>
BeanElementBuilderproduceBeans(ElementQuery<E> methodsOrFields) Produce additional beans from the given methods.<E extends MemberElement>
BeanElementBuilderproduceBeans(ElementQuery<E> methodsOrFields, @Nullable Consumer<BeanElementBuilder> childBeanBuilder) Produce additional beans from the given methods.default BeanElementBuilderqualifier(AnnotationValue<?> qualifier) Adds a qualifier for the given annotation value to the element.default BeanElementBuilderAdds aNamedqualifier to the element.default <T extends Annotation>
BeanElementBuilderremoveAnnotation(Class<T> annotationType) default BeanElementBuilderremoveAnnotation(String annotationType) Removes an annotation of the given type from the element.default <T extends Annotation>
BeanElementBuilderremoveAnnotationIf(Predicate<AnnotationValue<T>> predicate) Removes all annotations that pass the given predicate.default <T extends Annotation>
BeanElementBuilderremoveStereotype(Class<T> annotationType) Removes a stereotype annotation of the given type from the element.default BeanElementBuilderremoveStereotype(String annotationType) Removes a stereotype of the given name from the element.default BeanElementBuilderscope(AnnotationValue<?> scope) Adds a scope for the given annotation value to the bean.default BeanElementBuilderAdds a scope for the given annotation value to the bean.typeArguments(ClassElement... types) Fills the type arguments for the bean with the given types.typeArgumentsForType(@Nullable ClassElement type, ClassElement... types) Fills the type arguments for the given interface or super class with the given types.typed(ClassElement... types) Alters the exposed types for the bean limiting the exposed type to the given types.withConstructor(Consumer<BeanConstructorElement> constructorElement) Allows configuring the bean constructor.withFields(ElementQuery<FieldElement> fields, Consumer<BeanFieldElement> beanFields) Allows configuring fields of the bean.withMethods(ElementQuery<MethodElement> methods, Consumer<BeanMethodElement> beanMethods) Allows configuring methods of the bean.withParameters(Consumer<BeanParameterElement[]> parameters) Allows configuring the parameters for the current constructor.Methods inherited from interface AnnotatedElement
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullableMethods inherited from interface AnnotationMetadata
enumValuesSet, enumValuesSet, getValues, hasDeclaredStereotype, hasEvaluatedExpressions, hasStereotypeNonRepeating, isAnnotationPresent, isDeclaredAnnotationPresentMethods inherited from interface AnnotationMetadataDelegate
booleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, copyAnnotationMetadata, 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, getAnnotationValuesByName, getAnnotationValuesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByName, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getStereotypeAnnotationNames, getTargetAnnotationMetadata, 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, synthesizeDeclaredAnnotationsByTypeMethods inherited from interface AnnotationMetadataProvider
getAnnotationMetadataMethods inherited from interface Element
annotate, getDescription, getDescription, getDocumentation, getDocumentation, getModifiers, getName, getNativeType, getSimpleName, isAbstract, isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isSynthetic, withAnnotationMetadata
-
Method Details
-
intercept
Intercept the bean.- Parameters:
annotationValue- The annotation to intercept- Returns:
- This bean method
- Since:
- 3.5.2
-
getOriginatingElement
Element getOriginatingElement()- Returns:
- The originating element
-
getBeanType
ClassElement getBeanType()- Returns:
- The bean type
-
getProducingElement
- Returns:
- The element that produces the bean.
-
getDeclaringElement
Returns the class that declares the bean. In case of a bean defined by a class, that is the bean class directly. In case of a producer method or field, that is the class that declares the producer method or field.- Returns:
- The element declares the bean.
-
createWith
Specifies the bean will be created with the given method element. If not specified the bean will be created withClassElement.getPrimaryConstructor().Note that the method can be a one of the following:
- An accessible constructor on the bean type being generated
- An accessible static method on the bean type being generated
- Parameters:
element- The element- Returns:
- This bean builder
-
typed
Alters the exposed types for the bean limiting the exposed type to the given types.- Parameters:
types- 1 or more types to expose- Returns:
- This builder
-
typeArguments
Fills the type arguments for the bean with the given types.- Specified by:
typeArgumentsin interfaceConfigurableElement- Parameters:
types- The types- Returns:
- This bean builder
-
typeArgumentsForType
Fills the type arguments for the given interface or super class with the given types.- Parameters:
type- The type or interface. If null, results in a no-optypes- The types- Returns:
- This bean builder
-
scope
Adds a scope for the given annotation value to the bean.- Parameters:
scope- The scope- Returns:
- This bean element builder
-
scope
Adds a scope for the given annotation value to the bean.- Parameters:
scope- The full qualified scope annotation name- Returns:
- This bean element builder
-
withConstructor
Allows configuring the bean constructor.- Parameters:
constructorElement- The constructor element- Returns:
- This bean builder
-
withMethods
BeanElementBuilder withMethods(ElementQuery<MethodElement> methods, Consumer<BeanMethodElement> beanMethods) Allows configuring methods of the bean.- Parameters:
methods- TheElementQueryto locate selected methods.beanMethods- A consumer that receives eachBeanMethodElement- Returns:
- This builder
-
withFields
BeanElementBuilder withFields(ElementQuery<FieldElement> fields, Consumer<BeanFieldElement> beanFields) Allows configuring fields of the bean.- Parameters:
fields- TheElementQueryto locate fields.beanFields- The bean fields- Returns:
- This builder
-
withParameters
Allows configuring the parameters for the current constructor.- Parameters:
parameters- The parameters- Returns:
- This builder
-
qualifier
Description copied from interface:ConfigurableElementAdds aNamedqualifier to the element.- Specified by:
qualifierin interfaceConfigurableElement- Parameters:
qualifier- The qualifier. Ifnulla named annotation with no value is added assuming the default name.- Returns:
- This element
-
qualifier
Description copied from interface:ConfigurableElementAdds a qualifier for the given annotation value to the element.- Specified by:
qualifierin interfaceConfigurableElement- Parameters:
qualifier- The qualifier- Returns:
- This element
-
annotate
default <T extends Annotation> BeanElementBuilder annotate(String annotationType, Consumer<AnnotationValueBuilder<T>> consumer) Description copied from interface:MutableAnnotationMetadataDelegateAnnotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.- Specified by:
annotatein interfaceElement- Specified by:
annotatein interfaceMutableAnnotationMetadataDelegate<Element>- Type Parameters:
T- The annotation generic type- Parameters:
annotationType- The annotation typeconsumer- A function that receives theAnnotationValueBuilder- Returns:
- This element
-
removeAnnotation
Description copied from interface:MutableAnnotationMetadataDelegateRemoves an annotation of the given type from the 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.
- Specified by:
removeAnnotationin interfaceElement- Specified by:
removeAnnotationin interfaceMutableAnnotationMetadataDelegate<Element>- Parameters:
annotationType- The annotation type- Returns:
- This element
-
removeAnnotation
- Specified by:
removeAnnotationin interfaceElement- Specified by:
removeAnnotationin interfaceMutableAnnotationMetadataDelegate<Element>- Type Parameters:
T- The annotation generic type- Parameters:
annotationType- The annotation type- Returns:
- This element
- See Also:
-
removeAnnotationIf
default <T extends Annotation> BeanElementBuilder removeAnnotationIf(Predicate<AnnotationValue<T>> predicate) Description copied from interface:MutableAnnotationMetadataDelegateRemoves all annotations that pass the given predicate.- Specified by:
removeAnnotationIfin interfaceElement- Specified by:
removeAnnotationIfin interfaceMutableAnnotationMetadataDelegate<Element>- Type Parameters:
T- The annotation generic type- Parameters:
predicate- The predicate- Returns:
- This element
-
removeStereotype
Description copied from interface:MutableAnnotationMetadataDelegateRemoves a stereotype of the given name from the element.- Specified by:
removeStereotypein interfaceElement- Specified by:
removeStereotypein interfaceMutableAnnotationMetadataDelegate<Element>- Parameters:
annotationType- The annotation type- Returns:
- This element
-
removeStereotype
Description copied from interface:MutableAnnotationMetadataDelegateRemoves a stereotype annotation of the given type from the element.- Specified by:
removeStereotypein interfaceElement- Specified by:
removeStereotypein interfaceMutableAnnotationMetadataDelegate<Element>- Type Parameters:
T- The annotation generic type- Parameters:
annotationType- The annotation type- Returns:
- This element
-
annotate
Description copied from interface:MutableAnnotationMetadataDelegateAnnotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.- Specified by:
annotatein interfaceElement- Specified by:
annotatein interfaceMutableAnnotationMetadataDelegate<Element>- Parameters:
annotationType- The annotation type- Returns:
- This element
-
annotate
default <T extends Annotation> BeanElementBuilder annotate(Class<T> annotationType, Consumer<AnnotationValueBuilder<T>> consumer) Description copied from interface:MutableAnnotationMetadataDelegateAnnotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.- Specified by:
annotatein interfaceElement- Specified by:
annotatein interfaceMutableAnnotationMetadataDelegate<Element>- Type Parameters:
T- The annotation generic type- Parameters:
annotationType- The annotation typeconsumer- A function that receives theAnnotationValueBuilder- Returns:
- This element
-
annotate
Description copied from interface:MutableAnnotationMetadataDelegateAnnotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.- Specified by:
annotatein interfaceElement- Specified by:
annotatein interfaceMutableAnnotationMetadataDelegate<Element>- Type Parameters:
T- The annotation generic type- Parameters:
annotationType- The annotation type- Returns:
- This element
-
inject
-
produceBeans
<E extends MemberElement> BeanElementBuilder produceBeans(ElementQuery<E> methodsOrFields, @Nullable Consumer<BeanElementBuilder> childBeanBuilder) Produce additional beans from the given methods.- Type Parameters:
E- A type variable to- Parameters:
methodsOrFields- TheElementQueryrepresenting the methods or fieldschildBeanBuilder- Configure the child bean builder- Returns:
- This bean builder
-
produceBeans
Produce additional beans from the given methods.- Type Parameters:
E- A type variable to- Parameters:
methodsOrFields- TheElementQueryrepresenting the methods or fields- Returns:
- This bean builder
-