### Question:
ArchiveIdentifierPattern extends ArchiveIdentifier { @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + Objects.hash(pattern.pattern(), patternType); return result; } ArchiveIdentifierPattern(final ArchiveType archiveType, final PatternType patternType, final String regex); final PatternType getPatternType(); final Pattern getPattern(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }### Answer:
@Test public void testHashCodeSame() { final ArchiveIdentifierPattern ai1 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); final ArchiveIdentifierPattern ai2 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); Assert.assertEquals("hashCode()", ai1.hashCode(), ai2.hashCode()); }
@Test public void testHashCodeDifferentArchiveType() { final ArchiveIdentifierPattern ai1 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); final ArchiveIdentifierPattern ai2 = new ArchiveIdentifierPattern(ArchiveType.JAVASCRIPT, PatternType.PATTERN_ON_FILENAME, "abc"); Assert.assertNotEquals("hashCode()", ai1.hashCode(), ai2.hashCode()); }
@Test public void testHashCodeDifferentPatternType() { final ArchiveIdentifierPattern ai1 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); final ArchiveIdentifierPattern ai2 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_PATH, "abc"); Assert.assertNotEquals("hashCode()", ai1.hashCode(), ai2.hashCode()); }
@Test public void testHashCodeDifferentRegex() { final ArchiveIdentifierPattern ai1 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "abc"); final ArchiveIdentifierPattern ai2 = new ArchiveIdentifierPattern(ArchiveType.JAVA, PatternType.PATTERN_ON_FILENAME, "def"); Assert.assertNotEquals("hashCode()", ai1.hashCode(), ai2.hashCode()); }