Package com.google.common.base
Class Objects
-
- com.google.common.base.Objects
-
@GwtCompatible public final class Objects extends
Helper functions that can operate on anyObject
.See the Guava User Guide on .
- Since:
- 2.0
- Author:
- Laurence Gonsalves
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
a, b)
Determines whether two possibly-null objects are equal.static int
... objects)
Generates a hash code for multiple values.
-
-
-
Method Detail
-
equal
public static boolean a, b)
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 to .false
in all other situations.
This assumes that any non-null objects passed to this function conform to the
equals()
contract.Note for Java 7 and later: This method should be treated as deprecated; use instead.
-
hashCode
public static int ... objects)
Generates a hash code for multiple values. The hash code is generated by calling . Note that array arguments to this method, with the exception of a single Object array, do not get any special handling; their hash codes are based on identity and not contents.This is useful for implementing . For example, in an object that has three properties,
x
,y
, andz
, 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.
Note for Java 7 and later: This method should be treated as deprecated; use instead.
-
-