Package com.google.common.truth
Class StringUtil
- java.lang.Object
-
- com.google.common.truth.StringUtil
-
final class StringUtil extends java.lang.Object
Utilities for string comparisons.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
StringUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.String
format(java.lang.String template, java.lang.Object... args)
Substitutes each%s
intemplate
with an argument.(package private) static java.lang.String
messageFor(java.lang.String message, java.lang.CharSequence expected, java.lang.CharSequence actual)
Returns a message appropriate for string comparisons.
-
-
-
Method Detail
-
messageFor
static java.lang.String messageFor(java.lang.String message, java.lang.CharSequence expected, java.lang.CharSequence actual)
Returns a message appropriate for string comparisons. TODO(user): Do something closer to what JUnit'sComparisonFailure
does.
-
format
static java.lang.String format(java.lang.String template, java.lang.Object... args)
Substitutes each%s
intemplate
with an argument. These are matched by position - the first%s
getsargs[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'sPreconditions
to allow for a GWT-compatible alternative toString.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 usingString.valueOf(Object)
. Arguments can be null.- See Also:
Preconditions
-
-