cond

package
v0.1.52 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cond

type Cond[R any] interface {
	Eval(r R) bool
}

Cond is the interface used to simplify Query.Filter usage

func And

func And[R any](evalList ...Cond[R]) Cond[R]

And returns an Cond that returns true if all the Cond return true

func Eq

func Eq[R any, V any](valueGetter RecordValueGetter[R, V], otherValue V) Cond[R]

Eq returns an Cond that returns true if the record value is equal to the given value

func Func

func Func[R any](f func(r R) bool) Cond[R]

Func is the function template to be used for condition function

func Gt

func Gt[R any, V constraints.Ordered](valueGetter RecordValueGetter[R, V], otherValue V) Cond[R]

Gt returns an Cond that returns true if the record value is greater than the given value

func Gte

func Gte[R any, V constraints.Ordered](valueGetter RecordValueGetter[R, V], otherValue V) Cond[R]

Gte returns an Cond that returns true if the record value is greater than or equal to the given value

func Lt

func Lt[R any, V constraints.Ordered](valueGetter RecordValueGetter[R, V], otherValue V) Cond[R]

Lt returns an Cond that returns true if the record value is less than the given value

func Lte

func Lte[R any, V constraints.Ordered](valueGetter RecordValueGetter[R, V], otherValue V) Cond[R]

Lte returns an Cond that returns true if the record value is less than or equal to the given value

func Not

func Not[R any](eval Cond[R]) Cond[R]

Not returns an Cond that returns true if the Cond returns false

func Or

func Or[R any](evalList ...Cond[R]) Cond[R]

Or returns an Cond that returns true if any of the Cond return true

type CondFunc

type CondFunc[R any] func(r R) bool

CondFunc is the function type used to implement Cond interface

func (CondFunc[R]) Eval

func (e CondFunc[R]) Eval(r R) bool

Eval implements Cond interface.

type RecordValueGetter

type RecordValueGetter[R any, V any] func(r R) V

RecordValueGetter is the function type used to getting a value from a record

Jump to

Keyboard shortcuts

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