java.lang.Object
io.jstach.jstachio.spi.JStachioFactory.Builder
- Enclosing class:
- JStachioFactory
Builder for creating a custom JStachio.
JStachio jstachio = JStachioFactory.builder()
.add(extension1)
.add(extension2)
.build();
The order of adding extensions is important such that primacy order takes
precedence as composite extensions such as config will be created if multiple of
the same extension type are added. If you would like to share the JStachio in
a service locator style you may want to set it as the default via
JStachio.setStatic(java.util.function.Supplier)
which will make all calls
of JStachio.of()
use the custom one.- Author:
- agentgt
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionadd
(JStachioExtension extension) Adds an extensionadd
(TemplateInfo template) Registers an instantiated template.add
(Iterable<? extends JStachioExtension> extensions) Add extensions.add
(Collection<? extends TemplateInfo> templates) Registers instantiated templates.build()
Builds a JStachio by coalescing the extensions and registered templates.
-
Method Details
-
add
Adds an extension- Parameters:
extension
- not null- Returns:
- this
-
add
Add extensions. Useful for adding ServiceLoader results:builder.add(ServiceLoader.load(JStachioExtension.class));
- Parameters:
extensions
- not null- Returns:
- this
-
add
Registers an instantiated template. The templates will be added toJStachioTemplateFinder
with order-1
whenbuild()
is called.- Parameters:
template
- usually a generated renderer.- Returns:
- this
-
add
Registers instantiated templates. The templates will be addedJStachioTemplateFinder
with order-1
whenbuild()
is called.- Parameters:
templates
- usually a generated renderer.- Returns:
- this
-
build
Builds a JStachio by coalescing the extensions and registered templates.- Returns:
- resolved JStachio
- API Note
- See
JStachioExtensions
for logic on how the extensions are consolidated.
-