IdPath { public boolean contains(int id) { for (int part : myParts) { if (part == id) return true; } return false; } 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 testContains() { IdPath p = new IdPath(1, 2); assertTrue(p.contains(1)); assertTrue(p.contains(2)); assertFalse(p.contains(3)); }