/** * Creates an instance of {@link ToStringHelper}. * * <p>This is helpful for implementing {@link Object#toString()}. For * example, in an object that contains two member variables, {@code x}, * and {@code y}, one could write:<pre> <tt> * public class ClassName { * public String toString() { * return Objects.toStringHelper(this) * .add("x", x) * .add("y", y) * .toString(); * } * }</tt> * </pre> * * Assuming the values of {@code x} and {@code y} are 1 and 2, * this code snippet returns the string <tt>"ClassName{x=1, y=2}"</tt>. */ public static ToStringHelper toStringHelper(Object object) { return new ToStringHelper(object); }
/** * Creates an instance of {@link ToStringHelper}. * * <p>This is helpful for implementing {@link Object#toString()}. For * example, in an object that contains two member variables, {@code x}, * and {@code y}, one could write:<pre> <tt> * public class ClassName { * public String toString() { * return Objects.toStringHelper(this) * .add("x", x) * .add("y", y) * .toString(); * } * }</tt> * </pre> * * Assuming the values of {@code x} and {@code y} are 1 and 2, * this code snippet returns the string <tt>"ClassName{x=1, y=2}"</tt>. */ public static ToStringHelper toStringHelper(Object object) { return new ToStringHelper(object); }
/** * Creates an instance of {@link ToStringHelper}. * * <p>This is helpful for implementing {@link Object#toString()}. For * example, in an object that contains two member variables, {@code x}, * and {@code y}, one could write:<pre> <tt> * public class ClassName { * public String toString() { * return Objects.toStringHelper(this) * .add("x", x) * .add("y", y) * .toString(); * } * }</tt> * </pre> * * Assuming the values of {@code x} and {@code y} are 1 and 2, * this code snippet returns the string <tt>"ClassName{x=1, y=2}"</tt>. */ public static ToStringHelper toStringHelper(Object object) { return new ToStringHelper(object); }