predicate

package
v1.0.0-preview.3 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And(predicates ...Predicate) *predAnd

And creates a predicate that will perform the logical and operation on the given predicates. If no predicate is provided as argument, the created predicate will always evaluate to true.

func Between

func Between(attribute string, from interface{}, to interface{}) *predBetween

Between creates a predicate that will pass items if the value stored under the given item attribute is contained inside the given range.

The bounds are inclusive.

func Equal

func Equal(attributeName string, value interface{}) *predEqual

Equal creates a predicate that will pass items if the given value and the value stored under the given item attribute are equal.

func False

func False() *predFalse

False creates a predicate that always evaluates to false and passes no items.

func Greater

func Greater(attributeName string, value interface{}) *predGreaterLess

Greater creates a predicate that will pass items if the value stored under the given item attribute is greater than the given value.

func GreaterOrEqual

func GreaterOrEqual(attributeName string, value interface{}) *predGreaterLess

GreaterOrEqual creates a predicate that will pass items if the value stored under the given item attribute is greater than or equal to the given value.

func ILike

func ILike(attributeName string, pattern string) *predILike

ILike creates a predicate that will pass items if the given pattern matches the value stored under the given item attribute in a case-insensitive manner.

The % (percentage sign) is a placeholder for multiplecharacters, the _ (underscore) is a placeholder for a single character. If you need to match the percentage sign or the underscore character itself, escape it with the backslash, for example "\\%" string will match the percentage sign.

func In

func In(attributeName string, values ...interface{}) *predIn

In creates a predicate that will pass items if the value stored under the given item attribute is a member of the given values.

func InstanceOf

func InstanceOf(className string) *predInstanceOf

InstanceOf creates a predicate that will pass entries for which the value class is an instance of the given className.

func Less

func Less(attributeName string, value interface{}) *predGreaterLess

Less creates a predicate that will pass items if the value stored under the given item “attribute“ is less than the given value.

func LessOrEqual

func LessOrEqual(attributeName string, value interface{}) *predGreaterLess

LessOrEqual creates a predicate that will pass items if the value stored under the given item attribute is less than or equal to the given value.

func Like

func Like(attributeName string, expression string) *predLike

Like creates a predicate that will pass items if the given pattern matches the value stored under the given item attribute in a case-sensitive manner.

The % (percentage sign) is a placeholder for multiplecharacters, the _ (underscore) is a placeholder for a single character. If you need to match the percentage sign or the underscore character itself, escape it with the backslash, for example "\\%" string will match the percentage sign.

func Not

func Not(predicate Predicate) *predNot

Not creates a predicate that will negate the result of the given predicate.

func NotEqual

func NotEqual(attributeName string, value interface{}) *predNotEqual

NotEqual creates a predicate that will pass items if the given value and the value stored under the given item attribute are not equal.

func Or

func Or(predicates ...Predicate) *predOr

Or creates a predicate that will perform the logical or operation on the given predicates.

func Regex

func Regex(attributeName string, expression string) *predRegex

Regex creates a predicate that will pass items if the given pattern matches the value stored under the given item attribute.

The pattern interpreted exactly the same as described in https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html.

func SQL

func SQL(expression string) *predSQL

SQL creates a predicate that will pass items that match the given SQL where expression.

The following operators are supported: =, <, >, <=, >=, ==, !=, <>, BETWEEN, IN, LIKE, ILIKE, REGEX, AND, OR, NOT.

The operators are case-insensitive, but attribute names are case sensitive.

Example:

active AND (age > 20 OR salary < 60000)

Differences to standard SQL: * We don't use ternary boolean logic. field=10 evaluates to false, if field is null, in standard SQL it evaluates to UNKNOWN. * IS [NOT] NULL is not supported, use =NULL or <>NULL. * IS [NOT] DISTINCT FROM is not supported, but = and <> behave like it.

func True

func True() *predTrue

True creates a predicate that always evaluates to true and passes all items.

Types

type PagingPredicate

type PagingPredicate interface {
	Predicate
	Reset()
	NextPage()
	PreviousPage()
	Page() int
	SetPage(page int)
	PageSize() int
}

type Predicate

type Predicate interface {
	serialization.IdentifiedDataSerializable
	fmt.Stringer
}

Jump to

Keyboard shortcuts

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