filter

package
v0.3.17 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpEquals             = Operation("OpEquals")
	OpEqualsIgnoreCase   = Operation("OpEqualsIgnoreCase")
	OpNotEqual           = Operation("OpNotEqual")
	OpEqualIgnoreCase    = Operation("OpEqualIgnoreCase")
	OpContains           = Operation("OpContains")
	OpContainsIgnoreCase = Operation("OpContainsIgnoreCase")
	OpLowerThan          = Operation("OpLowerThan")
	OpGreaterThan        = Operation("OpGreaterThan")
	OpLowerOrEqualThan   = Operation("OpLowerOrEqualThan")
	OpGreaterOrEqualThan = Operation("OpGreaterOrEqualThan")
	OpMatchesRegex       = Operation("OpMatchesRegex")
	OpBetween            = Operation("OpBetween")
	OpBetweenInclusive   = Operation("OpBetweenInclusive")
)

Variables

This section is empty.

Functions

func Between

func Between(key string, expression, expression2 string) *between

func BetweenInclusive

func BetweenInclusive(key string, expression, expression2 string) *betweenInclusive

func Contains

func Contains(key string, expression string) *contains

func ContainsIgnoreCase

func ContainsIgnoreCase(key string, expression string) *containsIgnoreCase

func EqualIgnoreCase

func EqualIgnoreCase(key string, expression string) *equalsIgnoreCase

func Equals

func Equals(key string, expression string) *equals

func GreaterOrEqualThan

func GreaterOrEqualThan(key string, expression string) *greaterOrEqualThan

func GreaterThan

func GreaterThan(key string, expression string) *greaterThan

func LowerOrEqualThan

func LowerOrEqualThan(key string, expression string) *lowerOrEqualThan

func LowerThan

func LowerThan(key string, expression string) *lowerThan

func MatchesRegex

func MatchesRegex(key string, expression string) *matchRegex

func NotEquals

func NotEquals(key string, expression string) *notEquals

Types

type Condition

type Condition struct {
	Operand  string `@Ident`
	Operator string `@( "<>" | "<=" | ">=" | "=" | "==" | "<" | ">" | "!=" | "BETWEEN" | "CONTAINS" | "CONTAINSIC" | "MATCH" )`
	Value    *Value `@@`
	Value2   *Value `( "AND" @@ )*`
}

func (*Condition) Apply

func (c *Condition) Apply(row map[string]interface{}, key map[string]*config.Key) (bool, error)

type ConditionElement

type ConditionElement struct {
	Condition     *Condition   ` @@`
	GlobalToken   *GlobalToken `| @@ `
	Subexpression *Expression  `| "(" @@ ")"`
}

func (*ConditionElement) Apply

func (c *ConditionElement) Apply(row map[string]interface{}, key map[string]*config.Key) (bool, error)

type Expression

type Expression struct {
	Left  *Term     `@@`
	Right []*OpTerm `@@*`
}

func ParseFilterExpression

func ParseFilterExpression(exp string) (*Expression, error)

func (*Expression) Apply

func (c *Expression) Apply(row map[string]interface{}, key map[string]*config.Key) (bool, error)

type Filter

type Filter interface {
	Apply(value string, key map[string]*config.Key) (bool, error)
	Expression() []string
	Name() string
}

type GlobalToken added in v0.2.12

type GlobalToken struct {
	String *string `@String`
}

func (*GlobalToken) Apply added in v0.2.12

func (g *GlobalToken) Apply(row map[string]interface{}) (bool, error)

type LogicalOperator

type LogicalOperator int
const (
	And LogicalOperator = iota
	Or
)

func (LogicalOperator) Apply

func (c LogicalOperator) Apply(l, r bool) bool

func (*LogicalOperator) Capture

func (o *LogicalOperator) Capture(s []string) error

type OpTerm

type OpTerm struct {
	Operator LogicalOperator `@("OR")`
	Term     *Term           `@@`
}

type OpValue

type OpValue struct {
	Operator         LogicalOperator   `@("AND")`
	ConditionElement *ConditionElement `@@`
}

type Operation

type Operation string

type Predicate

type Predicate struct {
	KeyName       string    `json:"key" yaml:"key"`
	KeyExpression []string  `json:"expression" yaml:"expression"`
	Operation     Operation `json:"operation" yaml:"operation"`
	Right         []Filter  `json:"right,omitempty" yaml:"right"`
}

func (*Predicate) Apply

func (p *Predicate) Apply(value string, key map[string]*config.Key) (bool, error)

func (*Predicate) Expression

func (p *Predicate) Expression() []string

func (*Predicate) Name

func (p *Predicate) Name() string

type Term

type Term struct {
	Left  *ConditionElement `@@`
	Right []*OpValue        `@@*`
}

func (*Term) Apply

func (c *Term) Apply(row map[string]interface{}, key map[string]*config.Key) (bool, error)

type Value

type Value struct {
	Number *float64 `( @Number`
	String *string  ` | @String )`
}

func (*Value) ToString

func (v *Value) ToString() string

Jump to

Keyboard shortcuts

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