-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilter.java
More file actions
58 lines (39 loc) · 1.23 KB
/
Copy pathFilter.java
File metadata and controls
58 lines (39 loc) · 1.23 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
import java.util.ArrayList;
public class Filter{
public enum FilterAction{SORT_BY_ASCENDING, SORT_BY_DESCENDING, INCLUDE_IF, EXCLUDE_IF};
public enum FilterType{STARTS_WITH, ENDS_WITH, CONTAINS, EQUALS};
private FilterAction action;
private FilterType type;
private String field, value;
public Filter(FilterAction a, String f){
this(a, f, null, null);
}
public Filter(FilterAction a, String f, FilterType ft, String v){
if ((a == FilterAction.INCLUDE_IF || a==FilterAction.EXCLUDE_IF) && (ft ==null || v == null))
throw new IllegalArgumentException("No filter type or value provided for non-sort filter!");
action = a;
field = f;
type = ft;
value = v;
}
public boolean isSort(){
return (action == FilterAction.SORT_BY_ASCENDING || action == FilterAction.SORT_BY_DESCENDING);
}
public FilterAction getAction(){
return action;
}
public FilterType getFilterType(){
return type;
}
public String getField(){
return field;
}
public String getValue(){
return value;
}
public String toString(){
if (isSort())
return action + " " + field;
return action + " " + field + " " + type + " " + value;
}
}