Interface ViewElementBuilder<T extends ViewElement>
- All Known Implementing Classes:
AbstractNodeViewElementBuilder,AbstractVoidNodeViewElementBuilder,ContainerViewElementBuilder,ContainerViewElementBuilderSupport,CssWebResourceBuilder,JavascriptWebResourceBuilder,LinkWebResourceBuilder,MetaWebResourceBuilder,NodeViewElementBuilder,TextViewElementBuilder,ViewElementBuilderSupport,ViewElementGeneratorBuilder,VoidNodeViewElementBuilder,WebResourceReferenceCollection
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Base interface to create a single
ViewElement instance.
Usually used to build an entire hierarchy of elements by calling build(ViewElementBuilderContext) on the
top-most element. Building a ViewElement requires a ViewElementBuilderContext and often a
single builder context is used to build many elements.
If you call build() without manually specifying a builder context, a global context will be retrieved
using ViewElementBuilderContext.retrieveGlobalBuilderContext() and if none is available, a new
DefaultViewElementBuilderContext will be used instead.
For performance it is often best to manage the lifecycle of a ViewElementBuilderContext yourself,
so you don't have unnecessary creation and can optimize contextual data sharing.- Author:
- Arne Vandamme
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceViewElementBuilder.Wither<T extends ViewElementBuilder> -
Method Summary
Modifier and TypeMethodDescriptiondefault ViewElementBuilder<T>andThen(ViewElementPostProcessor<T> postProcessor) Chain aViewElementPostProcessorto the result of this builder.default Tbuild()Build theViewElementusing the globally availableViewElementBuilderContext, this will useViewElementBuilderContext.retrieveGlobalBuilderContext()to get the global context.build(ViewElementBuilderContext builderContext) Builds the actual element.default ViewElementBuilder<T>doWith(ViewElementBuilder.Wither... operations) Deprecated.default <U extends ViewElement>
ViewElementBuilder<U>map(@NonNull BiFunction<ViewElementBuilderContext, T, U> mappingFunction) Map theViewElementthat this builder returns to another type.default <U extends ViewElement>
ViewElementBuilder<U>Map theViewElementthat this builder returns to another type.static <U extends ViewElement>
ViewElementBuilder<U>of(Function<ViewElementBuilderContext, U> supplier) static <U extends ViewElement>
ViewElementBuilder<U>default ViewElementBuilder<T>postProcess(ViewElementPostProcessor<T> postProcessors) default ViewElementBuilder<T>postProcess(Collection<ViewElementPostProcessor<T>> postProcessors)
-
Method Details
-
build
Build theViewElementusing the globally availableViewElementBuilderContext, this will useViewElementBuilderContext.retrieveGlobalBuilderContext()to get the global context. If none is returned, a newDefaultViewElementBuilderContextwill be used instead. Use this method sparingly, usually only for the single top-level build of aViewElement. The creation of aViewElementBuilderContextcan be relatively costly, performance-wise it is usually better if you callbuild(ViewElementBuilderContext)with a predefined orViewElementBuilderContext, or at least ensure you have a global context available.- Returns:
- view element
- See Also:
-
build
Builds the actual element.- Parameters:
builderContext- provides the context for this build event- Returns:
- instance to render the element.
-
andThen
Chain aViewElementPostProcessorto the result of this builder. This will return a new builder instance that applies the post processor to the element generated.Explicitly supports
nullargument values, which mean do nothing and will actually return the same builder.- Parameters:
postProcessor- to apply on the builder result- Returns:
- new builder with the post processor chained to it
-
map
default <U extends ViewElement> ViewElementBuilder<U> map(@NonNull @NonNull Function<T, U> mappingFunction) Map theViewElementthat this builder returns to another type. Creates a new builder returning the resulting element. If you need access to theViewElementBuilderContextusemap(BiFunction)instead.- Type Parameters:
U- type of the new element returned- Parameters:
mappingFunction- to apply to the generated element- Returns:
- new builder instance
- See Also:
-
map
default <U extends ViewElement> ViewElementBuilder<U> map(@NonNull @NonNull BiFunction<ViewElementBuilderContext, T, U> mappingFunction) Map theViewElementthat this builder returns to another type. Creates a new builder returning the resulting element.- Type Parameters:
U- type of the new element returned- Parameters:
mappingFunction- to apply to the generated element- Returns:
- new builder instance
- See Also:
-
doWith
Deprecated. -
postProcess
-
postProcess
-
of
-
of
static <U extends ViewElement> ViewElementBuilder<U> of(Function<ViewElementBuilderContext, U> supplier)
-