public static final class MoreObjects.ToStringHelper extends Object
MoreObjects.toStringHelper(java.lang.Object)
.Objects.ToStringHelper
.Modifier and Type | Method and Description |
---|---|
MoreObjects.ToStringHelper |
add(String name,
int value)
Adds a name/value pair to the formatted output in
name=value
format. |
MoreObjects.ToStringHelper |
add(String name,
long value)
Adds a name/value pair to the formatted output in
name=value
format. |
MoreObjects.ToStringHelper |
add(String name,
Object value)
Adds a name/value pair to the formatted output in
name=value
format. |
String |
toString()
Returns a string in the format specified by
MoreObjects.toStringHelper(Object) . |
public MoreObjects.ToStringHelper add(String name, 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 added.public MoreObjects.ToStringHelper add(String name, int value)
name=value
format.Objects.ToStringHelper.omitNullValues()
.public MoreObjects.ToStringHelper add(String name, long value)
name=value
format.Objects.ToStringHelper.omitNullValues()
.public String toString()
MoreObjects.toStringHelper(Object)
.
After calling this method, you can keep adding more properties to later call toString() again and get a more complete representation of the same object; but properties cannot be removed, so this only allows limited reuse of the helper instance. The helper allows duplication of properties (multiple name/value pairs with the same name can be added).
Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.