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 Summary
Modifier and TypeMethodDescriptionadd
(DisplayData.ItemSpec<?> item) Register the given display item.addIfNotDefault
(DisplayData.ItemSpec<T> item, @Nullable T defaultValue) Register the given display item if the value is different than the specified default.addIfNotNull
(DisplayData.ItemSpec<?> item) Register the given display item if the value is not null.delegate
(HasDisplayData component) Register display data from the specified component on behalf of the current component.include
(String path, HasDisplayData subComponent) Register display data from the specified subcomponent at the given path.
-
Method Details
-
include
Register display data from the specified subcomponent at the given path. For example, aPTransform
which delegates to a user-provided function can implementHasDisplayData
on the function and include it from thePTransform
:@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 thesubComponent
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, usesubComponent.populateDisplayData(builder)
instead.- See Also:
-
delegate
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
Register the given display item if the value is different than the specified default.
-