TimestampMap implements TimeMap<Double, T> { @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final TimestampMap<?> other = (TimestampMap<?>) obj; if (this.size != other.size) { return false; } for (int i = 0; i < this.array.length && i < other.array.length; i++) { double i1 = this.array[i]; double i2 = other.array[i]; if (i1 != i2) { return false; } Object o1 = this.getValue(i); Object o2 = other.getValue(i); if ((o1 == null && o2 != null) || (o1 != null && o2 == null) || (o1 != null && o2 != null && !o1.equals(o2))) { return false; } } return true; } TimestampMap();  TimestampMap(int capacity); protected  TimestampMap(double[] keys); @Override boolean put(Double timestamp, T value); @Override boolean remove(Double timestamp); @Override T get(Double timestamp, T defaultValue); @Override Object get(Interval interval, Estimator estimator); @Override T[] toValuesArray(); @Override abstract Class<T> getTypeClass(); @Override abstract boolean isSupported(Estimator estimator); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Double timestamp); double[] getTimestamps(); @Override Double[] toKeysArray(); @Override void clear(); @Override int hashCode(); @Override boolean equals(Object obj); String toString(TimeFormat timeFormat, DateTimeZone timeZone); String toString(TimeFormat timeFormat); @Override String toString();  }
@Test public void testEquals() { double[] indices = new double[] { 1.0, 2.0, 6.0, 7.0 }; String[] values = new String[] { "a", "z", "e" }; TimestampStringMap set1 = new TimestampStringMap(); TimestampStringMap set2 = new TimestampStringMap(); TimestampStringMap set3 = new TimestampStringMap(); TimestampStringMap set4 = new TimestampStringMap(); TimestampStringMap set5 = new TimestampStringMap(); set1.put(indices[0], values[0]); set1.put(indices[1], values[1]); set1.put(indices[2], values[2]); set2.put(indices[2], values[2]); set2.put(indices[1], values[1]); set2.put(indices[0], values[0]); set3.put(indices[0], "f"); set3.put(indices[1], "o"); set3.put(indices[2], "o"); set4.put(7.0, values[0]); set4.put(8.0, values[1]); set4.put(9.0, values[2]); Assert.assertTrue(set1.equals(set2)); Assert.assertTrue(set2.equals(set1)); Assert.assertFalse(set1.equals(set3)); Assert.assertFalse(set1.equals(set4)); Assert.assertFalse(set1.equals(set5)); Assert.assertTrue(set1.hashCode() == set2.hashCode()); Assert.assertFalse(set1.hashCode() == set3.hashCode()); Assert.assertFalse(set1.hashCode() == set4.hashCode()); }