- All Implemented Interfaces:
TemplateSet
- Direct Known Subclasses:
AbstractByteBufPublisherTemplateSet
,AbstractByteBufTemplateSet
,AbstractCompositeByteBufTemplateSet
,AbstractStreamTemplateSet
,AbstractStringPublisherTemplateSet
,AbstractStringTemplateSet
Base TemplateSet
implementation.
This class especially provides general implementations for
applyTemplate
methods which allow to apply templates on the
elements of an array, an iterable, a stream and a publisher while making sure
the rendering process is non-blocking following reactive programming
principles.
- Since:
- 1.2
- Author:
- Jeremy Kuhn
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.inverno.mod.irt.TemplateSet
TemplateSet.IndexableRenderable<T>, TemplateSet.Renderable<T>
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Charset
The charset to use to encode rendered data.Fields inherited from interface io.inverno.mod.irt.TemplateSet
COMPLETED_FUTURE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapplyTemplate
(Iterable<T> iterable) Invokes a template defined in the template set implementation on each element of the specified iterable.applyTemplate
(Stream<T> stream) Invokes a template defined in the template set implementation on each element of the specified stream.applyTemplate
(Publisher<T> publisher) Invokes a template defined in the template set implementation on each element emitted in the specified publisher until the publisher completes.<T> TemplateSet.Renderable
<T> applyTemplate
(T value) Invokes a template defined in the template set implementation on the specified object.applyTemplate
(T[] array) Invokes a template defined in the template set implementation on each element of the specified array.Renders an object to the output.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.inverno.mod.irt.TemplateSet
render, render, template
-
Field Details
-
charset
The charset to use to encode rendered data.
-
-
Constructor Details
-
AbstractTemplateSet
Creates a template set.
- Parameters:
charset
- the charset to use to encode data
-
-
Method Details
-
render
Description copied from interface:TemplateSet
Renders an object to the output.
This method might invoke specialized methods based on the actual type of the object. If no specific method is found the string representation of the object must be rendered.
- Specified by:
render
in interfaceTemplateSet
- Parameters:
value
- the object to render- Returns:
- a future which completes once the value is rendered
-
applyTemplate
Description copied from interface:TemplateSet
Invokes a template defined in the template set implementation on the specified object.
- Specified by:
applyTemplate
in interfaceTemplateSet
- Type Parameters:
T
- the type of the object- Parameters:
value
- the value onto which template should be applied- Returns:
- a renderable object which can invoke the template method matching the object type
-
applyTemplate
Description copied from interface:TemplateSet
Invokes a template defined in the template set implementation on each element of the specified array.
Elements are guaranteed to be rendered in sequence.
- Specified by:
applyTemplate
in interfaceTemplateSet
- Type Parameters:
T
- the type of the object- Parameters:
array
- the array of elements onto which template should be applied- Returns:
- an indexable renderable object which can invoke the template method matching the object type
-
applyTemplate
Description copied from interface:TemplateSet
Invokes a template defined in the template set implementation on each element emitted in the specified publisher until the publisher completes.
Elements are guaranteed to be rendered in sequence.
- Specified by:
applyTemplate
in interfaceTemplateSet
- Type Parameters:
T
- the type of the object- Parameters:
publisher
- the stream of elements onto which template should be applied- Returns:
- an indexable renderable object which can invoke the template method matching the object type
-
applyTemplate
Description copied from interface:TemplateSet
Invokes a template defined in the template set implementation on each element of the specified iterable.
Elements are guaranteed to be rendered in sequence.
- Specified by:
applyTemplate
in interfaceTemplateSet
- Type Parameters:
T
- the type of the object- Parameters:
iterable
- the iterable providing the elements onto which template should be applied- Returns:
- an indexable renderable object which can invoke the template method matching the object type
-
applyTemplate
Description copied from interface:TemplateSet
Invokes a template defined in the template set implementation on each element of the specified stream.
Elements are guaranteed to be rendered in sequence.
- Specified by:
applyTemplate
in interfaceTemplateSet
- Type Parameters:
T
- the type of the object- Parameters:
stream
- the stream of elements onto which template should be applied- Returns:
- an indexable renderable object which can invoke the template method matching the object type
-