predicate

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Code generated by mkunion. DO NOT EDIT.

Code generated by mkunion. DO NOT EDIT.

Code generated by mkunion. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AndToJSON added in v1.21.0

func AndToJSON(x *And) ([]byte, error)

func BindValueToJSON added in v1.21.0

func BindValueToJSON(x *BindValue) ([]byte, error)

func BindableToJSON added in v1.21.0

func BindableToJSON(x Bindable) ([]byte, error)

func CompareToJSON added in v1.21.0

func CompareToJSON(x *Compare) ([]byte, error)

func Evaluate

func Evaluate[A any](predicate Predicate, data A, bind ParamBinds) bool

func EvaluateEqual

func EvaluateEqual[A any](data A, location string, value any) bool

func EvaluateEqualPrimitive added in v1.21.0

func EvaluateEqualPrimitive(record schema.Schema, location string, value any) bool

func EvaluateSchema added in v1.21.0

func EvaluateSchema(predicate Predicate, data schema.Schema, bind ParamBinds) bool

func EvaluateShape added in v1.21.0

func EvaluateShape(predicate Predicate, s shape.Shape, data schema.Schema, bind ParamBinds) bool

func GetValue

func GetValue(x Bindable, params ParamBinds, data schema.Schema) (schema.Schema, bool)

func LiteralToJSON added in v1.21.0

func LiteralToJSON(x *Literal) ([]byte, error)

func LocatableToJSON added in v1.21.0

func LocatableToJSON(x *Locatable) ([]byte, error)

func MatchBindableR0 added in v1.22.0

func MatchBindableR0(
	x Bindable,
	f1 func(x *BindValue),
	f2 func(x *Literal),
	f3 func(x *Locatable),
)

func MatchBindableR1 added in v1.22.0

func MatchBindableR1[T0 any](
	x Bindable,
	f1 func(x *BindValue) T0,
	f2 func(x *Literal) T0,
	f3 func(x *Locatable) T0,
) T0

func MatchBindableR2 added in v1.21.0

func MatchBindableR2[T0, T1 any](
	x Bindable,
	f1 func(x *BindValue) (T0, T1),
	f2 func(x *Literal) (T0, T1),
	f3 func(x *Locatable) (T0, T1),
) (T0, T1)

func MatchBindableR3 added in v1.22.0

func MatchBindableR3[T0, T1, T2 any](
	x Bindable,
	f1 func(x *BindValue) (T0, T1, T2),
	f2 func(x *Literal) (T0, T1, T2),
	f3 func(x *Locatable) (T0, T1, T2),
) (T0, T1, T2)

func MatchPredicateR0 added in v1.22.0

func MatchPredicateR0(
	x Predicate,
	f1 func(x *And),
	f2 func(x *Or),
	f3 func(x *Not),
	f4 func(x *Compare),
)

func MatchPredicateR1 added in v1.22.0

func MatchPredicateR1[T0 any](
	x Predicate,
	f1 func(x *And) T0,
	f2 func(x *Or) T0,
	f3 func(x *Not) T0,
	f4 func(x *Compare) T0,
) T0

func MatchPredicateR2 added in v1.21.0

func MatchPredicateR2[T0, T1 any](
	x Predicate,
	f1 func(x *And) (T0, T1),
	f2 func(x *Or) (T0, T1),
	f3 func(x *Not) (T0, T1),
	f4 func(x *Compare) (T0, T1),
) (T0, T1)

func MatchPredicateR3 added in v1.22.0

func MatchPredicateR3[T0, T1, T2 any](
	x Predicate,
	f1 func(x *And) (T0, T1, T2),
	f2 func(x *Or) (T0, T1, T2),
	f3 func(x *Not) (T0, T1, T2),
	f4 func(x *Compare) (T0, T1, T2),
) (T0, T1, T2)

func NotToJSON added in v1.21.0

func NotToJSON(x *Not) ([]byte, error)

func OrToJSON added in v1.21.0

func OrToJSON(x *Or) ([]byte, error)

func PredicateToJSON added in v1.21.0

func PredicateToJSON(x Predicate) ([]byte, error)

Types

type And

type And struct {
	L []Predicate
}

func AndFromJSON added in v1.21.0

func AndFromJSON(x []byte) (*And, error)

func (*And) AcceptPredicate added in v1.21.0

func (r *And) AcceptPredicate(v PredicateVisitor) any

func (*And) MarshalJSON added in v1.21.0

func (r *And) MarshalJSON() ([]byte, error)

func (*And) UnmarshalJSON added in v1.21.0

func (r *And) UnmarshalJSON(data []byte) error

type BindName

type BindName = string

type BindValue

type BindValue struct{ BindName BindName }

func BindValueFromJSON added in v1.21.0

func BindValueFromJSON(x []byte) (*BindValue, error)

func (*BindValue) AcceptBindable added in v1.21.0

func (r *BindValue) AcceptBindable(v BindableVisitor) any

func (*BindValue) MarshalJSON added in v1.21.0

func (r *BindValue) MarshalJSON() ([]byte, error)

func (*BindValue) UnmarshalJSON added in v1.21.0

func (r *BindValue) UnmarshalJSON(data []byte) error

type Bindable added in v1.21.0

type Bindable interface {
	AcceptBindable(g BindableVisitor) any
}

func BindableFromJSON added in v1.21.0

func BindableFromJSON(x []byte) (Bindable, error)

type BindableUnionJSON added in v1.21.0

type BindableUnionJSON struct {
	Type      string          `json:"$type,omitempty"`
	BindValue json.RawMessage `json:"predicate.BindValue,omitempty"`
	Literal   json.RawMessage `json:"predicate.Literal,omitempty"`
	Locatable json.RawMessage `json:"predicate.Locatable,omitempty"`
}

type BindableVisitor added in v1.21.0

type BindableVisitor interface {
	VisitBindValue(v *BindValue) any
	VisitLiteral(v *Literal) any
	VisitLocatable(v *Locatable) any
}

type Comparable

type Comparable struct {
	Location string `( @Location`
	Operator string `  @Operator`
	BindName Value  `  @@)`
}

func (Comparable) ToPredicate

func (a Comparable) ToPredicate() (Predicate, error)

type Compare

type Compare struct {
	Location  string
	Operation string
	BindValue Bindable
}

func CompareFromJSON added in v1.21.0

func CompareFromJSON(x []byte) (*Compare, error)

func (*Compare) AcceptPredicate added in v1.21.0

func (r *Compare) AcceptPredicate(v PredicateVisitor) any

func (*Compare) MarshalJSON added in v1.21.0

func (r *Compare) MarshalJSON() ([]byte, error)

func (*Compare) UnmarshalJSON added in v1.21.0

func (r *Compare) UnmarshalJSON(data []byte) error

type Condition

type Condition struct {
	Operand *Comparable `  @@`
	Not     *Condition  `| "NOT" @@`
}

func (*Condition) ToPredicate

func (c *Condition) ToPredicate() (Predicate, error)

type Expression

type Expression struct {
	Or []*OrCondition `@@ ( "OR" @@ )*`
}

func (Expression) ToPredicate

func (e Expression) ToPredicate() (Predicate, error)

type Literal

type Literal struct{ Value schema.Schema }

func LiteralFromJSON added in v1.21.0

func LiteralFromJSON(x []byte) (*Literal, error)

func (*Literal) AcceptBindable added in v1.21.0

func (r *Literal) AcceptBindable(v BindableVisitor) any

func (*Literal) MarshalJSON added in v1.21.0

func (r *Literal) MarshalJSON() ([]byte, error)

func (*Literal) UnmarshalJSON added in v1.21.0

func (r *Literal) UnmarshalJSON(data []byte) error

type Locatable

type Locatable struct{ Location string }

func LocatableFromJSON added in v1.21.0

func LocatableFromJSON(x []byte) (*Locatable, error)

func (*Locatable) AcceptBindable added in v1.21.0

func (r *Locatable) AcceptBindable(v BindableVisitor) any

func (*Locatable) MarshalJSON added in v1.21.0

func (r *Locatable) MarshalJSON() ([]byte, error)

func (*Locatable) UnmarshalJSON added in v1.21.0

func (r *Locatable) UnmarshalJSON(data []byte) error

type Not

type Not struct {
	P Predicate
}

func NotFromJSON added in v1.21.0

func NotFromJSON(x []byte) (*Not, error)

func (*Not) AcceptPredicate added in v1.21.0

func (r *Not) AcceptPredicate(v PredicateVisitor) any

func (*Not) MarshalJSON added in v1.21.0

func (r *Not) MarshalJSON() ([]byte, error)

func (*Not) UnmarshalJSON added in v1.21.0

func (r *Not) UnmarshalJSON(data []byte) error

type Or

type Or struct {
	L []Predicate
}

func OrFromJSON added in v1.21.0

func OrFromJSON(x []byte) (*Or, error)

func (*Or) AcceptPredicate added in v1.21.0

func (r *Or) AcceptPredicate(v PredicateVisitor) any

func (*Or) MarshalJSON added in v1.21.0

func (r *Or) MarshalJSON() ([]byte, error)

func (*Or) UnmarshalJSON added in v1.21.0

func (r *Or) UnmarshalJSON(data []byte) error

type OrCondition

type OrCondition struct {
	And []*Condition `@@ ( "AND" @@ )*`
}

func (*OrCondition) ToPredicate

func (c *OrCondition) ToPredicate() (Predicate, error)

type ParamBinds

type ParamBinds map[BindName]schema.Schema

func (*ParamBinds) MarshalJSON added in v1.20.2

func (r *ParamBinds) MarshalJSON() ([]byte, error)

func (*ParamBinds) UnmarshalJSON added in v1.20.2

func (r *ParamBinds) UnmarshalJSON(data []byte) error

type Predicate added in v1.21.0

type Predicate interface {
	AcceptPredicate(g PredicateVisitor) any
}

func Optimize added in v1.21.0

func Optimize(p Predicate) Predicate

func Parse added in v1.21.0

func Parse(input string) (Predicate, error)

func PredicateFromJSON added in v1.21.0

func PredicateFromJSON(x []byte) (Predicate, error)

type PredicateUnionJSON added in v1.21.0

type PredicateUnionJSON struct {
	Type    string          `json:"$type,omitempty"`
	And     json.RawMessage `json:"predicate.And,omitempty"`
	Or      json.RawMessage `json:"predicate.Or,omitempty"`
	Not     json.RawMessage `json:"predicate.Not,omitempty"`
	Compare json.RawMessage `json:"predicate.Compare,omitempty"`
}

type PredicateVisitor added in v1.21.0

type PredicateVisitor interface {
	VisitAnd(v *And) any
	VisitOr(v *Or) any
	VisitNot(v *Not) any
	VisitCompare(v *Compare) any
}

type Value

type Value struct {
	BindName *string  `(  @Bind`
	Number   *float64 `| @Number`
	String   *string  `| @String`
	Bool     *string  `| @("TRUE" | "FALSE" | "true" | "false") `
	Location *string  `| @Location )`
}

func (Value) ToBindable

func (v Value) ToBindable() Bindable

type WherePredicates

type WherePredicates struct {
	Predicate Predicate
	Params    ParamBinds
}

func MustWhere

func MustWhere(query string, params ParamBinds) *WherePredicates

func Where

func Where(query string, params ParamBinds) (*WherePredicates, error)

func (*WherePredicates) Evaluate

func (w *WherePredicates) Evaluate(data schema.Schema) bool

func (*WherePredicates) MarshalJSON added in v1.20.2

func (r *WherePredicates) MarshalJSON() ([]byte, error)

func (*WherePredicates) UnmarshalJSON added in v1.20.2

func (r *WherePredicates) UnmarshalJSON(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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