Setting { @Override public int hashCode() { return name.hashCode(); } protected  Setting(@NonNls final String name); @Override boolean equals(final Object o); @Override int hashCode(); static final Setting LOGGING; static final Setting SYSTEM_TRAY; }
@Test public void equalsAndHashCodeShouldBeTrueIfSameInstance() { final Setting one = new Setting("TEST1"); assertEquals(one, one); assertEquals(one.hashCode(), one.hashCode()); }
@Test public void equalsAndHashCodeShouldBeTrueIfSameName() { final Setting one = new Setting("TEST1"); final Setting two = new Setting("TEST1"); assertEquals(one, two); assertEquals(two, one); assertEquals(one.hashCode(), two.hashCode()); }
@Test public void equalsAndHashCodeShouldBeFalseIfDifferentName() { final Setting one = new Setting("TEST1"); final Setting two = new Setting("TEST2"); assertNotEquals(one, two); assertNotEquals(two, one); assertNotEquals(one.hashCode(), two.hashCode()); }