predicates

package
v1.25.0-116.3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AndImpl

type AndImpl[T any] struct {
	// TODO: see if we can somehow order arbitrary predicats and store a sorted list
	Predicates []Predicate[T]
}

func (*AndImpl[T]) Equals

func (a *AndImpl[T]) Equals(
	predicate Predicate[T],
) bool

func (*AndImpl[T]) Test

func (a *AndImpl[T]) Test(t T) bool

type EmptyImpl

type EmptyImpl[T any] struct{}

func (*EmptyImpl[T]) Equals

func (n *EmptyImpl[T]) Equals(
	predicate Predicate[T],
) bool

func (*EmptyImpl[T]) Test

func (n *EmptyImpl[T]) Test(t T) bool

type NotImpl

type NotImpl[T any] struct {
	Predicate Predicate[T]
}

func (*NotImpl[T]) Equals

func (n *NotImpl[T]) Equals(
	predicate Predicate[T],
) bool

func (*NotImpl[T]) Test

func (n *NotImpl[T]) Test(t T) bool

type OrImpl

type OrImpl[T any] struct {
	// TODO: see if we can somehow order arbitrary predicats and store a sorted list
	Predicates []Predicate[T]
}

func (*OrImpl[T]) Equals

func (o *OrImpl[T]) Equals(
	predicate Predicate[T],
) bool

func (*OrImpl[T]) Test

func (o *OrImpl[T]) Test(t T) bool

type Predicate

type Predicate[T any] interface {
	// Test checks if the given entity statisfy the predicate or not
	Test(T) bool

	// Equals recursively checks if the given Predicate has the same
	// structure and value as the caller Predicate
	// NOTE: the result will contain false negatives, meaning even if
	// two predicates are mathmatically equivalent, Equals may still
	// return false.
	Equals(Predicate[T]) bool
}

func And

func And[T any](
	predicates ...Predicate[T],
) Predicate[T]

func Empty

func Empty[T any]() Predicate[T]

func Not

func Not[T any](
	predicate Predicate[T],
) Predicate[T]

func Or

func Or[T any](
	predicates ...Predicate[T],
) Predicate[T]

func Universal added in v1.17.3

func Universal[T any]() Predicate[T]

type UniversalImpl added in v1.17.3

type UniversalImpl[T any] struct{}

func (*UniversalImpl[T]) Equals added in v1.17.3

func (a *UniversalImpl[T]) Equals(
	predicate Predicate[T],
) bool

func (*UniversalImpl[T]) Test added in v1.17.3

func (a *UniversalImpl[T]) Test(t T) bool

Jump to

Keyboard shortcuts

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