filters

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2024 License: UPL-1.0 Imports: 2 Imported by: 0

Documentation

Overview

Package filters provides various filter functions and types.

Index

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 All

func All(filters ...Filter) Filter

All returns a Filter that is the logical "and" of all the specified filters.

func Always

func Always() Filter

Always returns a Filter that always evaluates to true.

func And

func And(left Filter, right Filter) Filter

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

func Any(filters ...Filter) Filter

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 Never

func Never() Filter

Never creates a Filter always evaluates to false.

func Not

func Not(filter Filter) Filter

Not returns a filter that negates the results of the passed filter.

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 Or

func Or(left Filter, right Filter) Filter

Or creates a Filter evaluates the logical 'and' of the the two filters.

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.

func Xor

func Xor(left Filter, right Filter) Filter

Xor creates a Filter evaluates the logical 'xor' of the two filters.

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

func (sf MapEventFilter) And(other Filter) Filter

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

func (sf MapEventFilter) AssociatedWith(key any) Filter

AssociatedWith returns a key associated filter based on this filter and a specified key.

func (MapEventFilter) Or

func (sf MapEventFilter) Or(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.

func (MapEventFilter) String

func (mef MapEventFilter) String() string

func (MapEventFilter) Xor

func (sf MapEventFilter) Xor(other Filter) Filter

Xor returns a composed predicate that represents a logical XOR of this predicate and the other predicate.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL