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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DisplayData.Builder
add(DisplayData.ItemSpec<?> item)
Register the given display item.<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.DisplayData.Builder
addIfNotNull(DisplayData.ItemSpec<?> item)
Register the given display item if the value is not null.DisplayData.Builder
delegate(HasDisplayData component)
Register display data from the specified component on behalf of the current component.DisplayData.Builder
include(java.lang.String path, HasDisplayData subComponent)
Register display data from the specified subcomponent at the given path.
-
-
-
Method Detail
-
include
DisplayData.Builder include(java.lang.String path, HasDisplayData subComponent)
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.
-
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
DisplayData.Builder add(DisplayData.ItemSpec<?> item)
Register the given display item.
-
addIfNotNull
DisplayData.Builder addIfNotNull(DisplayData.ItemSpec<?> item)
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.
-
-