Class StringRenderer

java.lang.Object
dk.mada.jaxrs.generator.mpclient.StringRenderer

public final class StringRenderer extends Object
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 Details

    • makeValidOperationJavadocSummary

      public static Optional<String> makeValidOperationJavadocSummary(String textIn)
      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

      public static Optional<String> makeValidDtoJavadocSummary(String textIn)
      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

      public static Optional<String> makeValidPropertyJavadocSummary(String textIn)
      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

      public static Optional<String> encodeForString(Optional<String> text)
      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

      public static String encodeForString(String text)
      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

      public static String quote(String text)
      Quote text. Wraps a string in quotes. If it contains quotes, escape them.
      Parameters:
      text - the text to quote
      Returns:
      the quoted text
    • encodeRegexp

      public static String encodeRegexp(String regexp)
      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

      public static void consumeNonBlankEncoded(Optional<String> txt, Consumer<String> consumer)
      Encodes input text if it is non-blank for consumer.
      Parameters:
      txt - the text to be encoded
      consumer - the consumer of the text