Package { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + name.hashCode(); return result; } private  Package();  Package(@Nonnull final String packageName); @Override boolean equals(final Object obj); @Nonnull String getName(); @Override int hashCode(); boolean isUndefined(); @Override String toString(); static final Package UNDEFINED; static final Package JAVA_LANG; }
@Test public void equals_identical() { final Package a = new Package("test.pkg"); final Package b = new Package("test.pkg"); assertEquals(a, b); assertTrue(a.hashCode() == b.hashCode()); }
@Test public void equals_same() { final Package a = new Package("test.pkg"); assertEquals(a, a); assertSame(a, a); assertTrue(a.hashCode() == a.hashCode()); }