Interface DisplayData.Builder

Enclosing class:
DisplayData

public static interface DisplayData.Builder
Utility to build up display data from a component and its included subcomponents.
  • Method Details

    • include

      DisplayData.Builder include(String path, HasDisplayData subComponent)
      Register display data from the specified subcomponent at the given path. For example, a PTransform which delegates to a user-provided function can implement HasDisplayData on the function and include it from the PTransform:
      @Override
       public void populateDisplayData(DisplayData.Builder builder) {
         super.populateDisplayData(builder);
      
         builder
           // To register the class name of the userFn
           .add(DisplayData.item("userFn", userFn.getClass()))
           // To allow the userFn to register additional display data
           .include("userFn", userFn);
       }
       

      Using include(path, subComponent) will associate each of the registered items with the namespace of the subComponent being registered, with the specified path element relative to the current path. To register display data in the current path and namespace, such as from a base class implementation, use subComponent.populateDisplayData(builder) instead.

      See Also:
    • delegate

      DisplayData.Builder delegate(HasDisplayData component)
      Register display data from the specified component on behalf of the current component. Display data items will be added with the subcomponent namespace but the current component path.

      This is useful for components which simply wrap other components and wish to retain the display data from the wrapped component. Such components should implement populateDisplayData as:

      @Override
       public void populateDisplayData(DisplayData.Builder builder) {
         builder.delegate(wrapped);
       }
       
    • add

      Register the given display item.
    • addIfNotNull

      Register the given display item if the value is not null.
    • addIfNotDefault

      <T> DisplayData.Builder addIfNotDefault(DisplayData.ItemSpec<T> item, @Nullable T defaultValue)
      Register the given display item if the value is different than the specified default.