1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.core.appender.rolling.action;
18
19 import java.nio.file.Path;
20 import java.nio.file.attribute.BasicFileAttributes;
21 import java.util.Objects;
22
23 import org.apache.logging.log4j.core.config.plugins.Plugin;
24 import org.apache.logging.log4j.core.config.plugins.PluginElement;
25 import org.apache.logging.log4j.core.config.plugins.PluginFactory;
26
27
28
29
30 @Plugin(name = "IfNot", category = "Core", printObject = true)
31 public final class IfNot implements PathCondition {
32
33 private final PathCondition negate;
34
35 private IfNot(final PathCondition negate) {
36 this.negate = Objects.requireNonNull(negate, "filter");
37 }
38
39 public PathCondition getWrappedFilter() {
40 return negate;
41 }
42
43
44
45
46
47 @Override
48 public boolean accept(final Path baseDir, final Path relativePath, final BasicFileAttributes attrs) {
49 return !negate.accept(baseDir, relativePath, attrs);
50 }
51
52
53
54
55
56 @Override
57 public void beforeFileTreeWalk() {
58 negate.beforeFileTreeWalk();
59 }
60
61
62
63
64
65
66
67 @PluginFactory
68 public static IfNot createNotCondition(
69 @PluginElement("PathConditions") final PathCondition condition) {
70 return new IfNot(condition);
71 }
72
73 @Override
74 public String toString() {
75 return "IfNot(" + negate + ")";
76 }
77 }