Documentation ¶
Overview ¶
Package cond provides many conditions used when registering bean.
Package cond is a generated GoMock package.
Index ¶
- Constants
- func New() *conditional
- func On(cond Condition) *conditional
- func OnBean(selector util.BeanSelector) *conditional
- func OnExpression(expression string) *conditional
- func OnMatches(fn func(ctx Context) (bool, error)) *conditional
- func OnMissingBean(selector util.BeanSelector) *conditional
- func OnMissingProperty(name string) *conditional
- func OnProfile(profile string) *conditional
- func OnProperty(name string, options ...PropertyOption) *conditional
- func OnSingleBean(selector util.BeanSelector) *conditional
- type Condition
- type Context
- type FuncCond
- type MockCondition
- type MockConditionMockRecorder
- type MockContext
- type MockContextMockRecorder
- type Operator
- type PropertyOption
Constants ¶
const ( Or = Operator(1) // at least one of the conditions must be met. And = Operator(2) // all conditions must be met. None = Operator(3) // all conditions must be not met. )
Variables ¶
This section is empty.
Functions ¶
func On ¶
func On(cond Condition) *conditional
On returns a conditional that starts with one Condition.
func OnBean ¶
func OnBean(selector util.BeanSelector) *conditional
OnBean returns a conditional that starts with a Condition that returns true when finding more than one beans.
func OnExpression ¶
func OnExpression(expression string) *conditional
OnExpression returns a conditional that starts with a Condition that returns true when an expression returns true.
func OnMatches ¶
OnMatches returns a conditional that starts with a Condition that returns true when function returns true.
func OnMissingBean ¶
func OnMissingBean(selector util.BeanSelector) *conditional
OnMissingBean returns a conditional that starts with a Condition that returns true when finding no beans.
func OnMissingProperty ¶
func OnMissingProperty(name string) *conditional
OnMissingProperty returns a conditional that starts with a Condition that returns true when property doesn't exist.
func OnProfile ¶
func OnProfile(profile string) *conditional
OnProfile returns a conditional that starts with a Condition that returns true when property value equals to profile.
func OnProperty ¶
func OnProperty(name string, options ...PropertyOption) *conditional
OnProperty returns a conditional that starts with a Condition that checks a property and its value.
func OnSingleBean ¶
func OnSingleBean(selector util.BeanSelector) *conditional
OnSingleBean returns a conditional that starts with a Condition that returns true when finding only one bean.
Types ¶
type Condition ¶
Condition is used when registering a bean to determine whether it's valid.
type Context ¶
type Context interface { // Has returns whether the IoC container has a property. Has(key string) bool // Prop returns the property's value when the IoC container has it, or // returns empty string when the IoC container doesn't have it. Prop(key string, opts ...conf.GetOption) string // Find returns bean definitions that matched with the bean selector. Find(selector util.BeanSelector) ([]util.BeanDefinition, error) }
Context defines some methods of IoC container that conditions use.
type MockCondition ¶
type MockCondition struct {
// contains filtered or unexported fields
}
MockCondition is a mock of Condition interface.
func NewMockCondition ¶
func NewMockCondition(ctrl *gomock.Controller) *MockCondition
NewMockCondition creates a new mock instance.
func (*MockCondition) EXPECT ¶
func (m *MockCondition) EXPECT() *MockConditionMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockConditionMockRecorder ¶
type MockConditionMockRecorder struct {
// contains filtered or unexported fields
}
MockConditionMockRecorder is the mock recorder for MockCondition.
func (*MockConditionMockRecorder) Matches ¶
func (mr *MockConditionMockRecorder) Matches(ctx interface{}) *gomock.Call
Matches indicates an expected call of Matches.
type MockContext ¶
type MockContext struct {
// contains filtered or unexported fields
}
MockContext is a mock of Context interface.
func NewMockContext ¶
func NewMockContext(ctrl *gomock.Controller) *MockContext
NewMockContext creates a new mock instance.
func (*MockContext) EXPECT ¶
func (m *MockContext) EXPECT() *MockContextMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockContext) Find ¶
func (m *MockContext) Find(selector util.BeanSelector) ([]util.BeanDefinition, error)
Find mocks base method.
type MockContextMockRecorder ¶
type MockContextMockRecorder struct {
// contains filtered or unexported fields
}
MockContextMockRecorder is the mock recorder for MockContext.
func (*MockContextMockRecorder) Find ¶
func (mr *MockContextMockRecorder) Find(selector interface{}) *gomock.Call
Find indicates an expected call of Find.
func (*MockContextMockRecorder) Has ¶
func (mr *MockContextMockRecorder) Has(key interface{}) *gomock.Call
Has indicates an expected call of Has.
func (*MockContextMockRecorder) Prop ¶
func (mr *MockContextMockRecorder) Prop(key interface{}, opts ...interface{}) *gomock.Call
Prop indicates an expected call of Prop.
type Operator ¶
type Operator int
Operator defines operation between conditions, including Or、And、None.
type PropertyOption ¶
type PropertyOption func(*onProperty)
func HavingValue ¶
func HavingValue(havingValue string) PropertyOption
HavingValue sets a Condition to return true when property value equals to havingValue.
func MatchIfMissing ¶
func MatchIfMissing() PropertyOption
MatchIfMissing sets a Condition to return true when property doesn't exist.