Documentation ¶
Index ¶
- func RegisterFactory(factory Factory)
- func Unmarshal(dest, src interface{}) error
- type Factory
- type GeneralInterfaceFactory
- func (factory *GeneralInterfaceFactory) Create(data map[string]interface{}) (interface{}, error)
- func (factory *GeneralInterfaceFactory) GetInstanceType() reflect.Type
- func (factory *GeneralInterfaceFactory) RegisterInstance(name string, instance interface{})
- func (factory *GeneralInterfaceFactory) RegisterType(name string, instanceType reflect.Type)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Factory ¶
type Factory interface { // GetInstanceType returns the type of the instance create by this factory. // The instance type is used to index the factory. GetInstanceType() reflect.Type // Create returns the new instance. Create(map[string]interface{}) (interface{}, error) }
Factory represents a instance factory used in unmarshaling.
type GeneralInterfaceFactory ¶
type GeneralInterfaceFactory struct {
// contains filtered or unexported fields
}
GeneralInterfaceFactory provides a general factory for interface. For creating instance, the input map need a key to specified the type implelement the interface. The factory new a instance with the type associated the type key, and unmarshal the map to the instance struct.
func NewGeneralInterfaceFactory ¶
func NewGeneralInterfaceFactory(interfaceType reflect.Type, typeKey string, initializer func(interface{}) error) *GeneralInterfaceFactory
NewGeneralInterfaceFactory creates a GeneralInterfaceFactory instance.
func (*GeneralInterfaceFactory) Create ¶
func (factory *GeneralInterfaceFactory) Create(data map[string]interface{}) (interface{}, error)
Create creates a new instance implement the interface.
func (*GeneralInterfaceFactory) GetInstanceType ¶
func (factory *GeneralInterfaceFactory) GetInstanceType() reflect.Type
GetInstanceType returns the interface type.
func (*GeneralInterfaceFactory) RegisterInstance ¶
func (factory *GeneralInterfaceFactory) RegisterInstance(name string, instance interface{})
RegisterInstance register new instance and its associated key.
func (*GeneralInterfaceFactory) RegisterType ¶
func (factory *GeneralInterfaceFactory) RegisterType(name string, instanceType reflect.Type)
RegisterType register new type and its associated key.
Click to show internal directories.
Click to hide internal directories.