Package dk.mada.jaxrs.generator.mpclient
Class StringRenderer
java.lang.Object
dk.mada.jaxrs.generator.mpclient.StringRenderer
Renders text in various forms suitable for use in the templates.
Duplicates some of the logic in mustache rendering, but does so to allow for use of simpler templates.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
consumeNonBlankEncoded
(Optional<String> txt, Consumer<String> consumer) Encodes input text if it is non-blank for consumer.static String
encodeForString
(String text) Encodes text for use in string-input.encodeForString
(Optional<String> text) Encodes text for use in string-input.static String
encodeRegexp
(String regexp) Encode regular expression to be used in an annotation argument.makeValidDtoJavadocSummary
(String textIn) Make a summary valid for use in the DTO summary javadoc section.Make a summary valid for use in the API summary javadoc section.Make a summary valid for use in the property javadoc section.static String
Quote text.
-
Method Details
-
makeValidOperationJavadocSummary
Make a summary valid for use in the API summary javadoc section.- Parameters:
textIn
- the text summary- Returns:
- a valid summary to render as javadoc, or null
-
makeValidDtoJavadocSummary
Make a summary valid for use in the DTO summary javadoc section.- Parameters:
textIn
- the text summary- Returns:
- a valid summary to render as javadoc, or null
-
makeValidPropertyJavadocSummary
Make a summary valid for use in the property javadoc section.- Parameters:
textIn
- the text summary- Returns:
- a valid summary to render as javadoc, or null
-
encodeForString
Encodes text for use in string-input. The text may contain multiple lines, but needs to be represented in the source code as a single string input. Used for descriptions and examples that need to be specified as @Schema inputs.- Parameters:
text
- the text to be protected- Returns:
- a single-line string
-
encodeForString
Encodes text for use in string-input. The text may contain multiple lines, but needs to be represented in the source code as a single string input. Used for descriptions and examples that need to be specified as @Schema inputs.- Parameters:
text
- the text to be protected- Returns:
- a single-line string
-
quote
Quote text. Wraps a string in quotes. If it contains quotes, escape them.- Parameters:
text
- the text to quote- Returns:
- the quoted text
-
encodeRegexp
Encode regular expression to be used in an annotation argument. Backslashes need to be doubled.- Parameters:
regexp
- the regular expression to encode- Returns:
- the encoded regular expression
-
consumeNonBlankEncoded
Encodes input text if it is non-blank for consumer.- Parameters:
txt
- the text to be encodedconsumer
- the consumer of the text
-