docs: public String format(final String pattern, final Object... args) {
          buffer.setLength(0);
          boolean changed = false;
          int placeholder = -1;
          final int patternLength = pattern.length();
          for (int i = 0; i < patternLength; ++i) {
              final char ch = pattern.charAt(i);
              if (placeholder < 0) { // processing constant part
                  if (ch == '{') {
                      changed = true;
                      if (i + 1 < patternLength && pattern.charAt(i + 1) == '{') {
                          buffer.append(ch); // handle escaped '{'
                          ++i;
                      } else {
                          placeholder = 0; // switch to placeholder part
                      }
                  } else {
                      buffer.append(ch);
                  }
              } else { // processing placeholder part
                  if (ch == '}') {
                      if (placeholder >= args.length) {
                          throw new IllegalArgumentException("Argument index out of bounds: " + placeholder);
                      }
                      if (pattern.charAt(i - 1) == '{') {
                          throw new IllegalArgumentException("Missing argument index after a left curly brace");
                      }
                      if (args[placeholder] == null) {
                          buffer.append("null"); // append null argument
                      } else {
                          buffer.append(args[placeholder].toString()); // append actual argument
                      }
                      placeholder = -1; // switch to constant part
                  } else {
                      if (ch < '0' || ch > '9') {
                          throw new IllegalArgumentException("Unexpected '" + ch + "' while parsing argument index");
                      }
                      placeholder = placeholder * 10 + ch - '0';
                  }
              }
          }
          if (placeholder >= 0) {
              throw new IllegalArgumentException("Unmatched braces in the pattern.");
          }
  
          return changed ? buffer.toString() : pattern;
      }