Interface ComponentDescriptor

All Known Implementing Classes:
FilesystemStyleComponentDescriptor, JacksonComponentDescriptor

public interface ComponentDescriptor
Contract towards describing the properties an (infrastructure) component might have.

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 Type
    Method
    Description
    Provides the description of this ComponentDescriptor.
    void
    Describe the given value with this descriptor for the given name.
    void
    Describe the given value with this descriptor for the given name.
    void
    Describe the given object with this descriptor for the given name.
    void
    Describe the given value with this descriptor for the given name.
    void
    describeProperty(String name, Collection<?> collection)
    Describe the given collection with this descriptor for the given name.
    void
    describeProperty(String name, Map<?,?> map)
    Describe the given map with this descriptor for the given name.
    default void
    Describe the given delegate with this descriptor under the name "delegate".
  • Method Details

    • describeProperty

      void describeProperty(@Nonnull String name, Object object)
      Describe the given object with this descriptor for the given name.

      If the object is a DescribableComponent, DescribableComponent.describeTo(ComponentDescriptor) is invoked with this descriptor.

      Parameters:
      name - The name for the object to describe.
      object - The object to describe with this descriptor.
    • describeProperty

      void describeProperty(@Nonnull String name, Collection<?> collection)
      Describe the given collection with this descriptor for the given name.

      If any item in the collection is a DescribableComponent, it will be processed as if describeProperty(String, Object) was invoked for that item, and DescribableComponent.describeTo(ComponentDescriptor) will be called on it.

      The formatting of the collection typically takes a regular array structure.

      Parameters:
      name - The name for the collection to describe.
      collection - The collection to describe with this descriptor.
    • describeProperty

      void describeProperty(@Nonnull String name, Map<?,?> map)
      Describe the given map with this descriptor for the given name.

      If any value in the map is a DescribableComponent, it will be processed as if describeProperty(String, Object) was invoked for that value, and DescribableComponent.describeTo(ComponentDescriptor) will be called on it.

      The formatting of the map typically takes a regular key-value structure based on the entries of the map.

      Parameters:
      name - The name for the map to describe.
      map - The map to describe with this descriptor.
    • describeProperty

      void describeProperty(@Nonnull String name, String value)
      Describe the given value with this descriptor for the given name.
      Parameters:
      name - The name for the value to describe.
      value - The value to describe with this descriptor.
    • describeProperty

      void describeProperty(@Nonnull String name, Long value)
      Describe the given value with this descriptor for the given name.
      Parameters:
      name - The name for the value to describe.
      value - The value to describe with this descriptor.
    • describeProperty

      void describeProperty(@Nonnull String name, Boolean value)
      Describe the given value with this descriptor for the given name.
      Parameters:
      name - The name for the value to describe.
      value - The value to describe with this descriptor.
    • describeWrapperOf

      default void describeWrapperOf(Object delegate)
      Describe the given delegate with this descriptor under the name "delegate".

      If the delegate is a DescribableComponent, DescribableComponent.describeTo(ComponentDescriptor) is invoked with this descriptor.

      Parameters:
      delegate - The object to describe with this descriptor.
    • describe

      String describe()
      Provides the description of this ComponentDescriptor.
      Returns:
      The description result of this ComponentDescriptor.