@@ -147,9 +147,9 @@ func MustPrefixPattern(parts ...interface{}) *SetPattern {
147
147
return result
148
148
}
149
149
150
- // PrefixPattern creates a SetPattern that matches all field paths prefixed by the given list of path parts.
151
- // The parts may be PathPatterns, PathElements, strings (for field names) or ints (for array indices).
152
- // `MatchAnyPathElement()` may be used to "wildcard" match any PathElement at that position in the field path.
150
+ // PrefixPattern creates a SetPattern that matches all field paths prefixed by the given list of pattern path parts.
151
+ // The pattern parts may be PathPatterns, PathElements, strings (for field names) or ints (for array indices).
152
+ // `MatchAnyPathElement()` may be used as a pattern path part to wildcard match a field path part .
153
153
func PrefixPattern (parts ... interface {}) (* SetPattern , error ) {
154
154
current := MatchAnySet () // match all field patch suffixes
155
155
for i := len (parts ) - 1 ; i >= 0 ; i -- {
@@ -190,24 +190,25 @@ func MatchAnySet() *SetPattern {
190
190
// SetPattern defines a pattern that matches fields in a Set.
191
191
// SetPattern is structured much like a Set but with wildcard support.
192
192
type SetPattern struct {
193
- // Wildcard indicates that all members and children are matched .
194
- // If set, the Members and Children fields are ignored.
193
+ // Wildcard indicates that all members and children are included in the match .
194
+ // If set, the Members field is ignored.
195
195
Wildcard bool
196
- // Members provides patterns to match the Members of a Set.
197
- // If any PatchPattern is a wildcard, then all members of a Set are matched.
198
- // Otherwise, if any PathPattern is Equal to a member of a Set, that member is matched.
196
+ // Members provides patterns to match the members of a Set.
199
197
Members []* MemberSetPattern
200
198
}
201
199
202
- // MemberSetPattern defines a pattern that matches the Members of a Set.
203
- // MemberSetPattern is structured much like the elements of a SetNodeMap, but with wildcard support.
200
+ // MemberSetPattern defines a pattern that matches the members of a Set.
201
+ // MemberSetPattern is structured much like the elements of a SetNodeMap, but
202
+ // with wildcard support.
204
203
type MemberSetPattern struct {
205
- // Path provides a pattern to match Members of a Set.
206
- // If Path is a wildcard, all Members of a Set are matched.
207
- // Otherwise, the Member of a Set with a path that is Equal to this Path is matched.
204
+ // Path provides a pattern to match members of a Set.
205
+ // If Path is a wildcard, all members of a Set are included in the match.
206
+ // Otherwise, if any Path is Equal to a member of a Set, that member is
207
+ // included in the match and the children of that member are matched
208
+ // against the Child pattern.
208
209
Path PathPattern
209
210
210
- // Child provides a pattern to use for Member of a Set that were matched by this MemberSetPattern's Path .
211
+ // Child provides a pattern to use for the children of matched members of a Set .
211
212
Child * SetPattern
212
213
}
213
214
@@ -217,11 +218,12 @@ type PathPattern struct {
217
218
// If set, PathElement is ignored.
218
219
Wildcard bool
219
220
220
- // PathElement matches another PathElement if it is Equal to this PathElement.
221
+ // PathElement indicates that a PathElement is matched if it is Equal
222
+ // to this PathElement.
221
223
PathElement
222
224
}
223
225
224
- // FilterByPattern returns a Set with only fields that match the pattern.
226
+ // FilterByPattern returns a Set with only the field paths that match the pattern.
225
227
func (s * Set ) FilterByPattern (pattern * SetPattern ) * Set {
226
228
if pattern .Wildcard {
227
229
return s
@@ -582,7 +584,7 @@ func (s *SetNodeMap) EnsureNamedFieldsAreMembers(sc *schema.Schema, tr schema.Ty
582
584
}
583
585
}
584
586
585
- // FilterByPattern returns a set that is filtered by the pattern.
587
+ // FilterByPattern returns a SetNodeMap with only the field paths that match the pattern.
586
588
func (s * SetNodeMap ) FilterByPattern (pattern * SetPattern ) * SetNodeMap {
587
589
if pattern .Wildcard {
588
590
return s
@@ -637,12 +639,12 @@ func (s *SetNodeMap) Leaves() *SetNodeMap {
637
639
return out
638
640
}
639
641
640
- // Filter defines an interface for filtering Set .
641
- // NewExcludeFilter can be used to create a filter that removes fields at the
642
+ // Filter defines an interface for filtering a set .
643
+ // NewExcludeFilter can be used to create a filter that removes
642
644
// excluded field paths.
643
645
// NewPatternFilter can be used to create a filter that removes all fields except
644
646
// the fields that match a field path pattern. PrefixPattern and MustPrefixPattern
645
- // can help create field path patterns.
647
+ // can be used to define field path patterns.
646
648
type Filter interface {
647
649
// Filter returns a filtered copy of the set.
648
650
Filter (* Set ) * Set
0 commit comments