Package com.google.api.client.util
Class Objects
java.lang.Object
com.google.api.client.util.Objects
Helper functions that can operate on any
Object
.- Since:
- 1.14
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Support class fortoStringHelper(java.lang.Object)
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Determines whether two possibly-null objects are equal.static Objects.ToStringHelper
toStringHelper
(Object self) Creates an instance ofObjects.ToStringHelper
.
-
Constructor Details
-
Objects
private Objects()
-
-
Method Details
-
equal
Determines whether two possibly-null objects are equal. Returns:true
ifa
andb
are both null.true
ifa
andb
are both non-null and they are equal according toObject.equals(Object)
.false
in all other situations.
This assumes that any non-null objects passed to this function conform to the
equals()
contract. -
toStringHelper
Creates an instance ofObjects.ToStringHelper
.This is helpful for implementing
Object.toString()
. 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();
- Parameters:
self
- the object to generate the string for (typicallythis
), used only for its class name
-