Interface ComponentDescriptor
- All Known Implementing Classes:
FilesystemStyleComponentDescriptor,JacksonComponentDescriptor
The ComponentDescriptor implementation passed to a component by
DescribableComponent.describeTo(ComponentDescriptor) determines both the structure and
format of the output. This means the same component can be rendered in different formats (like JSON, XML, or a
filesystem-like tree) depending on which ComponentDescriptor implementation is used. The component only needs
to provide its properties and structure to the descriptor, which then handles the formatting details.
Handling Circular References: Component hierarchies may contain circular references where a
DescribableComponent refers to another component that eventually references back to the original.
ComponentDescriptor implementations must handle these circular dependencies to prevent infinite recursion.
- Since:
- 5.0.0
- Author:
- Allard Buijze, Mitchell Herrijgers, Steven van Beelen, Mateusz Nowak
-
Method Summary
Modifier and TypeMethodDescriptiondescribe()Provides the description ofthis ComponentDescriptor.voiddescribeProperty(String name, Boolean value) Describe the givenvaluewiththisdescriptor for the givenname.voiddescribeProperty(String name, Long value) Describe the givenvaluewiththisdescriptor for the givenname.voiddescribeProperty(String name, Object object) Describe the givenobjectwiththisdescriptor for the givenname.voiddescribeProperty(String name, String value) Describe the givenvaluewiththisdescriptor for the givenname.voiddescribeProperty(String name, Collection<?> collection) Describe the givencollectionwiththisdescriptor for the givenname.voiddescribeProperty(String name, Map<?, ?> map) Describe the givenmapwiththisdescriptor for the givenname.default voiddescribeWrapperOf(Object delegate) Describe the givendelegatewiththisdescriptor under the name"delegate".
-
Method Details
-
describeProperty
Describe the givenobjectwiththisdescriptor for the givenname.If the
objectis aDescribableComponent,DescribableComponent.describeTo(ComponentDescriptor)is invoked withthisdescriptor.- Parameters:
name- The name for theobjectto describe.object- The object to describe withthisdescriptor.
-
describeProperty
Describe the givencollectionwiththisdescriptor for the givenname.If any item in the
collectionis aDescribableComponent, it will be processed as ifdescribeProperty(String, Object)was invoked for that item, andDescribableComponent.describeTo(ComponentDescriptor)will be called on it.The formatting of the
collectiontypically takes a regular array structure.- Parameters:
name- The name for thecollectionto describe.collection- The collection to describe withthisdescriptor.
-
describeProperty
Describe the givenmapwiththisdescriptor for the givenname.If any value in the
mapis aDescribableComponent, it will be processed as ifdescribeProperty(String, Object)was invoked for that value, andDescribableComponent.describeTo(ComponentDescriptor)will be called on it.The formatting of the
maptypically takes a regular key-value structure based on theentriesof themap.- Parameters:
name- The name for themapto describe.map- The map to describe withthisdescriptor.
-
describeProperty
Describe the givenvaluewiththisdescriptor for the givenname.- Parameters:
name- The name for thevalueto describe.value- The value to describe withthisdescriptor.
-
describeProperty
Describe the givenvaluewiththisdescriptor for the givenname.- Parameters:
name- The name for thevalueto describe.value- The value to describe withthisdescriptor.
-
describeProperty
Describe the givenvaluewiththisdescriptor for the givenname.- Parameters:
name- The name for thevalueto describe.value- The value to describe withthisdescriptor.
-
describeWrapperOf
Describe the givendelegatewiththisdescriptor under the name"delegate".If the
delegateis aDescribableComponent,DescribableComponent.describeTo(ComponentDescriptor)is invoked withthisdescriptor.- Parameters:
delegate- The object to describe withthisdescriptor.
-
describe
String describe()Provides the description ofthis ComponentDescriptor.- Returns:
- The description result of
this ComponentDescriptor.
-