IdPath { public boolean startsWith(IdPath p) { if (myParts.length < p.myParts.length) return false; for (int i = 0; i < p.myParts.length; i++) { if (myParts[i] != p.myParts[i]) return false; } return true; } IdPath(int... parts);  IdPath(Stream s); void write(Stream s); int getId(); IdPath getParent(); IdPath appendedWith(int id); boolean isChildOrParentOf(IdPath p); boolean contains(int id); boolean startsWith(IdPath p); boolean rootEquals(int id); IdPath withoutRoot(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testStartsWith() { assertTrue(new IdPath(1, 2, 3).startsWith(new IdPath(1, 2))); assertTrue(new IdPath(1, 2, 3).startsWith(new IdPath(1, 2, 3))); assertFalse(new IdPath(1, 2, 3).startsWith(new IdPath(1, 3))); assertFalse(new IdPath(1, 2, 3).startsWith(new IdPath(1, 2, 3, 4))); }