Path extends ArrayList<K> { @Override public String toString() { ArrayList<String> l = new ArrayList<String>(this.size()); for (K k : this) { l.add(k.toString()); } return Strings.join("/", l); } Path();  Path(List<K> keys);  Path(K... keys); @SuppressWarnings("unchecked") Path<K> to(K subKey); Path<K> via(K... subKeys); @Override String toString();  }
@Test public void createsFromArray() { Path<String> p = new Path<String>("a", "b", "c"); assertEquals(p.toString(), "a/b/c"); }
@Test public void createsFromList() { List<String> l = new LinkedList<String>(); l.add("a"); l.add("b"); l.add("c"); Path<String> p = new Path<String>(l); assertEquals(p.toString(), "a/b/c"); }