Class BeanAnnotation
@Bean annotation.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceA collection of@Beanannotations.static classBuilder class. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic BeanAnnotation.Buildercreate()Instantiates a new builder for this class.find(MethodInfo method) Finds the@Beanannotation that applies to the specified method.static StringPulls the name/value attribute from aBeanannotation.
-
Field Details
-
DEFAULT
Default value
-
-
Method Details
-
create
Instantiates a new builder for this class.- Returns:
- A new builder object.
-
name
Pulls the name/value attribute from aBeanannotation.- Parameters:
a- The annotation to check. Can benull (returns an empty string).- Returns:
- The annotation value, or an empty string if the annotation is
null .
-
find
Finds the@Beanannotation that applies to the specified method.The result is the method's own declared
@Bean, or else the one declared on a method it truly overrides. A parent method only counts as overridden when it is non-private, non-static, not a bridge/synthetic method, and (when package-private) declared in the same package as the method. This is stricter thanMethodInfo.getAnnotations(), which also merges annotations from same-signature private or static parent methods that are not overrides.Bridge and synthetic methods always return
Optional.empty().Example:
public class Parent {@Bean (name="db" )public HealthIndicator dbIndicator() { ... } }public class Childextends Parent {@Override public HealthIndicator dbIndicator() { ... }// Not annotated, but overrides an annotated method. } MethodInfomi = ClassInfo.of (Child.class ).getDeclaredMethod(x ->x .hasName("dbIndicator" )).get(); Optional<Bean>bean = BeanAnnotation.find (mi );// Present, name="db". - Parameters:
method- The method to inspect. Must not benull .- Returns:
- The applicable annotation, or
Optional.empty()if none applies.
-