Documentation ¶
Overview ¶
Package filters provides various filter functions and types.
Index ¶
- type Filter
- func All(filters ...Filter) Filter
- func Always() Filter
- func And(left Filter, right Filter) Filter
- func Any(filters ...Filter) Filter
- func Between[V comparable](extractor extractors.ValueExtractor[any, V], from, to V) Filter
- func Contains[V any](extractor extractors.ValueExtractor[any, V], value V) Filter
- func ContainsAll[V any](extractor extractors.ValueExtractor[any, V], values ...V) Filter
- func ContainsAny[V any](extractor extractors.ValueExtractor[any, V], values ...V) Filter
- func Equal[V any](extractor extractors.ValueExtractor[any, V], value V) Filter
- func Greater[V any](extractor extractors.ValueExtractor[any, V], value V) Filter
- func GreaterEqual[V any](extractor extractors.ValueExtractor[any, V], value V) Filter
- func In[V any](extractor extractors.ValueExtractor[any, V], values []V) Filter
- func IsNil[V any](extractor extractors.ValueExtractor[any, V]) Filter
- func IsNotNil[V any](extractor extractors.ValueExtractor[any, V]) Filter
- func Less[V comparable](extractor extractors.ValueExtractor[any, V], value V) Filter
- func LessEqual[V comparable](extractor extractors.ValueExtractor[any, V], value V) Filter
- func Like(extractor extractors.ValueExtractor[any, string], pattern string, ...) Filter
- func Never() Filter
- func Not(filter Filter) Filter
- func NotEqual[V any](extractor extractors.ValueExtractor[any, V], value V) Filter
- func Or(left Filter, right Filter) Filter
- func Present() Filter
- func Regex(extractor extractors.ValueExtractor[any, string], pattern string) Filter
- func Xor(left Filter, right Filter) Filter
- type MapEventFilter
- type MapEventMask
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter interface { // And returns a composed filter that represents a short-circuiting logical // AND of this filter and another. When evaluating the composed // filter, if this filter is false, then the other // filter is not evaluated. // The returned filter can be used for further composition. And(other Filter) Filter // Or returns a composed predicate that represents a short-circuiting logical // OR of this predicate and another. When evaluating the composed // predicate, if this predicate is true, then the other // predicate is not evaluated. // The returned filter can be used for further composition. Or(other Filter) Filter // Xor Returns a composed predicate that represents a logical XOR of this // predicate and another. // The returned filter can be used for further composition. Xor(other Filter) Filter // AssociatedWith returns a key associated filter that limits the scope of this filter to the specified key. // The returned filter can be used for further composition. AssociatedWith(key any) Filter }
Filter interface defines the common operations on all Filters.
func And ¶
And filter evaluates the logical 'and' of the two filters. When evaluating the composed filter, if the 'left' filter is false, then the other filter is not evaluated. The returned filter can be used for further composition.
func Any ¶
Any Filter returns the logical "or" of a filter array. When evaluating the composed filter, if any of the specified filters evaluates to true, then the other filters are not evaluated. The returned filter can be used for further composition.
func Between ¶
func Between[V comparable](extractor extractors.ValueExtractor[any, V], from, to V) Filter
Between creates a filter that checks if the property value lies between 'to' and 'from' which always evaluates to false.
func Contains ¶
func Contains[V any](extractor extractors.ValueExtractor[any, V], value V) Filter
Contains creates a Filter that tests a collection or array value returned from a method invocation based on the given property for containment of a given value.
func ContainsAll ¶
func ContainsAll[V any](extractor extractors.ValueExtractor[any, V], values ...V) Filter
ContainsAll creates a filter that tests a collection or array value returned from a method invocation based on the given property for containment of all the given values.
func ContainsAny ¶
func ContainsAny[V any](extractor extractors.ValueExtractor[any, V], values ...V) Filter
ContainsAny creates a filter that tests a collection or array value returned from a method invocation based on the given property for containment of the given values.
func Equal ¶
func Equal[V any](extractor extractors.ValueExtractor[any, V], value V) Filter
Equal creates a Filter that compares the result of a method invocation with a value for equality.
func Greater ¶
func Greater[V any](extractor extractors.ValueExtractor[any, V], value V) Filter
Greater creates a Filter that checks if the result of a method invocation is greater than the specified value. If either result of a method invocation or a value to compare are equal to nil, the evaluation yields false.
func GreaterEqual ¶
func GreaterEqual[V any](extractor extractors.ValueExtractor[any, V], value V) Filter
GreaterEqual creates a Filter that checks if the result of a method invocation is greater or equal to the specified value. If either result of a method invocation or a value to compare are equal to nil, the evaluation yields false.
func In ¶
func In[V any](extractor extractors.ValueExtractor[any, V], values []V) Filter
In creates a Filter which checks whether the result of a method invocation based on the given property belongs to a predefined set of values.
func IsNil ¶
func IsNil[V any](extractor extractors.ValueExtractor[any, V]) Filter
IsNil creates a Filter which compares the result of a method invocation with nil.
func IsNotNil ¶
func IsNotNil[V any](extractor extractors.ValueExtractor[any, V]) Filter
IsNotNil creates a Filter which tests the result of a method invocation for inequality to nil.
func Less ¶
func Less[V comparable](extractor extractors.ValueExtractor[any, V], value V) Filter
Less creates a Filter compares the result of a method invocation with a value for "Less" condition. In a case when either result of a method invocation or a value to compare are equal to nil, the evaluation yields false.
func LessEqual ¶
func LessEqual[V comparable](extractor extractors.ValueExtractor[any, V], value V) Filter
LessEqual creates a Filter compares the result of a method invocation with a value for "Less or Equals" condition. In a case when either result of a method invocation or a value to compare are equal to nil, the evaluation yields false.
func Like ¶
func Like(extractor extractors.ValueExtractor[any, string], pattern string, ignoreCase bool) Filter
Like creates a filter compares the result of a method invocation based on the provided property with a value for pattern match. A pattern can include regular characters and wildcard characters '_' and '%'.
During pattern matching, regular characters must exactly match the characters in an evaluated string. Wildcard character '_' (underscore) can be matched with any single character, and wildcard character '%' can be matched with any string fragment of zero or more characters.
func NotEqual ¶
func NotEqual[V any](extractor extractors.ValueExtractor[any, V], value V) Filter
NotEqual creates a Filter compares the result of a method invocation with a value for inequality.
func Present ¶
func Present() Filter
Present creates a Filter returns true for entries that currently exist in a NamedMap. This Filter is intended to be used solely in combination with a ConditionalProcessor.
func Regex ¶
func Regex(extractor extractors.ValueExtractor[any, string], pattern string) Filter
Regex creates a Filter that uses the regular expression pattern match defined by the Java's String.matches(String) contract.
type MapEventFilter ¶
type MapEventFilter struct { Mask MapEventMask `json:"mask"` // contains filtered or unexported fields }
func NewEventFilter ¶
func NewEventFilter(mask MapEventMask, filter Filter) *MapEventFilter
func NewEventFilterFromFilter ¶
func NewEventFilterFromFilter(filter Filter) *MapEventFilter
func NewEventFilterFromMask ¶
func NewEventFilterFromMask(mask MapEventMask) *MapEventFilter
func (MapEventFilter) And ¶
And returns a composed filter that represents a short-circuiting logical AND of this filter and another. When evaluating the composed filter, if this filter is false, then the other filter is not evaluated.
func (MapEventFilter) AssociatedWith ¶
AssociatedWith returns a key associated filter based on this filter and a specified key.
func (MapEventFilter) Or ¶
Or returns a composed predicate that represents a short-circuiting logical OR of this predicate and another. When evaluating the composed predicate, if this predicate is true, then the other predicate is not evaluated.
func (MapEventFilter) String ¶
func (mef MapEventFilter) String() string
type MapEventMask ¶
type MapEventMask int
const ( // MaskInserted indicates that insert events should be evaluated. // The event will be fired if there is no filter specified or if the // filter evaluates to true for a new value. MaskInserted MapEventMask = 0x0001 // MaskUpdated indicates that update events should be evaluated. // The event will be fired if there is no filter specified or the // filter evaluates to true when applied to either old or new value. MaskUpdated MapEventMask = 0x0002 // MaskDeleted indicates that delete events should be evaluated. // The event will be fired if there is no filter specified or the // filter evaluates to true for an old value. MaskDeleted MapEventMask = 0x0004 // MaskAll indicates that all events should be evaluated. MaskAll MapEventMask = MaskInserted | MaskUpdated | MaskDeleted )
func (MapEventMask) String ¶
func (m MapEventMask) String() string