github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/predicate/where/api.go (about) 1 // Package where provides short predicate constructors 2 package where 3 4 import ( 5 "github.com/m4gshm/gollections/predicate" 6 "github.com/m4gshm/gollections/predicate/eq" 7 ) 8 9 // Match - where.Match alias for the predicate.Match 10 func Match[From, To any](getter func(From) To, condition predicate.Predicate[To]) predicate.Predicate[From] { 11 return predicate.Match(getter, condition) 12 } 13 14 // Any - where.Any alias for the predicate.MatchAny 15 func Any[From, To any](getter func(From) []To, condition predicate.Predicate[To]) predicate.Predicate[From] { 16 return predicate.MatchAny(getter, condition) 17 } 18 19 // Eq creates predicate thet checks equality of a strcut property value to the specified example 20 func Eq[From any, To comparable](getter func(From) To, example To) predicate.Predicate[From] { 21 return Match(getter, eq.To(example)) 22 } 23 24 // Not creates negate condition for a a strcut property 25 func Not[From, To any](getter func(From) To, condition predicate.Predicate[To]) predicate.Predicate[From] { 26 return predicate.Not(Match(getter, condition)) 27 }