1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.rat.analysis.matchers;
20
21 import java.util.Objects;
22
23 import org.apache.rat.analysis.IHeaderMatcher;
24 import org.apache.rat.analysis.IHeaders;
25 import org.apache.rat.config.parameters.ComponentType;
26 import org.apache.rat.config.parameters.ConfigComponent;
27
28
29
30
31 @ConfigComponent(type = ComponentType.MATCHER, name = "not",
32 desc = "A matcher that wraps one matcher and negates its value. Not matchers require that the entire " +
33 "header be read before it can report true or false. This may significantly slow processing.")
34 public class NotMatcher extends AbstractHeaderMatcher {
35
36
37
38 @ConfigComponent(desc = "enclosed Matcher", type = ComponentType.PARAMETER, parameterType = IHeaderMatcher.class, required = true)
39 private final IHeaderMatcher enclosed;
40
41
42
43
44
45
46
47 public NotMatcher(final String id, final IHeaderMatcher enclosed) {
48 super(id);
49 Objects.requireNonNull(enclosed, "enclosed matcher may not be null");
50 this.enclosed = enclosed;
51 }
52
53 public IHeaderMatcher getEnclosed() {
54 return enclosed;
55 }
56
57 @Override
58 public boolean matches(final IHeaders headers) {
59 return !enclosed.matches(headers);
60 }
61
62 @Override
63 public void reset() {
64 enclosed.reset();
65 }
66 }