blob: 588c53f11d39a21b9cc5be228d30ee2bf5bd439f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package com.github.javaparser.ast.validator;
import com.github.javaparser.ParseResult;
import com.github.javaparser.ast.Node;
import java.util.function.BiConsumer;
/**
* A validator that validates a known node type.
*/
public interface TypedValidator<N extends Node> extends BiConsumer<N, ProblemReporter> {
/**
* @param node the node that wants to be validated
* @param problemReporter when found, validation errors can be reported here
*/
void accept(N node, ProblemReporter problemReporter);
@SuppressWarnings("unchecked")
default ParseResult.PostProcessor postProcessor() {
return (result, configuration) ->
result.getResult().ifPresent(node ->
accept((N) node, new ProblemReporter(problem -> result.getProblems().add(problem))));
}
}
|