/** * Returns a hash code for {@code value}; equal to the result of invoking {@code ((Double) * value).hashCode()}. * * <p><b>Java 8 users:</b> use {@link Double#hashCode(double)} instead. * * @param value a primitive {@code double} value * @return a hash code for the value */ public static int hashCode(double value) { return ((Double) value).hashCode(); // TODO(kevinb): do it this way when we can (GWT problem): // long bits = Double.doubleToLongBits(value); // return (int) (bits ^ (bits >>> 32)); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((value == null) ? 0 : value.hashCode()); return result; }
/** * Return the same value as {@link Double#hashCode(double)}}. * @deprecated as of Spring Framework 5.0, in favor of the native JDK 8 variant */ @Deprecated public static int hashCode(double dbl) { return Double.hashCode(dbl); }
/** * Returns a hash code for {@code value}; equal to the result of invoking {@code ((Double) * value).hashCode()}. * * <p><b>Java 8 users:</b> use {@link Double#hashCode(double)} instead. * * @param value a primitive {@code double} value * @return a hash code for the value */ public static int hashCode(double value) { return ((Double) value).hashCode(); // TODO(kevinb): do it this way when we can (GWT problem): // long bits = Double.doubleToLongBits(value); // return (int) (bits ^ (bits >>> 32)); }
/** * Return a hash code based on the contents of the specified array. * If {@code array} is {@code null}, this method returns 0. */ public static int nullSafeHashCode(@Nullable double[] array) { if (array == null) { return 0; } int hash = INITIAL_HASH; for (double element : array) { hash = MULTIPLIER * hash + Double.hashCode(element); } return hash; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((score == null) ? 0 : score.hashCode()); result = prime * result + ((value == null) ? 0 : value.hashCode()); return result; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((score == null) ? 0 : score.hashCode()); result = prime * result + ((value == null) ? 0 : value.hashCode()); return result; }
@Override public int hashCode() { return (new Double(alpha)).hashCode(); }
@Override public int hashCode() { return (name.hashCode() * 31 + field.hashCode()) * 31 + Double.hashCode(fraction); }
@Override public int hashCode() { return i.hashCode(); }
@Override public int hashCode() { double value = getValue(MILLISECONDS); return Double.hashCode(value); }
@Override public int hashCode() { double value = getValue(Unit.BYTE); return Double.hashCode(value); }
@Override public int getUnsortedEncodedKeyComponentHashCode(@Nullable Double key) { return DimensionHandlerUtils.nullToZero(key).hashCode(); }
@Override public int hashCode() { return Double.valueOf(doubleValue()).hashCode(); } }
@Override public int hashCode() { return Double.valueOf(doubleValue()).hashCode(); } }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + new Double(count).hashCode(); result = 31 * result + timeWindow; result = 31 * result + grade; return result; }
public void testHashCode() { for (double value : VALUES) { assertEquals(((Double) value).hashCode(), Doubles.hashCode(value)); } }
@Test @Deprecated public void hashCodeWithDouble() { double dbl = 9830.43; int expected = (new Double(dbl)).hashCode(); assertEquals(expected, ObjectUtils.hashCode(dbl)); }
@Test public void testHashCode() { final MutableDouble mutNumA = new MutableDouble(0d); final MutableDouble mutNumB = new MutableDouble(0d); final MutableDouble mutNumC = new MutableDouble(1d); assertTrue(mutNumA.hashCode() == mutNumA.hashCode()); assertTrue(mutNumA.hashCode() == mutNumB.hashCode()); assertFalse(mutNumA.hashCode() == mutNumC.hashCode()); assertTrue(mutNumA.hashCode() == Double.valueOf(0d).hashCode()); }