public <T extends Entry>void walk(Entry start,RepositoryVisitor<T> visitor,Class<T> visitedType) throws RepositoryException {
  boolean continueChildren=true;
  if (visitedType.isInstance(start)) {
    continueChildren&=visitor.visit(visitedType.cast(start));
  }
  if (continueChildren && start instanceof Folder) {
    Folder folder=(Folder)start;
    for (    Entry child : folder.getDataEntries()) {
      walk(child,visitor,visitedType);
    }
    for (    Folder childFolder : folder.getSubfolders()) {
      walk(childFolder,visitor,visitedType);
    }
  }
}

public < T extends Entry > void walk ( Entry start , RepositoryVisitor < T > visitor , Class < T > visitedType ) throws RepositoryException { boolean continueChildren = true ; if ( visitedType . isInstance ( start ) ) { continueChildren &= visitor . visit ( visitedType . cast ( start ) ) ; } if ( continueChildren && start instanceof Folder ) { Folder folder = ( Folder ) start ; for ( Entry child : folder . getDataEntries ( ) ) { walk ( child , visitor , visitedType ) ; } for ( Folder childFolder : folder . getSubfolders ( ) ) { walk ( childFolder , visitor , visitedType ) ; } } }
visitor pattern for repositories . callbacks to the visitor will be made only for matching types . ( recursion happens also if the type is not a folder .
