Documentation
¶
Index ¶
- Constants
- func MarshalExpr(e Expr) ([]byte, error)
- type ComparisonExpr
- type ComparisonExprRaw
- type ConstantExpr
- type EvalResult
- func (e *EvalResult) And(other *EvalResult) (*EvalResult, error)
- func (e *EvalResult) Equal(other *EvalResult) (*EvalResult, error)
- func (e *EvalResult) GetBool() (bool, error)
- func (e *EvalResult) GetFloat64() (float64, error)
- func (e *EvalResult) GreaterOrEqual(other *EvalResult) (*EvalResult, error)
- func (e *EvalResult) GreaterThan(other *EvalResult) (*EvalResult, error)
- func (e *EvalResult) LessOrEqual(other *EvalResult) (*EvalResult, error)
- func (e *EvalResult) LessThan(other *EvalResult) (*EvalResult, error)
- func (e *EvalResult) Not() (*EvalResult, error)
- func (e *EvalResult) NotEqual(other *EvalResult) (*EvalResult, error)
- func (e *EvalResult) Or(other *EvalResult) (*EvalResult, error)
- type Expr
- type ExprComparisonOperator
- type ExprLogicalOperator
- type ExprType
- type ExprValueSelector
- type ExprValueType
- type LogicalExpr
- type LogicalExprRaw
- type NotExpr
- type NotExprRaw
- type VariantExpr
Constants ¶
View Source
const ( GreaterThan ExprComparisonOperator = "gt" GreaterOrEqual ExprComparisonOperator = "gte" LessThan ExprComparisonOperator = "lt" LessOrEqual ExprComparisonOperator = "lte" Equal ExprComparisonOperator = "eq" NotEqual ExprComparisonOperator = "neq" And ExprLogicalOperator = "and" Or ExprLogicalOperator = "or" Not ExprLogicalOperator = "not" Number ExprValueType = "number" String ExprValueType = "string" Boolean ExprValueType = "boolean" ConstantExprType ExprType = "const" VariantExprType ExprType = "var" ComparisonExprType ExprType = "comparison" LogicalExprType ExprType = "logical" NotExprType ExprType = "not" )
Variables ¶
This section is empty.
Functions ¶
func MarshalExpr ¶
Types ¶
type ComparisonExpr ¶
type ComparisonExpr struct {
Type ExprType `json:"type"` // compare
Operator ExprComparisonOperator `json:"operator"`
Left Expr `json:"left"`
Right Expr `json:"right"`
}
func (ComparisonExpr) Eval ¶
func (c ComparisonExpr) Eval(variables map[string]map[string]any) (*EvalResult, error)
func (ComparisonExpr) GetType ¶
func (c ComparisonExpr) GetType() ExprType
type ComparisonExprRaw ¶
type ComparisonExprRaw struct {
Type ExprType `json:"type"`
Operator ExprComparisonOperator `json:"operator"`
Left json.RawMessage `json:"left"`
Right json.RawMessage `json:"right"`
}
func (ComparisonExprRaw) ToComparisonExpr ¶
func (r ComparisonExprRaw) ToComparisonExpr() (ComparisonExpr, error)
type ConstantExpr ¶
type ConstantExpr struct {
Type ExprType `json:"type"`
Value string `json:"value"`
ValueType ExprValueType `json:"valueType"`
}
func (ConstantExpr) Eval ¶
func (c ConstantExpr) Eval(variables map[string]map[string]any) (*EvalResult, error)
func (ConstantExpr) GetType ¶
func (c ConstantExpr) GetType() ExprType
type EvalResult ¶
type EvalResult struct {
Type ExprValueType
Value any
}
func (*EvalResult) And ¶
func (e *EvalResult) And(other *EvalResult) (*EvalResult, error)
func (*EvalResult) Equal ¶
func (e *EvalResult) Equal(other *EvalResult) (*EvalResult, error)
func (*EvalResult) GetBool ¶
func (e *EvalResult) GetBool() (bool, error)
func (*EvalResult) GetFloat64 ¶
func (e *EvalResult) GetFloat64() (float64, error)
func (*EvalResult) GreaterOrEqual ¶
func (e *EvalResult) GreaterOrEqual(other *EvalResult) (*EvalResult, error)
func (*EvalResult) GreaterThan ¶
func (e *EvalResult) GreaterThan(other *EvalResult) (*EvalResult, error)
func (*EvalResult) LessOrEqual ¶
func (e *EvalResult) LessOrEqual(other *EvalResult) (*EvalResult, error)
func (*EvalResult) LessThan ¶
func (e *EvalResult) LessThan(other *EvalResult) (*EvalResult, error)
func (*EvalResult) Not ¶
func (e *EvalResult) Not() (*EvalResult, error)
func (*EvalResult) NotEqual ¶
func (e *EvalResult) NotEqual(other *EvalResult) (*EvalResult, error)
func (*EvalResult) Or ¶
func (e *EvalResult) Or(other *EvalResult) (*EvalResult, error)
type Expr ¶
type Expr interface {
GetType() ExprType
Eval(variables map[string]map[string]any) (*EvalResult, error)
}
func UnmarshalExpr ¶
type ExprComparisonOperator ¶
type ExprComparisonOperator string
type ExprLogicalOperator ¶
type ExprLogicalOperator string
type ExprValueSelector ¶
type ExprValueSelector struct {
Id string `json:"id"`
Name string `json:"name"`
Type ExprValueType `json:"type"`
}
type ExprValueType ¶
type ExprValueType string
type LogicalExpr ¶
type LogicalExpr struct {
Type ExprType `json:"type"` // logical
Operator ExprLogicalOperator `json:"operator"`
Left Expr `json:"left"`
Right Expr `json:"right"`
}
func (LogicalExpr) Eval ¶
func (l LogicalExpr) Eval(variables map[string]map[string]any) (*EvalResult, error)
func (LogicalExpr) GetType ¶
func (l LogicalExpr) GetType() ExprType
type LogicalExprRaw ¶
type LogicalExprRaw struct {
Type ExprType `json:"type"`
Operator ExprLogicalOperator `json:"operator"`
Left json.RawMessage `json:"left"`
Right json.RawMessage `json:"right"`
}
func (LogicalExprRaw) ToLogicalExpr ¶
func (r LogicalExprRaw) ToLogicalExpr() (LogicalExpr, error)
type NotExprRaw ¶
type NotExprRaw struct {
Type ExprType `json:"type"`
Expr json.RawMessage `json:"expr"`
}
func (NotExprRaw) ToNotExpr ¶
func (r NotExprRaw) ToNotExpr() (NotExpr, error)
type VariantExpr ¶
type VariantExpr struct {
Type ExprType `json:"type"`
Selector ExprValueSelector `json:"selector"`
}
func (VariantExpr) Eval ¶
func (v VariantExpr) Eval(variables map[string]map[string]any) (*EvalResult, error)
func (VariantExpr) GetType ¶
func (v VariantExpr) GetType() ExprType
Click to show internal directories.
Click to hide internal directories.