Skip to content

Commit 240e975

Browse files
committed
update docs
1 parent f157da3 commit 240e975

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

ldapfilter.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ type Filter interface {
77
Append(filter Filter)
88
}
99

10-
// AND
11-
10+
// AndFilter filters entries by and operation
1211
type AndFilter struct {
1312
Type string
1413
Children []Filter
1514
}
1615

16+
// NewAndFilter inititalizes a new AndFilter
1717
func NewAndFilter() *AndFilter {
1818
return &AndFilter{Type: "and"}
1919
}
2020

21+
// Match matches entry input
2122
func (f *AndFilter) Match(input Input) bool {
2223
for _, filter := range f.Children {
2324
if !filter.Match(input) {
@@ -27,21 +28,23 @@ func (f *AndFilter) Match(input Input) bool {
2728
return true
2829
}
2930

31+
// Append appends a new filter
3032
func (f *AndFilter) Append(filter Filter) {
3133
f.Children = append(f.Children, filter)
3234
}
3335

34-
// OR
35-
36+
// OrFilter filters entries by or operation
3637
type OrFilter struct {
3738
Type string
3839
Children []Filter
3940
}
4041

42+
// NewOrFilter inititalizes a new OrFilter
4143
func NewOrFilter() *OrFilter {
4244
return &OrFilter{Type: "or"}
4345
}
4446

47+
// Match matches entry input
4548
func (f *OrFilter) Match(input Input) bool {
4649
if len(f.Children) == 0 {
4750
return true
@@ -54,22 +57,24 @@ func (f *OrFilter) Match(input Input) bool {
5457
return false
5558
}
5659

60+
// Append appends a new filter
5761
func (f *OrFilter) Append(filter Filter) {
5862
f.Children = append(f.Children, filter)
5963
}
6064

61-
// EQUALITY
62-
65+
// EqualityFilter filters entries by equality
6366
type EqualityFilter struct {
6467
Type string
6568
Key string
6669
Value string
6770
}
6871

72+
// NewEqualityFilter inititalizes a new EqualityFilter
6973
func NewEqualityFilter() *EqualityFilter {
7074
return &EqualityFilter{Type: "equality"}
7175
}
7276

77+
// Match matches entry input
7378
func (f *EqualityFilter) Match(input Input) bool {
7479
if values, ok := input[f.Key]; ok {
7580
for _, value := range values {
@@ -81,4 +86,6 @@ func (f *EqualityFilter) Match(input Input) bool {
8186
return false
8287
}
8388

89+
// Append does not appand anything here,
90+
// because EqualityFilter is already a leaf
8491
func (f *EqualityFilter) Append(filter Filter) {}

0 commit comments

Comments
 (0)