Interface TemplateVisitor<T>
- Type Parameters:
T
- The return type of this visitor
public interface TemplateVisitor<T>
For code generating from a template, use a `TemplateVisitor`. Template visitor is written to enable optimized
behavior for static templates with no dynamic components.
-
Method Summary
Modifier and TypeMethodDescriptionInvoked at the conclusion of visiting a multipart template like `https://{Region}.{dnsSuffix}`.Invoked prior to visiting a multipart template like `https://{Region}.{dnsSuffix}`.visitDynamicElement
(Expression value) Visit a dynamic element within a multipart template.The template contains a single dynamic element, eg.visitStaticElement
(String value) Visit a static element within a multipart template.visitStaticTemplate
(String value) The template contains a single static string, eg.
-
Method Details
-
visitStaticTemplate
The template contains a single static string, eg. "https://mystaticendpoing.com"- Parameters:
value
- The static value of the template.- Returns:
- T
-
visitSingleDynamicTemplate
The template contains a single dynamic element, eg. `{Region}`. In this case, string formatting is not required. The type of the value is guaranteed to be a string.- Parameters:
value
- The single expression that represents this template.- Returns:
- T
-
visitStaticElement
Visit a static element within a multipart template. This will only be called afterstartMultipartTemplate()
has been invoked.- Parameters:
value
- A static element within a larger template- Returns:
- T
-
visitDynamicElement
Visit a dynamic element within a multipart template. This will only be called afterstartMultipartTemplate()
has been invoked.- Parameters:
value
- The dynamic template value- Returns:
- T
-
startMultipartTemplate
T startMultipartTemplate()Invoked prior to visiting a multipart template like `https://{Region}.{dnsSuffix}`. This function will be followed by invocations ofvisitStaticTemplate(String)
andvisitDynamicElement(Expression)
.- Returns:
- T
-
finishMultipartTemplate
T finishMultipartTemplate()Invoked at the conclusion of visiting a multipart template like `https://{Region}.{dnsSuffix}`. This allows implementations to do something like call `string.join()` or `stringbuilder.toString()`.- Returns:
- T
-