predicates

package
v1.26.2-121.4 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyPredicateProtoSize = (&persistencespb.Predicate{
	PredicateType: enums.PREDICATE_TYPE_EMPTY,
	Attributes: &persistencespb.Predicate_EmptyPredicateAttributes{
		EmptyPredicateAttributes: &persistencespb.EmptyPredicateAttributes{},
	},
}).Size()

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]) Size added in v1.26.0

func (a *AndImpl[T]) Size() int

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]) Size added in v1.26.0

func (*EmptyImpl[T]) Size() int

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]) Size added in v1.26.0

func (n *NotImpl[T]) Size() int

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]) Size added in v1.26.0

func (o *OrImpl[T]) Size() int

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

	// Size gets the estimated size in bytes of this predicate.
	// Implementation may keep this estimate rough and mostly account for elements that may take up considerable
	// space such as strings and slices.
	Size() int
}

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]) Size added in v1.26.0

func (*UniversalImpl[T]) Size() int

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