Documentation
¶
Overview ¶
Package cond 提供了判断 bean 注册是否有效的条件。
Index ¶
- Constants
- func Group(op Operator, cond ...Condition) *group
- func New() *conditional
- func Not(c Condition) *not
- func On(cond Condition) *conditional
- func OnBean(selector bean.Selector) *conditional
- func OnExpression(expression string) *conditional
- func OnMatches(fn Matches) *conditional
- func OnMissingBean(selector bean.Selector) *conditional
- func OnProfile(profile string) *conditional
- func OnProperty(name string, options ...PropertyOption) *conditional
- func OnSingleCandidate(selector bean.Selector) *conditional
- type Condition
- type Context
- type Matches
- type Operator
- type PropertyOption
Constants ¶
View Source
const ( Or = Operator(1) // 条件成立必须至少一个满足。 And = Operator(2) // 条件成立必须所有都要满足。 None = Operator(3) // 条件成立必须没有一个满足。 )
Variables ¶
This section is empty.
Functions ¶
func OnExpression ¶
func OnExpression(expression string) *conditional
OnExpression 返回一个以 onExpression 为开始条件的计算式。
func OnMissingBean ¶
OnMissingBean 返回一个以 onMissingBean 为开始条件的计算式。
func OnProfile ¶
func OnProfile(profile string) *conditional
OnProfile 返回一个以 spring.profile 属性值是否匹配为开始条件的计算式。
func OnProperty ¶
func OnProperty(name string, options ...PropertyOption) *conditional
OnProperty 返回一个以 onProperty 为开始条件的计算式。
func OnSingleCandidate ¶
OnSingleCandidate 返回一个以 onSingleCandidate 为开始条件的计算式。
Types ¶
type Context ¶
type Context interface {
// Prop 获取 key 对应的属性值,注意 key 是大小写敏感的。当 key 对应的属性
// 值存在时,或者 key 对应的属性值不存在但设置了默认值时,该方法返回 string
// 类型的数据,当 key 对应的属性值不存在且没有设置默认值时该方法返回 nil。
// 因此可以通过判断该方法的返回值是否为 nil 来判断 key 对应的属性值是否存在。
Prop(key string, opts ...conf.GetOption) interface{}
// Find 查找符合条件的 bean 对象,注意该函数只能保证返回的 bean 是有效的,
// 即未被标记为删除的,而不能保证已经完成属性绑定和依赖注入。
Find(selector bean.Selector) ([]bean.Definition, error)
}
Context IoC 容器对 cond 模块提供的最小功能集。
type PropertyOption ¶
type PropertyOption func(*onProperty)
func HavingValue ¶
func HavingValue(havingValue string) PropertyOption
HavingValue 当 havingValue 与属性值相同时条件成立。
Click to show internal directories.
Click to hide internal directories.