Class MoreObjects.ToStringHelper
- Enclosing class:
MoreObjects
MoreObjects.toStringHelper(java.lang.Object)
.- Since:
- 18.0 (since 2.0 as
Objects.ToStringHelper
).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Holder object for values that cannot be null or empty (will be printed unconditionally).(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
private final MoreObjects.ToStringHelper.ValueHolder
private boolean
private boolean
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ToStringHelper
(String className) UseMoreObjects.toStringHelper(Object)
to create an instance. -
Method Summary
Modifier and TypeMethodDescriptionAdds a name/value pair to the formatted output inname=value
format.Adds a name/value pair to the formatted output inname=value
format.Adds a name/value pair to the formatted output inname=value
format.Adds a name/value pair to the formatted output inname=value
format.Adds a name/value pair to the formatted output inname=value
format.Adds a name/value pair to the formatted output inname=value
format.Adds a name/value pair to the formatted output inname=value
format.private MoreObjects.ToStringHelper
private MoreObjects.ToStringHelper
private MoreObjects.ToStringHelper
addUnconditionalHolder
(Object value) private MoreObjects.ToStringHelper
addUnconditionalHolder
(String name, Object value) addValue
(boolean value) Adds an unnamed value to the formatted output.addValue
(char value) Adds an unnamed value to the formatted output.addValue
(double value) Adds an unnamed value to the formatted output.addValue
(float value) Adds an unnamed value to the formatted output.addValue
(int value) Adds an unnamed value to the formatted output.addValue
(long value) Adds an unnamed value to the formatted output.Adds an unnamed value to the formatted output.private static boolean
Configures theMoreObjects.ToStringHelper
sotoString()
will ignore properties with null value.toString()
Returns a string in the format specified byMoreObjects.toStringHelper(Object)
.
-
Field Details
-
className
-
holderHead
-
holderTail
-
omitNullValues
private boolean omitNullValues -
omitEmptyValues
private boolean omitEmptyValues
-
-
Constructor Details
-
ToStringHelper
UseMoreObjects.toStringHelper(Object)
to create an instance.
-
-
Method Details
-
omitNullValues
Configures theMoreObjects.ToStringHelper
sotoString()
will ignore properties with null value. The order of calling this method, relative to theadd()
/addValue()
methods, is not significant.- Since:
- 18.0 (since 12.0 as
Objects.ToStringHelper.omitNullValues()
).
-
add
Adds a name/value pair to the formatted output inname=value
format. Ifvalue
isnull
, the string"null"
is used, unlessomitNullValues()
is called, in which case this name/value pair will not be added. -
add
Adds a name/value pair to the formatted output inname=value
format.- Since:
- 18.0 (since 11.0 as
Objects.ToStringHelper.add()
).
-
add
Adds a name/value pair to the formatted output inname=value
format.- Since:
- 18.0 (since 11.0 as
Objects.ToStringHelper.add()
).
-
add
Adds a name/value pair to the formatted output inname=value
format.- Since:
- 18.0 (since 11.0 as
Objects.ToStringHelper.add()
).
-
add
Adds a name/value pair to the formatted output inname=value
format.- Since:
- 18.0 (since 11.0 as
Objects.ToStringHelper.add()
).
-
add
Adds a name/value pair to the formatted output inname=value
format.- Since:
- 18.0 (since 11.0 as
Objects.ToStringHelper.add()
).
-
add
Adds a name/value pair to the formatted output inname=value
format.- Since:
- 18.0 (since 11.0 as
Objects.ToStringHelper.add()
).
-
addValue
Adds an unnamed value to the formatted output.It is strongly encouraged to use
add(String, Object)
instead and give value a readable name. -
addValue
Adds an unnamed value to the formatted output.It is strongly encouraged to use
add(String, boolean)
instead and give value a readable name.- Since:
- 18.0 (since 11.0 as
Objects.ToStringHelper.addValue()
).
-
addValue
Adds an unnamed value to the formatted output.It is strongly encouraged to use
add(String, char)
instead and give value a readable name.- Since:
- 18.0 (since 11.0 as
Objects.ToStringHelper.addValue()
).
-
addValue
Adds an unnamed value to the formatted output.It is strongly encouraged to use
add(String, double)
instead and give value a readable name.- Since:
- 18.0 (since 11.0 as
Objects.ToStringHelper.addValue()
).
-
addValue
Adds an unnamed value to the formatted output.It is strongly encouraged to use
add(String, float)
instead and give value a readable name.- Since:
- 18.0 (since 11.0 as
Objects.ToStringHelper.addValue()
).
-
addValue
Adds an unnamed value to the formatted output.It is strongly encouraged to use
add(String, int)
instead and give value a readable name.- Since:
- 18.0 (since 11.0 as
Objects.ToStringHelper.addValue()
).
-
addValue
Adds an unnamed value to the formatted output.It is strongly encouraged to use
add(String, long)
instead and give value a readable name.- Since:
- 18.0 (since 11.0 as
Objects.ToStringHelper.addValue()
).
-
isEmpty
-
toString
Returns a string in the format specified byMoreObjects.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).
-
addHolder
-
addHolder
-
addHolder
-
addUnconditionalHolder
-
addUnconditionalHolder
-
addUnconditionalHolder
-