Class DelegatingGeneralConverter
- All Implemented Interfaces:
DescribableComponent,Converter,GeneralConverter
GeneralConverter implementation delegating conversion operations to a Converter.
Useful to adapt any Converter to the GeneralConverter contract, ensuring callers work against the
more specific GeneralConverter interface without restricting the types that can be converted.
- Since:
- 5.1.0
- Author:
- Jakob Hatzl
-
Constructor Summary
ConstructorsConstructorDescriptionDelegatingGeneralConverter(Converter delegate) Constructs aDelegatingGeneralConverter, delegating operations to the givendelegate. -
Method Summary
Modifier and TypeMethodDescription<T> @Nullable TConverts the giveninputobject into an object of the giventargetType.delegate()Returns the delegateConverterthisDelegatingGeneralConverterdelegates to.voiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.
-
Constructor Details
-
DelegatingGeneralConverter
Constructs aDelegatingGeneralConverter, delegating operations to the givendelegate.- Parameters:
delegate- The converter to delegate all conversion operations to.
-
-
Method Details
-
convert
Description copied from interface:ConverterConverts the giveninputobject into an object of the giventargetType. -
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.Best Practices: As a general rule, all relevant fields of a
DescribableComponentimplementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing thedescribeTomethod, who should focus on providing information that is useful for understanding the component's configuration and state.Example implementation:
public void describeTo(ComponentDescriptor descriptor) { descriptor.describeProperty("name", this.name); descriptor.describeProperty("enabled", this.enabled); descriptor.describeProperty("configuration", this.configuration); // A nested component descriptor.describeProperty("handlers", this.eventHandlers); // A collection }- Specified by:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-
delegate
Returns the delegateConverterthisDelegatingGeneralConverterdelegates to.Useful to construct other instances with the exact same
Converter.- Returns:
- The
ConverterthisDelegatingGeneralConverterdelegates to.
-