- All Known Subinterfaces:
ByteBufTemplateSet
,LoginView.BytebufTemplateSet
,LoginView.BytesTemplateSet
,LoginView.StringTemplateSet
,PublisherTemplateSet<T>
- All Known Implementing Classes:
AbstractByteBufPublisherTemplateSet
,AbstractByteBufTemplateSet
,AbstractCompositeByteBufTemplateSet
,AbstractStreamTemplateSet
,AbstractStringPublisherTemplateSet
,AbstractStringTemplateSet
,AbstractTemplateSet
Template set definition which specifies the methods used in a generated template set implementation to render objects in a procedural or reactive way.
This interface is intended to be implemented by a template compiler generating an implementation based on a template set file following an appropriate grammar.
Such implementation must define template methods accepting zero or more
parameters and returning a CompletableFuture
which completes once
input arguments are fully rendered to the output which is done using the
generic methods specified in this interface.
As a result, depending on the implementation, data can be rendered in different ways as a string, an output stream or a stream of data which emits events each time new rendered data are generated.
- Since:
- 1.2
- Author:
- Jeremy Kuhn
- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A particularTemplateSet.Renderable
with the ability to expose the index of the value in a group of elements to the renderer (eg. an array, an iterable, a stream, a publisher...).static interface
A renderable is used to render a value with a particular type of object typically by invoking the corresponding template in a TemplateSet implementation. -
Field Summary
Modifier and TypeFieldDescriptionstatic final CompletableFuture
<Void> An empty completed future which returns immediately. -
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.render
(byte[] value) Renders a byte array to the output.Renders an object to the output.Renders a string to the output.default CompletableFuture
<Void> The root template method which basically invokes therender(Object)
method.
-
Field Details
-
COMPLETED_FUTURE
An empty completed future which returns immediately.
-
-
Method Details
-
render
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.
- Parameters:
value
- the object to render- Returns:
- a future which completes once the value is rendered
-
render
Renders a string to the output.
- Parameters:
value
- the string to render- Returns:
- a future which completes once the value is rendered
-
render
Renders a byte array to the output.
- Parameters:
value
- The byte array to render- Returns:
- a future which completes once the value is rendered
-
applyTemplate
Invokes a template defined in the template set implementation on the specified object.
- 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
Invokes a template defined in the template set implementation on each element of the specified array.
Elements are guaranteed to be rendered in sequence.
- 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
Invokes a template defined in the template set implementation on each element of the specified iterable.
Elements are guaranteed to be rendered in sequence.
- 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
Invokes a template defined in the template set implementation on each element of the specified stream.
Elements are guaranteed to be rendered in sequence.
- 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
-
applyTemplate
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.
- 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
-
template
The root template method which basically invokes the
render(Object)
method.- Parameters:
value
- the value onto which the template is applied- Returns:
- a future which completes once the value is rendered
-