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.Arrays;
22 import java.util.Objects;
23
24 import org.apache.logging.log4j.core.config.plugins.Plugin;
25 import org.apache.logging.log4j.core.config.plugins.PluginElement;
26 import org.apache.logging.log4j.core.config.plugins.PluginFactory;
27
28
29
30
31
32 @Plugin(name = "IfAny", category = "Core", printObject = true)
33 public final class IfAny implements PathCondition {
34
35 private final PathCondition[] components;
36
37 private IfAny(final PathCondition... filters) {
38 this.components = Objects.requireNonNull(filters, "filters");
39 }
40
41 public PathCondition[] getDeleteFilters() {
42 return components;
43 }
44
45
46
47
48
49 @Override
50 public boolean accept(final Path baseDir, final Path relativePath, final BasicFileAttributes attrs) {
51 for (final PathCondition component : components) {
52 if (component.accept(baseDir, relativePath, attrs)) {
53 return true;
54 }
55 }
56 return false;
57 }
58
59
60
61
62
63 @Override
64 public void beforeFileTreeWalk() {
65 for (final PathCondition condition : components) {
66 condition.beforeFileTreeWalk();
67 }
68 }
69
70
71
72
73
74
75
76 @PluginFactory
77 public static IfAny createOrCondition(
78 @PluginElement("PathConditions") final PathCondition... components) {
79 return new IfAny(components);
80 }
81
82 @Override
83 public String toString() {
84 return "IfAny" + Arrays.toString(components);
85 }
86 }