@@ -7,17 +7,18 @@ type Filter interface {
7
7
Append (filter Filter )
8
8
}
9
9
10
- // AND
11
-
10
+ // AndFilter filters entries by and operation
12
11
type AndFilter struct {
13
12
Type string
14
13
Children []Filter
15
14
}
16
15
16
+ // NewAndFilter inititalizes a new AndFilter
17
17
func NewAndFilter () * AndFilter {
18
18
return & AndFilter {Type : "and" }
19
19
}
20
20
21
+ // Match matches entry input
21
22
func (f * AndFilter ) Match (input Input ) bool {
22
23
for _ , filter := range f .Children {
23
24
if ! filter .Match (input ) {
@@ -27,21 +28,23 @@ func (f *AndFilter) Match(input Input) bool {
27
28
return true
28
29
}
29
30
31
+ // Append appends a new filter
30
32
func (f * AndFilter ) Append (filter Filter ) {
31
33
f .Children = append (f .Children , filter )
32
34
}
33
35
34
- // OR
35
-
36
+ // OrFilter filters entries by or operation
36
37
type OrFilter struct {
37
38
Type string
38
39
Children []Filter
39
40
}
40
41
42
+ // NewOrFilter inititalizes a new OrFilter
41
43
func NewOrFilter () * OrFilter {
42
44
return & OrFilter {Type : "or" }
43
45
}
44
46
47
+ // Match matches entry input
45
48
func (f * OrFilter ) Match (input Input ) bool {
46
49
if len (f .Children ) == 0 {
47
50
return true
@@ -54,22 +57,24 @@ func (f *OrFilter) Match(input Input) bool {
54
57
return false
55
58
}
56
59
60
+ // Append appends a new filter
57
61
func (f * OrFilter ) Append (filter Filter ) {
58
62
f .Children = append (f .Children , filter )
59
63
}
60
64
61
- // EQUALITY
62
-
65
+ // EqualityFilter filters entries by equality
63
66
type EqualityFilter struct {
64
67
Type string
65
68
Key string
66
69
Value string
67
70
}
68
71
72
+ // NewEqualityFilter inititalizes a new EqualityFilter
69
73
func NewEqualityFilter () * EqualityFilter {
70
74
return & EqualityFilter {Type : "equality" }
71
75
}
72
76
77
+ // Match matches entry input
73
78
func (f * EqualityFilter ) Match (input Input ) bool {
74
79
if values , ok := input [f .Key ]; ok {
75
80
for _ , value := range values {
@@ -81,4 +86,6 @@ func (f *EqualityFilter) Match(input Input) bool {
81
86
return false
82
87
}
83
88
89
+ // Append does not appand anything here,
90
+ // because EqualityFilter is already a leaf
84
91
func (f * EqualityFilter ) Append (filter Filter ) {}
0 commit comments