public static Predicate [ ] acceptVisitor ( Predicate [ ] predicates , Visitor visitor , Indexes indexes ) { Predicate [ ] target = predicates ; boolean copyCreated = false ; for ( int i = 0 ; i < predicates . length ; i ++ ) { Predicate predicate = predicates [ i ] ; if ( predicate instanceof VisitablePredicate ) { Predicate transformed = ( ( VisitablePredicate ) predicate ) . accept ( visitor , indexes ) ; if ( transformed != predicate ) { if ( ! copyCreated ) { copyCreated = true ; target = createCopy ( target ) ; } target [ i ] = transformed ; } } } return target ; }
Accept visitor by all predicates . It treats the input array as immutable .