org.elasticsearch.common.inject.internal
Class Objects

java.lang.Object
  extended by org.elasticsearch.common.inject.internal.Objects

public final class Objects
extends Object

Helper functions that can operate on any Object.

Author:
Laurence Gonsalves

Method Summary
static boolean equal(Object a, Object b)
          Determines whether two possibly-null objects are equal.
static int hashCode(Object... objects)
          Generates a hash code for multiple values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

equal

public static boolean equal(@Nullable
                            Object a,
                            @Nullable
                            Object b)
Determines whether two possibly-null objects are equal. Returns:

This assumes that any non-null objects passed to this function conform to the equals() contract.


hashCode

public static int hashCode(Object... objects)
Generates a hash code for multiple values. The hash code is generated by calling Arrays.hashCode(Object[]).

This is useful for implementing Object.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.



Copyright © 2009-2012. All Rights Reserved.