gs_cond

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package gs_cond provides a set of composable conditions used to control bean registration for Go-Spring framework.

It defines various condition types such as:

  • OnFunc: Uses a custom function to evaluate a condition.
  • OnProperty: Matches based on the presence or value of a property.
  • OnBean: Matches if at least one bean exists for a given selector.
  • OnMissingBean: Matches if no beans exist for a given selector.
  • OnSingleBean: Matches if exactly one bean exists for a given selector.
  • OnExpression: Evaluates a custom expression (currently unimplemented).
  • Not / Or / And / None: Logical combinators for composing multiple conditions.

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 using AND logic.

func EvalExpr

func EvalExpr(input string, val string) (bool, error)

EvalExpr evaluates a boolean expression using the provided value as the "$" variable. - `input` is a boolean expression string to evaluate, it must return a boolean result. - `val` is a string value accessible as "$" within the expression context.

func FormatGroup

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

FormatGroup formats a group of conditions (e.g., AND, OR, NONE) as a string for debugging and logging purposes.

func None

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

None combines multiple conditions using NONE logic. Returns true only if all conditions are false.

func Not

func Not(c gs.Condition) gs.Condition

Not creates a condition that returns the negation of another condition.

func OnBean

func OnBean[T any](name ...string) gs.Condition

OnBean creates a condition that evaluates to true if at least one bean matches the specified type and optional name.

func OnBeanSelector

func OnBeanSelector(s gs.BeanSelector) gs.Condition

OnBeanSelector 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 a custom boolean expression.

func OnFunc

func OnFunc(fn func(ctx gs.ConditionContext) (bool, error)) gs.Condition

OnFunc creates a condition that evaluates using the provided custom function.

func OnMissingBean

func OnMissingBean[T any](name ...string) gs.Condition

OnMissingBean creates a condition that evaluates to true if no bean matches the given type and optional name.

func OnMissingBeanSelector

func OnMissingBeanSelector(s gs.BeanSelector) gs.Condition

OnMissingBeanSelector creates a condition that evaluates to true if no bean matches the provided selector.

func OnSingleBean

func OnSingleBean[T any](name ...string) gs.Condition

OnSingleBean creates a condition that evaluates to true if exactly one bean matches the given type and optional name.

func OnSingleBeanSelector

func OnSingleBeanSelector(s gs.BeanSelector) gs.Condition

OnSingleBeanSelector 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 using OR logic.

func RegisterExpressFunc

func RegisterExpressFunc(name string, fn any)

RegisterExpressFunc registers a function under the given name, making it available for use in expressions evaluated by EvalExpr. Functions must be registered before they are referenced in any expression.

Types

type ConditionOnProperty added in v1.2.3

type ConditionOnProperty interface {
	gs.Condition
	MatchIfMissing() ConditionOnProperty      // Match if the property is missing
	HavingValue(s string) ConditionOnProperty // Match if the property has a specific value
}

ConditionOnProperty defines a condition that is evaluated based on the value of a property in the application context. It provides methods to customize behavior for missing properties and specific property values.

func OnProperty

func OnProperty(name string) ConditionOnProperty

OnProperty creates a new condition that checks for the presence and/or value of a specified property.

Jump to

Keyboard shortcuts

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