-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathIgnoredPathMatcher.java
More file actions
32 lines (25 loc) · 984 Bytes
/
IgnoredPathMatcher.java
File metadata and controls
32 lines (25 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.deblock.jsondiff.matcher;
import com.deblock.jsondiff.diff.JsonDiff;
import com.deblock.jsondiff.diff.MatchedPrimaryDiff;
import tools.jackson.databind.JsonNode;
import java.util.Arrays;
import java.util.List;
public class IgnoredPathMatcher implements PartialJsonMatcher {
private final List<PathMatcher> pathsToIgnore;
public IgnoredPathMatcher(List<String> paths) {
this.pathsToIgnore = paths.stream()
.map(PathMatcher::from)
.toList();
}
public IgnoredPathMatcher(String ...paths) {
this(Arrays.stream(paths).toList());
}
@Override
public JsonDiff jsonDiff(Path path, JsonNode expectedJson, JsonNode receivedJson, JsonMatcher jsonMatcher) {
return new MatchedPrimaryDiff(path, expectedJson);
}
@Override
public boolean manage(Path path, JsonNode expected, JsonNode received) {
return pathsToIgnore.stream().anyMatch(pattern -> pattern.match(path));
}
}