PredicateWalker.java
1.48 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
/*
* Decompiled with CFR 0_118.
*/
package com.day.cq.search.impl.builder;
import com.day.cq.search.Predicate;
import com.day.cq.search.PredicateGroup;
import java.util.ArrayList;
import java.util.List;
public abstract class PredicateWalker {
public void visit(Predicate predicate) {
if (predicate instanceof PredicateGroup) {
this.visit((PredicateGroup)predicate);
} else {
this.visitInternal(predicate);
}
}
public void visit(PredicateGroup group) {
this.visitInternal(group);
for (Predicate p : group) {
this.visit(p);
}
}
protected abstract void visitInternal(Predicate var1);
public static class ExtractByType
extends PredicateWalker {
private String type;
protected List<Predicate> predicatesFound = new ArrayList<Predicate>();
public static List<Predicate> find(Predicate predicate, String type) {
ExtractByType walker = new ExtractByType(type);
walker.visit(predicate);
return walker.getFoundPredicates();
}
public ExtractByType(String type) {
this.type = type;
}
@Override
protected void visitInternal(Predicate predicate) {
if (this.type.equals(predicate.getType())) {
this.predicatesFound.add(predicate);
}
}
public List<Predicate> getFoundPredicates() {
return this.predicatesFound;
}
}
}