CloudnamePath { public String get(final int index) { return pathElements[index]; } CloudnamePath(final String[] pathElements);  CloudnamePath(final CloudnamePath path, final String additionalElement); static boolean isValidPathElementName(final String name); int length(); String join(final char separator); String get(final int index); boolean isSubpathOf(final CloudnamePath other); CloudnamePath getParent(); @Override boolean equals(final Object other); @Override int hashCode(); @Override String toString();  }
@Test public void elementAccess() { final CloudnamePath path = new CloudnamePath(twoElements); assertThat(path.get(0), is(twoElements[0])); assertThat(path.get(1), is(twoElements[1])); }
@Test (expected = IndexOutOfBoundsException.class) public void elementAccessMustBeWithinBounds() { final CloudnamePath path = new CloudnamePath(twoElements); path.get(2); }