Class StringUtil

java.lang.Object
com.google.common.truth.StringUtil

final class StringUtil extends Object
Utilities for string comparisons.
  • Constructor Details

    • StringUtil

      private StringUtil()
  • Method Details

    • messageFor

      static String messageFor(String message, CharSequence expected, CharSequence actual)
      Returns a message appropriate for string comparisons. TODO(user): Do something closer to what JUnit's ComparisonFailure does.
    • format

      static String format(String template, Object... args)
      Substitutes each %s in template with an argument. These are matched by position - the first %s gets args[0], etc. If there are more arguments than placeholders, the unmatched arguments will be appended to the end of the formatted message in square braces. Cribbed from Guava's Preconditions to allow for a GWT-compatible alternative to String.format(String, Object...)
      Parameters:
      template - a non-null string containing 0 or more %s placeholders.
      args - the arguments to be substituted into the message template. Arguments are converted to strings using String.valueOf(Object). Arguments can be null.
      See Also:
      • Preconditions