| java.lang.Object | |
| ↳ | com.google.gdata.util.common.base.Objects |
Helper functions that can operate on any Object.
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Objects.ToStringHelper | Helper class for generating consistent toString across ads/api pojos. | ||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Determines if two objects are equal as determined by
equals(Object), or "deeply equal" if both are arrays. | |||||||||||
Determines the hash code of an object, returning a hash code based on the
array's "deep contents" if the object is an array.
| |||||||||||
Determines the string representation of an object, or the "deep contents
of the array if the
obj is an array. | |||||||||||
Determines whether two possibly-null objects are equal.
| |||||||||||
Returns the first of two given parameters that is not
null, if
either is, or otherwise throws a NullPointerException. | |||||||||||
Generates a hash code for multiple values.
| |||||||||||
Checks that the specified object is not
null. | |||||||||||
Checks that the specified object is not
null. | |||||||||||
Creates an instance of
Objects.ToStringHelper. | |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Determines if two objects are equal as determined by
equals(Object), or "deeply equal" if both are arrays.
If both objects are null, true is returned. If only one is null,
false is returned. If both objects are arrays, the corresponding
deepEquals(Object[], Object[]), or
equals(int[], int[]) or the like are called to determine
equality. Otherwise, a.equals(b) is returned.
Note that this method does not "deeply" compare the fields of the objects.
| a | |
|---|---|
| b |
Determines the hash code of an object, returning a hash code based on the array's "deep contents" if the object is an array.
If obj is null, 0 is returned. If obj is an array, the
corresponding deepHashCode(Object[]), or
hashCode(int[]) or the like is used to calculate the hash
code. If obj isn't null or an array, obj.hashCode() is
returned.
| obj |
|---|
Determines the string representation of an object, or the "deep contents
of the array if the obj is an array.
If obj is null, "null" is returned; if obj is an
array, the corresponding deepToString(Object[]),
toString(int[]) or the like is used to generate the string.
If obj isn't null or an array, obj.toString() is returned.
| obj |
|---|
Determines whether two possibly-null objects are equal. Returns:
true if a and b are both null.
true if a and b are both non-null and they are
equal according to equals(Object).
false in all other situations.
This assumes that any non-null objects passed to this function conform
to the equals() contract.
| a | |
|---|---|
| b |
Returns the first of two given parameters that is not null, if
either is, or otherwise throws a NullPointerException.
| first | |
|---|---|
| second |
first if first is not null, or
second if first is null and second is
not null| NullPointerException | if both first and second were
null
|
|---|
Generates a hash code for multiple values. The hash code is generated by
calling hashCode(Object[]).
This is useful for implementing hashCode(). For example,
in an object that has three properties, x, y, and
z, one could write:
public int hashCode() {
return Objects.hashCode(getX(), getY(), getZ());
}
Warning: When a single object is supplied, the returned hash code
does not equal the hash code of that object.
| objects |
|---|
Checks that the specified object is not null.
| obj | The object to check for nullness |
|---|
obj if not null.| NullPointerException | if obj is null.
|
|---|
Checks that the specified object is not null.
| obj | The object to check for nullness |
|---|---|
| message | Exception message used in the event that a NullPointerException is thrown |
obj if not null| NullPointerException | if obj is null
|
|---|
Creates an instance of Objects.ToStringHelper.
This is helpful for implementing toString(). For
example, in an object that contains two member variables, x,
and y, one could write:
public class ClassName {
public String toString() {
return Objects.toStringHelper(this)
.add("x", x)
.add("y", y)
.toString();
}
}
Assuming the values of x and y are 1 and 2,
this code snippet returns the string "ClassName{x=1, y=2}".
| object |
|---|