Annotation Interface ParentProperty
This annotation is used by parsers to automatically establish parent-child relationships when parsing nested objects. When a child object is created within a parent object (e.g., in a list or as a property), the parser automatically sets the parent reference on the child.
Requirements:
- Must be an instance method or field (not static)
- For methods: Must accept exactly one parameter (the parent object type)
- For fields: Can be any type (typically the parent object type)
- The method or field does not need to be public (will be made accessible automatically)
Can be used in the following locations:
- Bean setter methods or fields
@Rest -annotated classes and@RestOp -annotated methods when anon()value is specified
Example:
When It's Called:
- During parsing when a child object is created within a parent object
- The parser automatically calls the setter or sets the field with a reference to the parent object
- This allows child objects to navigate back to their parent if needed
See Also:
-
Element Details
-
description
Optional description for the exposed API.- Returns:
- The annotation value.
- Since:
- 9.2.0
- Default:
- {}
-
on
Dynamically apply this annotation to the specified methods/fields.Used in conjunction with
BeanContext.Builder.applyAnnotations(Class...)to dynamically apply an annotation to an existing method/field. It is ignored when the annotation is applied directly to methods/fields.Valid patterns:
- Methods:
- Fully qualified with args:
"com.foo.MyClass.myMethod(String,int)" "com.foo.MyClass.myMethod(java.lang.String,int)" "com.foo.MyClass.myMethod()"
- Fully qualified:
"com.foo.MyClass.myMethod"
- Simple with args:
"MyClass.myMethod(String,int)" "MyClass.myMethod(java.lang.String,int)" "MyClass.myMethod()"
- Simple:
"MyClass.myMethod"
- Simple inner class:
"MyClass$Inner1$Inner2.myMethod" "Inner1$Inner2.myMethod" "Inner2.myMethod"
- Fully qualified with args:
- Fields:
- Fully qualified:
"com.foo.MyClass.myField"
- Simple:
"MyClass.myField"
- Simple inner class:
"MyClass$Inner1$Inner2.myField" "Inner1$Inner2.myField" "Inner2.myField"
- Fully qualified:
- A comma-delimited list of anything on this list.
See Also:
- Returns:
- The annotation value.
- Default:
- {}
- Methods:
-