arg

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: Apache-2.0 Imports: 9 Imported by: 6

Documentation

Overview

Package arg 用于实现函数参数绑定。

Package arg is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Option

func Option(fn interface{}, args ...Arg) *optionArg

Option 返回 Option 函数的参数绑定。

Types

type Arg

type Arg interface{}

Arg 用于为函数参数提供绑定值。可以是 bean.Selector 类型,表示注入 bean ; 可以是 ${X:=Y} 形式的字符串,表示属性绑定或者注入 bean ;可以是 ValueArg 类型,表示不从 IoC 容器获取而是用户传入的普通值;可以是 IndexArg 类型,表示 带有下标的参数绑定;可以是 *optionArg 类型,用于为 Option 方法提供参数绑定。

type Callable

type Callable struct {
	// contains filtered or unexported fields
}

Callable wrappers a function and its binding arguments, then you can invoke the Call method of Callable to get the function's result.

func Bind

func Bind(fn interface{}, args []Arg, skip int) (*Callable, error)

Bind returns a Callable that wrappers a function and its binding arguments. The argument skip is the number of frames to skip over.

func Provide

func Provide(fn interface{}, args ...Arg) *Callable

Provide 为 Option 方法绑定运行时参数。

func (*Callable) Arg

func (r *Callable) Arg(i int) (Arg, bool)

Arg returns the ith binding argument.

func (*Callable) Call

func (r *Callable) Call(ctx Context) ([]reflect.Value, error)

Call invokes the function with its binding arguments processed in the IoC container. If the function returns an error, then the Call returns it.

func (*Callable) In added in v1.1.1

func (r *Callable) In(i int) (reflect.Type, bool)

type Context

type Context interface {
	// Matches returns true when the Condition returns true,
	// and returns false when the Condition returns false.
	Matches(c cond.Condition) (bool, error)
	// Bind binds properties value by the "value" tag.
	Bind(v reflect.Value, tag string) error
	// Wire wires dependent beans by the "autowire" tag.
	Wire(v reflect.Value, tag string) error
}

Context defines some methods of IoC container that Callable use.

type IndexArg

type IndexArg struct {
	// contains filtered or unexported fields
}

IndexArg is an Arg that has an index.

func Index

func Index(n int, arg Arg) IndexArg

Index returns an IndexArg.

func R0

func R0(arg Arg) IndexArg

R0 returns an IndexArg with index 0.

func R1

func R1(arg Arg) IndexArg

R1 returns an IndexArg with index 1.

func R2

func R2(arg Arg) IndexArg

R2 returns an IndexArg with index 2.

func R3

func R3(arg Arg) IndexArg

R3 returns an IndexArg with index 3.

func R4

func R4(arg Arg) IndexArg

R4 returns an IndexArg with index 4.

func R5

func R5(arg Arg) IndexArg

R5 returns an IndexArg with index 5.

func R6

func R6(arg Arg) IndexArg

R6 returns an IndexArg with index 6.

type MockArg

type MockArg struct {
	// contains filtered or unexported fields
}

MockArg is a mock of Arg interface.

func NewMockArg

func NewMockArg(ctrl *gomock.Controller) *MockArg

NewMockArg creates a new mock instance.

func (*MockArg) EXPECT

func (m *MockArg) EXPECT() *MockArgMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

type MockArgMockRecorder

type MockArgMockRecorder struct {
	// contains filtered or unexported fields
}

MockArgMockRecorder is the mock recorder for MockArg.

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) Bind

func (m *MockContext) Bind(v reflect.Value, tag string) error

Bind mocks base method.

func (*MockContext) EXPECT

func (m *MockContext) EXPECT() *MockContextMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockContext) Matches

func (m *MockContext) Matches(c cond.Condition) (bool, error)

Matches mocks base method.

func (*MockContext) Wire

func (m *MockContext) Wire(v reflect.Value, tag string) error

Wire mocks base method.

type MockContextMockRecorder

type MockContextMockRecorder struct {
	// contains filtered or unexported fields
}

MockContextMockRecorder is the mock recorder for MockContext.

func (*MockContextMockRecorder) Bind

func (mr *MockContextMockRecorder) Bind(v, tag interface{}) *gomock.Call

Bind indicates an expected call of Bind.

func (*MockContextMockRecorder) Matches

func (mr *MockContextMockRecorder) Matches(c interface{}) *gomock.Call

Matches indicates an expected call of Matches.

func (*MockContextMockRecorder) Wire

func (mr *MockContextMockRecorder) Wire(v, tag interface{}) *gomock.Call

Wire indicates an expected call of Wire.

type ValueArg

type ValueArg struct {
	// contains filtered or unexported fields
}

ValueArg is an Arg that has a value.

func Nil

func Nil() ValueArg

Nil return a ValueArg with a value of nil.

func Value

func Value(v interface{}) ValueArg

Value return a ValueArg with a value of v.

Jump to

Keyboard shortcuts

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