LaunchExclusionConfig.java
2.34 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.cq.wcm.launches.impl.msm.utils;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class LaunchExclusionConfig {
public static final LaunchExclusionConfig EMPTY_EXCLUSION_CONFIG = new LaunchExclusionConfig(null, null, null);
private static final Set<Pattern> EMPTY_PATTERNS = Collections.unmodifiableSet(Collections.emptySet());
private Set<Pattern> pagePropertyPatterns;
private Set<Pattern> paragraphItemPatterns;
private Set<Pattern> nodeTypePatterns;
public LaunchExclusionConfig(Set<String> excludedPageProperties, Set<String> excludedParagraphItems, Set<String> excludedNodeTypes) {
this.pagePropertyPatterns = this.buildPatterns(excludedPageProperties);
this.paragraphItemPatterns = this.buildPatterns(excludedParagraphItems);
this.nodeTypePatterns = this.buildPatterns(excludedNodeTypes);
}
public boolean matchExcludedParagraphItem(String itemName) {
return this.match(itemName, this.getParagraphItems());
}
public boolean matchExcludedPageProperty(String propertyName) {
return this.match(propertyName, this.getPageProperties());
}
public boolean matchExcludedNodeType(String nodeType) {
return this.match(nodeType, this.getNodeTypes());
}
private Set<Pattern> getPageProperties() {
return this.pagePropertyPatterns;
}
private Set<Pattern> getParagraphItems() {
return this.paragraphItemPatterns;
}
private Set<Pattern> getNodeTypes() {
return this.nodeTypePatterns;
}
private boolean match(String data, Set<Pattern> patterns) {
if (data == null) {
return false;
}
for (Pattern pattern : patterns) {
if (!pattern.matcher(data).matches()) continue;
return true;
}
return false;
}
private Set<Pattern> buildPatterns(Set<String> patterns) {
if (patterns != null && patterns.size() > 0) {
HashSet<Pattern> pats = new HashSet<Pattern>(patterns.size());
for (String pattern : patterns) {
pats.add(Pattern.compile(pattern));
}
return Collections.unmodifiableSet(pats);
}
return EMPTY_PATTERNS;
}
}