IdPath { public IdPath appendedWith(int id) { int[] newPath = new int[myParts.length + 1]; System.arraycopy(myParts, 0, newPath, 0, myParts.length); newPath[newPath.length - 1] = id; return new IdPath(newPath); } 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 testAppending() { IdPath p = new IdPath(1, 2); assertEquals(new IdPath(1, 2, 3), p.appendedWith(3)); }
@Test public void testAppendingDoesNotChangeOriginal() { IdPath p = new IdPath(1, 2); p.appendedWith(3); assertEquals(new IdPath(1, 2), p); }