Class MoreObjects
java.lang.Object
org.glassfish.jersey.internal.guava.MoreObjects
Helper functions that operate on any
Object, and are not already provided in
Objects.
See the Guava User Guide on writing
Object methods with MoreObjects.
- Since:
- 18.0 (since 2.0 as
Objects) - Author:
- Laurence Gonsalves
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classSupport class fortoStringHelper(java.lang.Object). -
Method Summary
Modifier and TypeMethodDescriptionstatic MoreObjects.ToStringHelpertoStringHelper(Object self) Creates an instance ofMoreObjects.ToStringHelper.
-
Method Details
-
toStringHelper
Creates an instance ofMoreObjects.ToStringHelper.This is helpful for implementing
Object.toString(). Specification by example:// Returns "ClassName{}" MoreObjects.toStringHelper(this) .toString(); <p> // Returns "ClassName{x=1}" MoreObjects.toStringHelper(this) .add("x", 1) .toString(); <p> // Returns "MyObject{x=1}" MoreObjects.toStringHelper("MyObject") .add("x", 1) .toString(); <p> // Returns "ClassName{x=1, y=foo}" MoreObjects.toStringHelper(this) .add("x", 1) .add("y", "foo") .toString(); <p> // Returns "ClassName{x=1}" MoreObjects.toStringHelper(this) .omitNullValues() .add("x", 1) .add("y", null) .toString();}Note that in GWT, class names are often obfuscated.
- Parameters:
self- the object to generate the string for (typicallythis), used only for its class name- Since:
- 18.0 (since 2.0 as
Objects.toStringHelper().
-