- All Superinterfaces:
TemplateProcessorPREVIEW<String>
,ValidatingProcessorPREVIEW<String,
RuntimeException>
- 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.
StringProcessor
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 only produce
String
results. Any implementation must supply a
process(StringTemplate)
method that constructs a result
from the information provided by the supplied StringTemplate
PREVIEW instance.
For example:
StringProcessor processor = st -> st.interpolate().toUpperCase();
- Implementation Note:
- Implementations using
StringProcessor
PREVIEW are equivalent to implementations usingTemplateProcessor<String>
orValidatingProcessor<String, RuntimeException>
, however, StringProcessor is cleaner and easier to understand. - See Java Language Specification:
-
15.8.6 Process Template Expressions
- Since:
- 21
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionprocess
(StringTemplatePREVIEW stringTemplate) Constructs aString
based on the template fragments and values in the suppliedStringTemplate
PREVIEW object.
-
Method Details
-
process
Constructs aString
based on the template fragments and values in the suppliedStringTemplate
PREVIEW object.- Specified by:
process
in interfaceTemplateProcessorPREVIEW<String>
- Specified by:
process
in interfaceValidatingProcessorPREVIEW<String,
RuntimeException> - Parameters:
stringTemplate
- aStringTemplate
PREVIEW instance- Returns:
- constructed
String
-
StringProcessor
when preview features are enabled.