brooklyn.util.text.FormattedString Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of brooklyn-utils-common Show documentation
Show all versions of brooklyn-utils-common Show documentation
Utility classes and methods developed for Brooklyn but not dependendent on Brooklyn or much else
package brooklyn.util.text;
import com.google.common.base.Preconditions;
/** wraps a call to {@link String#format(String, Object...)} in a toString, i.e. using %s syntax,
* useful for places where we want deferred evaluation
* (e.g. as message to {@link Preconditions} to skip concatenation when not needed) */
public class FormattedString {
private final String pattern;
private final Object[] args;
public FormattedString(String pattern, Object[] args) {
this.pattern = pattern;
this.args = args;
}
@Override
public String toString() {
return String.format(pattern, args);
}
public String getPattern() {
return pattern;
}
public Object[] getArgs() {
return args;
}
}