Documentation
¶
Index ¶
- func FilterTypedMapCollection[TItem any, TValue any](items []TItem, getMap func(TItem) *typedmap.ReadonlyTypedMap, ...) []TItem
- type ContainsElementFilter
- type EnabledFilter
- type EqualFilter
- type TypedMapFilter
- func NewContainsElementFilter(key typedmap.TypedKey[[]string], element string, includeUndefined bool) TypedMapFilter[[]string]
- func NewEnabledFilter(key typedmap.TypedKey[bool], includeUndefined bool) TypedMapFilter[bool]
- func NewEqualFilter[T comparable](key typedmap.TypedKey[T], value T, includeUndefined bool) TypedMapFilter[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterTypedMapCollection ¶
func FilterTypedMapCollection[TItem any, TValue any]( items []TItem, getMap func(TItem) *typedmap.ReadonlyTypedMap, filter TypedMapFilter[TValue], ) []TItem
FilterTypedMapCollection filters a collection of items using a type-safe filter TItem: the type of items being filtered TValue: the type of value being filtered on
Types ¶
type ContainsElementFilter ¶
type ContainsElementFilter struct {
// contains filtered or unexported fields
}
ContainsElementFilter checks if a string array contains a specific element
func (*ContainsElementFilter) KeyToFilter ¶
func (f *ContainsElementFilter) KeyToFilter() typedmap.TypedKey[[]string]
KeyToFilter implements TypedMapFilter interface
func (*ContainsElementFilter) ShouldInclude ¶
func (f *ContainsElementFilter) ShouldInclude(found bool, values []string) bool
ShouldInclude implements TypedMapFilter interface
type EnabledFilter ¶
type EnabledFilter struct {
// contains filtered or unexported fields
}
EnabledFilter checks if a boolean value is true
func (*EnabledFilter) KeyToFilter ¶
func (f *EnabledFilter) KeyToFilter() typedmap.TypedKey[bool]
KeyToFilter implements TypedMapFilter interface
func (*EnabledFilter) ShouldInclude ¶
func (f *EnabledFilter) ShouldInclude(found bool, value bool) bool
ShouldInclude implements TypedMapFilter interface
type EqualFilter ¶
type EqualFilter[T comparable] struct { // contains filtered or unexported fields }
EqualFilter matches items with values exactly equal to the specified value
func (*EqualFilter[T]) KeyToFilter ¶
func (f *EqualFilter[T]) KeyToFilter() typedmap.TypedKey[T]
KeyToFilter implements TypedMapFilter interface
func (*EqualFilter[T]) ShouldInclude ¶
func (f *EqualFilter[T]) ShouldInclude(found bool, value T) bool
ShouldInclude implements TypedMapFilter interface
type TypedMapFilter ¶
type TypedMapFilter[T any] interface { // KeyToFilter returns the key to evaluate KeyToFilter() typedmap.TypedKey[T] // ShouldInclude determines if an item should be included in filtered results // found: whether the key exists on the item // value: the value if it exists (zero value if found=false) ShouldInclude(found bool, value T) bool }
TypedMapFilter is an interface for filtering objects that have a TypedMap Type parameter T represents the type of the value to filter on
func NewContainsElementFilter ¶
func NewContainsElementFilter(key typedmap.TypedKey[[]string], element string, includeUndefined bool) TypedMapFilter[[]string]
NewContainsElementFilter creates a filter that checks if an array contains an element
func NewEnabledFilter ¶
NewEnabledFilter creates a filter that checks if a boolean value is true
func NewEqualFilter ¶
func NewEqualFilter[T comparable](key typedmap.TypedKey[T], value T, includeUndefined bool) TypedMapFilter[T]
NewEqualFilter creates a new filter that matches exact values