1 package com.github.javaparser.ast.validator; 2 3 import com.github.javaparser.ast.Node; 4 5 import java.util.function.BiConsumer; 6 import java.util.function.Predicate; 7 8 /** 9 * Runs a validator on all nodes of a certain type, 10 * and adds a problem for all nodes that pass a condition. 11 */ 12 public class SimpleValidator<N extends Node> extends SingleNodeTypeValidator<N> { 13 public SimpleValidator(Class<N> type, Predicate<N> condition, BiConsumer<N, ProblemReporter> problemSupplier) { 14 super(type, (node, problemReporter) -> { 15 if (condition.test(node)) { 16 problemSupplier.accept(node, problemReporter); 17 } 18 }); 19 } 20 } 21