@Override public boolean accept(ICompilerProblem problem) { switch ( this.operator ) { case And: return left.accept(problem) && right.accept(problem); case Or: return left.accept(problem) || right.accept(problem); case Not: return ! (left.accept(problem) ); } assert(false): "Uncovered composition case " + this.operator; return false; }
@Override public boolean accept(ICompilerProblem problem) { switch ( this.operator ) { case And: return left.accept(problem) && right.accept(problem); case Or: return left.accept(problem) || right.accept(problem); case Not: return ! (left.accept(problem) ); } assert(false): "Uncovered composition case " + this.operator; return false; }
/** * Position to the next problem that matches the filter. * @post currentProblem is not null if findNext() returns true. */ private boolean findNext() { while (this.currentProblem == null && this.underlyingProblems.hasNext() ) { ICompilerProblem candidate = this.underlyingProblems.next(); if ( filter.accept(candidate) ) this.currentProblem = candidate; } return this.currentProblem != null; }
/** * Position to the next problem that matches the filter. * @post currentProblem is not null if findNext() returns true. */ private boolean findNext() { while (this.currentProblem == null && this.underlyingProblems.hasNext() ) { ICompilerProblem candidate = this.underlyingProblems.next(); if ( filter.accept(candidate) ) this.currentProblem = candidate; } return this.currentProblem != null; }
/** * Print problems and return number of problems printed after applying the * filter. * * @param problems compiler problems * @param filter problem filter * @return count of printed problems */ public int printProblems(final Collection<ICompilerProblem> problems, IProblemFilter filter) { if (problems == null || problems.isEmpty()) return 0; List<ICompilerProblem> filteredProblems = new ArrayList<ICompilerProblem>(); for (final ICompilerProblem problem : problems) { if ((filter == null) || (filter.accept(problem))) { filteredProblems.add(problem); } } return printProblems(filteredProblems); }
/** * Print problems and return number of problems printed after applying the * filter. * * @param problems compiler problems * @param filter problem filter * @return count of printed problems */ public int printProblems(final Collection<ICompilerProblem> problems, IProblemFilter filter) { if (problems == null || problems.isEmpty()) return 0; List<ICompilerProblem> filteredProblems = new ArrayList<ICompilerProblem>(); for (final ICompilerProblem problem : problems) { if ((filter == null) || (filter.accept(problem))) { filteredProblems.add(problem); } } return printProblems(filteredProblems); }