@Test public void equivalentFactsShouldHaveTheSametHashCode() { Fact<String> fact1 = new Fact<String>("fact1", "Fact One"); Fact<String> fact2 = new Fact<String>("fact1", "Fact One"); Fact<Double> fact3 = new Fact<Double>("fact2", 1.25); Fact<Double> fact4 = new Fact<Double>("fact2", 1.25); Assert.assertEquals(fact3, fact4); Assert.assertEquals(fact1, fact2); Assert.assertEquals(fact1.hashCode(), fact2.hashCode()); Assert.assertEquals(fact3.hashCode(), fact4.hashCode()); Assert.assertNotEquals(fact1, fact3); }
@Override public int hashCode() { return (_name.hashCode() + _value.hashCode()) % Integer.MAX_VALUE; }
Fact implements NameValueReferable<T> { @Override public int hashCode() { return (_name.hashCode() + _value.hashCode()) % Integer.MAX_VALUE; } }
Fact implements NameValueReferable<T> { @Override public int hashCode() { return (_name.hashCode() + _value.hashCode()) % Integer.MAX_VALUE; } Fact(String name, T value);  Fact(T obj);  Fact(NameValueReferable<T> fact); }
Fact implements NameValueReferable<T> { @Override public int hashCode() { return (_name.hashCode() + _value.hashCode()) % Integer.MAX_VALUE; } Fact(String name, T value);  Fact(T obj);  Fact(NameValueReferable<T> fact); @Override String getName(); @Override void setName(String name); @Override T getValue(); @Override void setValue(T value); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
Fact implements NameValueReferable<T> { @Override public int hashCode() { return (_name.hashCode() + _value.hashCode()) % Integer.MAX_VALUE; } Fact(String name, T value);  Fact(T obj);  Fact(NameValueReferable<T> fact); @Override String getName(); @Override void setName(String name); @Override T getValue(); @Override void setValue(T value); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }