public static final class MoreObjects.ToStringHelper
extends java.lang.Object
MoreObjects.toStringHelper(java.lang.Object). Builder which allows reducing boilerplate around toString
implementations| Modifier and Type | Method and Description |
|---|---|
MoreObjects.ToStringHelper |
add(java.lang.String name,
java.lang.Object value)
Adds a name/value pair to the formatted output in
name=value format. |
MoreObjects.ToStringHelper |
addValue(java.lang.Object value)
Adds an unnamed value to the formatted output.
|
MoreObjects.ToStringHelper |
omitNullValues()
Configures the
MoreObjects.ToStringHelper so toString() will ignore properties with a null value. |
java.lang.String |
toString() |
public MoreObjects.ToStringHelper omitNullValues()
MoreObjects.ToStringHelper so toString() will ignore properties with a null value. The
order of calling this method, relative to the add()/addValue() methods, is not significantpublic MoreObjects.ToStringHelper add(java.lang.String name, @Nullable java.lang.Object value)
name=value format. If value is
null, the string "null" is used, unless omitNullValues() is called, in which case
this name/value pair will not be addedname - Label for the value being added, must not be nullvalue - The data to represent in the built stringpublic MoreObjects.ToStringHelper addValue(@Nullable java.lang.Object value)
It is strongly encouraged to use add(String, Object) instead and give value a readable name
value - The data to represent in the built stringpublic java.lang.String toString()
toString in class java.lang.Object