test_class.declarator: underTest
test_class.modifier: private
test_class.original_string: private JavaStringToEscapedJsonString underTest;
test_class.type: JavaStringToEscapedJsonString
test_class.var_name: underTest
test_class.file: json/src/test/java/org/eclipse/ditto/json/JavaStringToEscapedJsonStringTest.java
test_class.identifier: JavaStringToEscapedJsonStringTest
test_case.body: @Test
      public void convertJavaStringWithSpecialChars() {
          final String javaString = "Auf der Wiese\n blueht ein kleines \"Blümelein\".";
          final String expected = "\"" + "Auf der Wiese\\n blueht ein kleines \\\"Blümelein\\\"." + "\"";
  
          final String actual = underTest.apply(javaString);
  
          assertThat(actual).isEqualTo(expected);
      }
test_case.class_method_signature: JavaStringToEscapedJsonStringTest.convertJavaStringWithSpecialChars()
test_case.full_signature: @Test public void convertJavaStringWithSpecialChars()
test_case.identifier: convertJavaStringWithSpecialChars
test_case.invocations: apply isEqualTo assertThat
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void convertJavaStringWithSpecialChars()
focal_class.declarator: INSTANCE =
              new JavaStringToEscapedJsonString(JsonCharEscaper.getInstance())
focal_class.modifier: private static final
focal_class.original_string: private static final JavaStringToEscapedJsonString INSTANCE =
              new JavaStringToEscapedJsonString(JsonCharEscaper.getInstance());
focal_class.type: JavaStringToEscapedJsonString
focal_class.var_name: INSTANCE
focal_class.declarator: QUOTE = '\"'
focal_class.modifier: private static final
focal_class.original_string: private static final char QUOTE = '\"';
focal_class.type: char
focal_class.var_name: QUOTE
focal_class.declarator: jsonCharEscaper
focal_class.modifier: private final
focal_class.original_string: private final Function<Integer, String> jsonCharEscaper;
focal_class.type: Function<Integer, String>
focal_class.var_name: jsonCharEscaper
focal_class.file: json/src/main/java/org/eclipse/ditto/json/JavaStringToEscapedJsonString.java
focal_class.identifier: JavaStringToEscapedJsonString
focal_class.interfaces: implements UnaryOperator<String>
focal_class.class_method_signature: JavaStringToEscapedJsonString.JavaStringToEscapedJsonString(final Function<Integer, String> theJsonCharEscaper)
focal_class.full_signature: private  JavaStringToEscapedJsonString(final Function<Integer, String> theJsonCharEscaper)
focal_class.identifier: JavaStringToEscapedJsonString
focal_class.modifiers: private
focal_class.parameters: (final Function<Integer, String> theJsonCharEscaper)
focal_class.signature:  JavaStringToEscapedJsonString(final Function<Integer, String> theJsonCharEscaper)
focal_class.class_method_signature: JavaStringToEscapedJsonString.getInstance()
focal_class.full_signature: public static JavaStringToEscapedJsonString getInstance()
focal_class.identifier: getInstance
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: JavaStringToEscapedJsonString
focal_class.signature: JavaStringToEscapedJsonString getInstance()
focal_class.class_method_signature: JavaStringToEscapedJsonString.apply(final String javaString)
focal_class.full_signature: @Override public String apply(final String javaString)
focal_class.identifier: apply
focal_class.modifiers: @Override public
focal_class.parameters: (final String javaString)
focal_class.return: String
focal_class.signature: String apply(final String javaString)
focal_method.body: @Override
      public String apply(final String javaString) {
          requireNonNull(javaString, "The Java String to be converted must not be null");
          final StringBuilder stringBuilder = new StringBuilder(javaString.length() + 2);
          stringBuilder.append(QUOTE);
          stringBuilder.append(javaString);
          int i = 1; // offset of starting " char
          for (final char c : javaString.toCharArray()) {
              @Nullable final String replacement = jsonCharEscaper.apply((int) c);
              if (null != replacement) {
                  stringBuilder.replace(i, i + 1, replacement);
                  i += replacement.length();
              } else {
                  i++;
              }
          }
          stringBuilder.append(QUOTE);
          return stringBuilder.toString();
      }
focal_method.class_method_signature: JavaStringToEscapedJsonString.apply(final String javaString)
focal_method.full_signature: @Override public String apply(final String javaString)
focal_method.identifier: apply
focal_method.invocations: requireNonNull length append append toCharArray apply replace length append toString
focal_method.modifiers: @Override public
focal_method.parameters: (final String javaString)
focal_method.return: String
focal_method.signature: String apply(final String javaString)