Creates an instance of {@link ToStringHelper}. <p>This is helpful for implementing {@link Object#toString()}. Specification by example: {@snippet : // Returns "ClassName{}" MoreObjects.toStringHelper(this) .toString(); // Returns "ClassName{x=1}" MoreObjects.toStringHelper(this) .add("x",
(Object self)
| 113 | * @since 18.0 (since 2.0 as {@code Objects.toStringHelper}). |
| 114 | */ |
| 115 | public static ToStringHelper toStringHelper(Object self) { |
| 116 | return new ToStringHelper(self.getClass().getSimpleName()); |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Creates an instance of {@link ToStringHelper} in the same manner as {@link |