All Downloads are FREE. Search and download functionalities are using the official Maven repository.

brooklyn.util.text.FormattedString Maven / Gradle / Ivy

Go to download

Utility classes and methods developed for Brooklyn but not dependendent on Brooklyn or much else

There is a newer version: 0.7.0-M1
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy