Segment.java
2.56 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* Decompiled with CFR 0_118.
*/
package com.day.cq.personalization;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Segment {
public static final String NAME_PERCENTILE = "percentile";
private final String name;
private final String operator;
private final List<String> values;
private final Kind kind;
private final List<Segment> children = new ArrayList<Segment>();
public static Segment newLogicSegment(Kind kind) {
if (kind == Kind.Direct) {
throw new IllegalArgumentException("Segment kind " + (Object)((Object)kind) + " is invalid for a logic segment.");
}
return new Segment(null, null, Collections.<String>emptyList(), kind);
}
public static Segment newDirectSegment(String name, String operator, String value) {
return new Segment(name, operator, Collections.singletonList(value), Kind.Direct);
}
public static Segment newDirectSegment(String name, String operator, List<String> values) {
return new Segment(name, operator, values, Kind.Direct);
}
public static Segment newExternalReferenceSegment(String name, String operator, String externalId) {
return new Segment(name, operator, Collections.singletonList(externalId), Kind.ExternalReference);
}
public static Segment newByPathSegment(String path) {
return new Segment(null, null, Collections.singletonList(path), Kind.ClientOnly);
}
private Segment(String name, String operator, List<String> values, Kind kind) {
this.name = name;
this.operator = operator;
this.values = values;
this.kind = kind;
}
public Kind getKind() {
return this.kind;
}
public String getName() {
return this.name;
}
public String getOperator() {
return this.operator;
}
public List<String> getValue() {
return this.values;
}
public List<Segment> getChildren() {
return Collections.unmodifiableList(this.children);
}
public void addChild(Segment resolvedSegment) {
this.children.add(resolvedSegment);
}
public String toString() {
return "[" + Segment.class.getSimpleName() + "# name : " + this.name + ", operator: " + this.operator + ", " + "values: " + this.values + " kind: " + (Object)((Object)this.kind) + ", children.size(): " + this.children.size() + "]";
}
public static enum Kind {
And,
Or,
Direct,
ExternalReference,
ClientOnly;
private Kind() {
}
}
}