Class StringUtils

java.lang.Object
org.openrewrite.yaml.internal.StringUtils

public class StringUtils extends Object
  • Method Details

    • quoteIfNeeded

      public static String quoteIfNeeded(String value)
      Quotes a YAML scalar value if needed, per the YAML 1.2.2 spec.

      If the input is already quoted (surrounded by matching single or double quotes), it is returned as-is. Otherwise, the method determines whether the value requires quoting and applies the minimal quoting style: single quotes by default, double quotes only when escape sequences are required.

      Parameters:
      value - the raw string value
      Returns:
      the value, potentially quoted for safe use as a YAML scalar