public final class Objects extends Object
Object.
NOTE: proxy for the Guava implementation of com.google.common.base.Objects.
| Modifier and Type | Class and Description |
|---|---|
static class |
Objects
Support class for
toStringHelper(java.lang.Object).
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
equal(Object
Determines whether two possibly-null objects are equal.
|
static Objects |
toStringHelper(Object
Creates an instance of
Objects.ToStringHelper.
|
public static boolean equal(Objecta, Object b)
true if a and b are both null.true if a and b are both non-null and they are equal according to Object.equals(Object) .false in all other situations. This assumes that any non-null objects passed to this function conform to the equals() contract.
public static Objects.ToStringHelper toStringHelper(Object self)
Objects.ToStringHelper.
This is helpful for implementing Object. Specification by example:
// Returns "ClassName{}"
Objects.toStringHelper(this)
.toString();
// Returns "ClassName{x=1}"
Objects.toStringHelper(this)
.add("x", 1)
.toString();
// Returns "MyObject{x=1}"
Objects.toStringHelper("MyObject")
.add("x", 1)
.toString();
// Returns "ClassName{x=1, y=foo}"
Objects.toStringHelper(this)
.add("x", 1)
.add("y", "foo")
.toString();
// Returns "ClassName{x=1}"
Objects.toStringHelper(this)
.omitNullValues()
.add("x", 1)
.add("y", null)
.toString();
self - the object to generate the string for (typically
this), used only for its class name