Documentation ¶
Index ¶
- func NoWrap(errStmt *jen.Statement) *jen.Statement
- func ToString(err *Error) string
- type Agg
- type Basic
- type BasicTargetPointerRule
- type Builder
- type Error
- type ErrorWrapper
- type Generator
- type ItemToListRule
- type List
- type Map
- type MethodContext
- func (ctx *MethodContext) DefinedFields(target *xtype.Type) map[string]struct{}
- func (ctx *MethodContext) Field(target *xtype.Type, name string) *config.FieldMapping
- func (ctx *MethodContext) HasSeen(source *xtype.Type) bool
- func (ctx *MethodContext) MarkSeen(source *xtype.Type)
- func (ctx *MethodContext) SetErrorTargetVar(m *jen.Statement)
- type Path
- type Pointer
- type SkipCopy
- type SourcePointer
- type Struct
- type TargetPointer
- type UseUnderlyingTypeMethods
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Agg ¶
type Agg struct{}
ItemToListRule handles edge conditions if the target type is a pointer.
type Basic ¶
type Basic struct{}
Basic handles basic data types.
type BasicTargetPointerRule ¶
type BasicTargetPointerRule struct{}
BasicTargetPointerRule handles edge conditions if the target type is a pointer.
func (*BasicTargetPointerRule) Build ¶
func (*BasicTargetPointerRule) Build(gen Generator, ctx *MethodContext, sourceID *xtype.JenID, source, target *xtype.Type) ([]jen.Code, *xtype.JenID, *Error)
Build creates conversion source code for the given source and target type.
func (*BasicTargetPointerRule) Matches ¶
func (*BasicTargetPointerRule) Matches(_ *MethodContext, source, target *xtype.Type) bool
Matches returns true, if the builder can create handle the given types.
type Builder ¶
type Builder interface { // Matches returns true, if the builder can create handle the given types. Matches(ctx *MethodContext, source, target *xtype.Type) bool // Build creates conversion source code for the given source and target type. Build(gen Generator, ctx *MethodContext, sourceID *xtype.JenID, source, target *xtype.Type) ([]jen.Code, *xtype.JenID, *Error) }
Builder builds converter implementations, and can decide if it can handle the given type.
type ErrorWrapper ¶
ErrorWrapper generates code that wraps the errors returned from conversion methods, embedding extra details to ease on troubleshooting.
type Generator ¶
type Generator interface { Build( ctx *MethodContext, sourceID *xtype.JenID, source, target *xtype.Type, errWrapper ErrorWrapper) ([]jen.Code, *xtype.JenID, *Error) CallMethod( ctx *MethodContext, method *method.Definition, sourceID *xtype.JenID, source, target *xtype.Type, errWrapper ErrorWrapper) ([]jen.Code, *xtype.JenID, *Error) }
Generator checks all existing builders if they can create a conversion implementations for the given source and target type If no one Builder#Matches then, an error is returned.
type ItemToListRule ¶
type ItemToListRule struct{}
ItemToListRule handles edge conditions if the target type is a pointer.
func (*ItemToListRule) Build ¶
func (*ItemToListRule) Build(gen Generator, ctx *MethodContext, sourceID *xtype.JenID, source, target *xtype.Type) ([]jen.Code, *xtype.JenID, *Error)
Build creates conversion source code for the given source and target type.
func (*ItemToListRule) Matches ¶
func (*ItemToListRule) Matches(_ *MethodContext, source, target *xtype.Type) bool
Matches returns true, if the builder can create handle the given types.
type List ¶
type List struct{}
List handles array / slice types.
type Map ¶
type Map struct{}
Map handles map types.
type MethodContext ¶
type MethodContext struct { *namer.Namer Conf *config.Method FieldsTarget string OutputPackagePath string Signature xtype.Signature TargetType *xtype.Type HasMethod func(types.Type, types.Type) bool SeenNamed map[string]struct{} TargetVar *jen.Statement }
MethodContext exposes information for the current method.
func (*MethodContext) DefinedFields ¶
func (ctx *MethodContext) DefinedFields(target *xtype.Type) map[string]struct{}
func (*MethodContext) Field ¶
func (ctx *MethodContext) Field(target *xtype.Type, name string) *config.FieldMapping
func (*MethodContext) MarkSeen ¶
func (ctx *MethodContext) MarkSeen(source *xtype.Type)
func (*MethodContext) SetErrorTargetVar ¶
func (ctx *MethodContext) SetErrorTargetVar(m *jen.Statement)
type Path ¶
type Path struct { Prefix string SourceID string TargetID string SourceType string TargetType string }
Path defines the path inside an error message.
type Pointer ¶
type Pointer struct{}
Pointer handles pointer types.
type SkipCopy ¶
type SkipCopy struct{}
SkipCopy handles FlagSkipCopySameType.
type SourcePointer ¶
type SourcePointer struct{}
SourcePointer handles type were only the source is a pointer.
func (*SourcePointer) Build ¶
func (*SourcePointer) Build(gen Generator, ctx *MethodContext, sourceID *xtype.JenID, source, target *xtype.Type) ([]jen.Code, *xtype.JenID, *Error)
Build creates conversion source code for the given source and target type.
func (*SourcePointer) Matches ¶
func (*SourcePointer) Matches(ctx *MethodContext, source, target *xtype.Type) bool
Matches returns true, if the builder can create handle the given types.
type Struct ¶
type Struct struct{}
Struct handles struct types.
type TargetPointer ¶
type TargetPointer struct{}
TargetPointer handles type were only the target is a pointer.
func (*TargetPointer) Build ¶
func (*TargetPointer) Build(gen Generator, ctx *MethodContext, sourceID *xtype.JenID, source, target *xtype.Type) ([]jen.Code, *xtype.JenID, *Error)
Build creates conversion source code for the given source and target type.
func (*TargetPointer) Matches ¶
func (*TargetPointer) Matches(_ *MethodContext, source, target *xtype.Type) bool
Matches returns true, if the builder can create handle the given types.
type UseUnderlyingTypeMethods ¶
type UseUnderlyingTypeMethods struct{}
UseUnderlyingTypeMethods handles UseUnderlyingTypeMethods.
func (*UseUnderlyingTypeMethods) Build ¶
func (*UseUnderlyingTypeMethods) Build(gen Generator, ctx *MethodContext, sourceID *xtype.JenID, source, target *xtype.Type) ([]jen.Code, *xtype.JenID, *Error)
Build creates conversion source code for the given source and target type.
func (*UseUnderlyingTypeMethods) Matches ¶
func (*UseUnderlyingTypeMethods) Matches(ctx *MethodContext, source, target *xtype.Type) bool
Matches returns true, if the builder can create handle the given types.