List of usage examples for java.lang Object hashCode
@HotSpotIntrinsicCandidate public native int hashCode();
From source file:com.googlecode.memcachefy.hashkey.HashKeyGenerator.java
/** * Generates a hashkey using the object's own hashCode function * * @param method/*from w ww . ja v a2s .c o m*/ * @param parameters * @return */ public static Integer defaultHashKey(Method method, Object[] parameters) { int hashCode = method.getName().hashCode(); if (parameters == null || parameters.length == 0) { return hashCode; } if (parameters.length == 1) { return 17 * hashCode + (parameters[0] == null ? method.getName().hashCode() : parameters[0].hashCode()); } for (Object object : parameters) { hashCode = 31 * hashCode + (object == null ? NULL_PARAM_KEY : object.hashCode()); } return hashCode; }
From source file:Main.java
public static int hashCode(@Nullable Object o1, @Nullable Object o2, @Nullable Object o3) { return hashCode(o1 == null ? 0 : o1.hashCode(), o2 == null ? 0 : o2.hashCode(), o3 == null ? 0 : o3.hashCode()); }
From source file:edu.cornell.mannlib.vitro.webapp.utils.logging.ToString.java
public static String hashHex(Object o) { return (o == null) ? "@00000000" : String.format("@%08x", o.hashCode()); }
From source file:Main.java
public static int hashCode(@Nullable Object o1, @Nullable Object o2, @Nullable Object o3, @Nullable Object o4) { return hashCode(o1 == null ? 0 : o1.hashCode(), o2 == null ? 0 : o2.hashCode(), o3 == null ? 0 : o3.hashCode(), o4 == null ? 0 : o4.hashCode()); }
From source file:org.pentaho.di.utils.TestUtils.java
public static void checkEqualsHashCodeConsistency(Object object1, Object object2) { if (object1.equals(object2)) { assertTrue("inconsistent hashcode and equals", object1.hashCode() == object2.hashCode()); }//from w w w .ja v a 2s .co m }
From source file:Main.java
private static int listHashCode(Iterable<?> l) { int ret = 1;//from ww w. jav a 2 s . co m for (Object e : l) { // don't overflow stack if list contains itself -- substitute default hashcode int elementHash = e == l ? System.identityHashCode(l) : (e == null ? 0 : e.hashCode()); ret = 31 * ret + elementHash; } return ret; }
From source file:Main.java
public static int hashCode(@Nullable Object o1, @Nullable Object o2, @Nullable Object o3, @Nullable Object o4, @Nullable Object o5) {// w w w. jav a2s . com return hashCode(o1 == null ? 0 : o1.hashCode(), o2 == null ? 0 : o2.hashCode(), o3 == null ? 0 : o3.hashCode(), o4 == null ? 0 : o4.hashCode(), o5 == null ? 0 : o5.hashCode()); }
From source file:Main.java
/** * Computes the hash code for a set per the contract defined by {@link Set#hashCode()}. * //w w w . j a v a2 s. c o m * @param set the set * @return the hash code for {@code list} */ public static int hashCode(Set<?> set) { int hashCode = 0; for (Object item : set) { if (item != null) { // don't overflow stack if set contains itself -- substitute default hashcode hashCode += item == set ? System.identityHashCode(set) : item.hashCode(); } } return hashCode; }
From source file:Main.java
public static int hashCode(@Nullable Object o1, @Nullable Object o2, @Nullable Object o3, @Nullable Object o4, @Nullable Object o5, @Nullable Object o6) { return hashCode(o1 == null ? 0 : o1.hashCode(), o2 == null ? 0 : o2.hashCode(), o3 == null ? 0 : o3.hashCode(), o4 == null ? 0 : o4.hashCode(), o5 == null ? 0 : o5.hashCode(), o6 == null ? 0 : o6.hashCode()); }
From source file:com.dragome.callbackevictor.serverside.utils.ReflectionUtils.java
public static String getClassName(final Object o) { if (o == null) { return "unknown"; }// w w w.j a va 2 s. c o m return o.getClass().getName() + "@" + o.hashCode(); }