DERPath { @Override public int hashCode() { int hc = HASH_CODE_SEED; for (Node n : nodeStack) { hc = HASH_CODE_SEED * hc + n.hashCode(); } return hc; } DERPath();  DERPath(final DERPath path);  DERPath(final String pathSpec); DERPath pushNode(final String name); DERPath pushNode(final String name, final int index); String peekNode(); String popNode(); int getSize(); boolean isEmpty(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); static final String PATH_SEPARATOR; }
@Test(groups = "asn1") public void testHashCode() throws Exception { Assert.assertEquals(new DERPath("SEQ").hashCode(), new DERPath("SEQ").hashCode()); Assert.assertNotEquals(new DERPath("ENUM").hashCode(), new DERPath("INT").hashCode()); Assert.assertEquals( new DERPath("APP(0)").pushNode("CTX(0)").hashCode(), new DERPath("APP(0)").pushNode("CTX(0)").hashCode()); Assert.assertNotEquals( new DERPath("APP(0)").pushNode("CTX(0)").hashCode(), new DERPath("CTX(0)").pushNode("APP(0)").hashCode()); }
@Test(groups = "asn1") public void testHashcode() throws Exception { Assert.assertEquals(new DERPath("/SEQ[0]/OCTSTR[1]").hashCode(), new DERPath("/SEQ[0]/OCTSTR[1]").hashCode()); Assert.assertFalse(new DERPath("/SEQ[0]/OCTSTR[1]").hashCode() == new DERPath("/SEQ[0]/OCTSTR[2]").hashCode()); Assert.assertFalse(new DERPath("/SEQ[0]/OCTSTR[1]").hashCode() == new DERPath("/SEQ/OCTSTR[2]").hashCode()); }