- Type Parameters:
R
- Processor's process result type.
- All Superinterfaces:
ValidatingProcessorPREVIEW<R,
RuntimeException>
- All Known Subinterfaces:
StringProcessorPREVIEW
- All Known Implementing Classes:
FormatProcessorPREVIEW
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface TemplateProcessor<R>
extends ValidatingProcessorPREVIEW<R,RuntimeException>
TemplateProcessor
is a preview API of the Java platform.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
This interface is used to implement template processors that do not throw checked
exceptions. Any implementation must supply a
process(StringTemplate)
method that constructs a result
from the information provided by the supplied StringTemplate
PREVIEW instance.
For example:
TemplateProcessor<Integer> processor = st -> {
String interpolation = st.interpolate();
return Integer.valueOf(interpolation);
};
- Implementation Note:
- It is recommended that
StringProcessor
PREVIEW be used instead ofTemplateProcessor<String>
when the result type isString
. - See Java Language Specification:
-
15.8.6 Process Template Expressions
- Since:
- 21
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionprocess
(StringTemplatePREVIEW stringTemplate) Constructs a result based on the template fragments and values in the suppliedstringTemplate
PREVIEW instance.
-
Method Details
-
process
Constructs a result based on the template fragments and values in the suppliedstringTemplate
PREVIEW instance.- Specified by:
process
in interfaceValidatingProcessorPREVIEW<R,
RuntimeException> - Parameters:
stringTemplate
- aStringTemplate
PREVIEW instance- Returns:
- constructed object of type R
-
TemplateProcessor
when preview features are enabled.