gs_cond

package
v1.2.0-rc Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package gs_cond provides a set of conditions that can be used for evaluating and combining logical conditions in a flexible way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And(conditions ...gs.Condition) gs.Condition

And combines multiple conditions with an AND operator, returning true if all conditions are satisfied.

func EvalExpr

func EvalExpr(input string, val interface{}) (bool, error)

EvalExpr evaluates a boolean expression (input) using the provided value (val) and any registered express functions. The string expression to evaluate (should return a boolean value). The value used in the evaluation (referred to as `$` in the expression context).

func FormatGroup

func FormatGroup(op string, conditions []gs.Condition) string

FormatGroup generates a formatted string for a group of conditions (AND, OR, NONE).

func None

func None(conditions ...gs.Condition) gs.Condition

None combines multiple conditions with a NONE operator, returning true if none of the conditions are satisfied.

func Not

func Not(c gs.Condition) gs.Condition

Not creates a condition that inverts the result of the provided condition.

func OnBean

OnBean creates a condition that evaluates to true if at least one bean matches the provided selector.

func OnExpression

func OnExpression(expression string) gs.Condition

OnExpression creates a condition that evaluates based on a custom string expression. The expression is expected to return true or false.

func OnFunc

func OnFunc(fn gs.CondFunc) gs.Condition

OnFunc creates a Conditional that evaluates using a custom function.

func OnMissingBean

func OnMissingBean(s gs.BeanSelectorInterface) gs.Condition

OnMissingBean creates a condition that evaluates to true if no beans match the provided selector.

func OnMissingProperty

func OnMissingProperty(name string) gs.Condition

OnMissingProperty creates a condition that matches if the specified property is missing.

func OnSingleBean

func OnSingleBean(s gs.BeanSelectorInterface) gs.Condition

OnSingleBean creates a condition that evaluates to true if exactly one bean matches the provided selector.

func Or

func Or(conditions ...gs.Condition) gs.Condition

Or combines multiple conditions with an OR operator, returning true if at least one condition is satisfied.

func RegisterExpressFunc

func RegisterExpressFunc(name string, fn interface{})

RegisterExpressFunc registers an express function with a specified name. The function can later be used in expressions evaluated by EvalExpr.

Types

type OnPropertyInterface

type OnPropertyInterface interface {
	gs.Condition
	MatchIfMissing() OnPropertyInterface
	HavingValue(s string) OnPropertyInterface
}

OnPropertyInterface defines the methods for evaluating a condition based on a property. This interface provides flexibility for matching missing properties and checking their values.

func OnProperty

func OnProperty(name string) OnPropertyInterface

OnProperty creates a condition based on the presence and value of a specified property.

Jump to

Keyboard shortcuts

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