Thomas Müller wrote:
Hi,

I believe this is the right solution for now. With static import:

for (Node child : childNodes(node)) { ... }

This is far more readable than:

for (NodeIterator it = node.getNodes(); it.hasNext();) {
    Node child = it.nextNode();
    ...
}

I disagree here; it depends on how familiar the reader is with static imports in general, and JCRUtils in particular. It's shorter, but requires additional knowledge of both language and libraries in use.

The best API would be probably:
for (Node child : node.getNodeList())
...

The best API would be:

  for (Node child : node.getNodes())
  ...

and I think we get there once java.util.Iterator implements Iterable, which I think is planned for future Java release.

BR, Julian


Reply via email to