1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.rat.configuration.builders;
20
21 import org.apache.rat.ConfigurationException;
22 import org.apache.rat.analysis.IHeaderMatcher;
23 import org.apache.rat.analysis.matchers.NotMatcher;
24 import org.apache.rat.config.parameters.MatcherBuilder;
25
26
27
28
29 @MatcherBuilder(NotMatcher.class)
30 public class NotBuilder extends ChildContainerBuilder {
31
32 @Override
33 public NotMatcher build() {
34 if (children.isEmpty()) {
35 throw new ConfigurationException("'not' type matcher requires one and only one enclosed matcher");
36 }
37 return new NotMatcher(getId(), children.get(0).build());
38 }
39
40 @Override
41 public String toString() {
42 return String.format("NotBuilder: %s", !children.isEmpty() ? children.get(0) : null);
43 }
44
45
46
47
48
49
50 public NotBuilder setEnclosed(final IHeaderMatcher.Builder enclosed) {
51 if (children.isEmpty()) {
52 children.add(enclosed);
53 } else {
54 children.set(0, enclosed);
55 }
56 return this;
57 }
58 }