Class AppliedAnnotationObject
- All Implemented Interfaces:
Annotation
- Direct Known Subclasses:
AppliedOnClassAnnotationObject
This class extends AnnotationObject to provide support for annotations that have an
Overview:
Applied annotations allow you to define annotation properties in external configuration or programmatically at runtime, rather than requiring them to be declared directly on classes, methods, fields, or constructors at compile-time.
This is particularly useful for:
- Configuration-driven behavior - Define annotation properties in config files without modifying source code
- Dynamic application - Apply annotations to third-party classes where you can't modify the source
- Runtime customization - Change annotation properties based on runtime conditions
- Centralized configuration - Define annotation properties for multiple classes in one place
Targeting with on :
The base AppliedAnnotationObject.Builder.on(String...) method accepts fully-qualified names in the following formats:
"com.example.MyClass" - Target a specific class"com.example.MyClass.myMethod" - Target a specific method"com.example.MyClass.myField" - Target a specific field"com.example.MyClass(java.lang.String,int)" - Target a specific constructor
Builder Variants:
This class provides specialized builder variants for different targeting scenarios:
AppliedAnnotationObject.Builder- Base builder with string-based targeting viaAppliedAnnotationObject.Builder.on(String...)AppliedAnnotationObject.BuilderT- For targeting classeson(Class...)- Target by class, stored as stringson(ClassInfo...)- Target by ClassInfo, stored as stringsonClass(Class...)- Target by class, stored as Class objectsonClass(ClassInfo...)- Target by ClassInfo, stored as Class objects
AppliedAnnotationObject.BuilderM- For targeting methodson(Method...)- Target by Method objecton(MethodInfo...)- Target by MethodInfo object
AppliedAnnotationObject.BuilderC- For targeting constructorson(Constructor...)- Target by Constructor objecton(ConstructorInfo...)- Target by ConstructorInfo object
AppliedAnnotationObject.BuilderMF- For targeting methods and fieldson(Method...)- Target by Method objecton(MethodInfo...)- Target by MethodInfo objecton(Field...)- Target by Field objecton(FieldInfo...)- Target by FieldInfo object
AppliedAnnotationObject.BuilderTM- For targeting classes and methodsAppliedAnnotationObject.BuilderTMF- For targeting classes, methods, and fieldsAppliedAnnotationObject.BuilderTMFC- For targeting classes, methods, fields, and constructors
Example:
Notes:
- The
on()method returns the string-based targets - Subclasses may provide additional
onClass(),onMethod(), etc. methods for type-safe access - All builder methods return the builder for method chaining
- Hashcode is calculated lazily on first access and then cached for performance
See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder forAppliedAnnotationObjectobjects.static classBuilder for applied annotations targeting constructors.static classBuilder for applied annotations targeting methods.static classBuilder for applied annotations targeting methods and fields.static classBuilder for applied annotations targeting classes.static classBuilder for applied annotations targeting classes and methods.static classBuilder for applied annotations targeting classes, methods, and fields.static classBuilder for applied annotations targeting classes, methods, fields, and constructors. -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.apache.juneau.commons.annotation.AnnotationObject
annotationType, equals, hashCode, propertyMap, toString
-
Constructor Details
-
AppliedAnnotationObject
Constructor.- Parameters:
b- The builder used to instantiate the fields of this class.
-
-
Method Details
-
on
The targets this annotation applies to.- Returns:
- The targets this annotation applies to.
-