Documentation
¶
Overview ¶
Package models defines the domain models that model field relations and manipulation.
Index ¶
- func CountFields(fields []*Field) int
- func PrintFieldGraph(field *Field, tabs string)
- func PrintFieldRelation(toFields, fromFields []*Field)
- func PrintFieldTree(typename string, fields []*Field, tabs string)
- func PrintFunctionFields(function *Function)
- type Field
- type FieldOptions
- type Function
- type FunctionOptions
- type Generator
- type GeneratorOptions
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountFields ¶ added in v0.2.0
CountFields returns the number of fields in a field slice.
func PrintFieldGraph ¶ added in v0.2.0
PrintFieldGraph prints a list of fields with the related fields.
func PrintFieldRelation ¶ added in v0.2.0
func PrintFieldRelation(toFields, fromFields []*Field)
PrintFieldRelation prints the relationship between to and from fields.
func PrintFieldTree ¶ added in v0.2.0
PrintFieldTree prints a tree of fields for a given type to standard output.
func PrintFunctionFields ¶ added in v0.2.0
func PrintFunctionFields(function *Function)
PrintFunctionFields prints all of a functions fields to standard output.
Types ¶
type Field ¶
type Field struct {
// The variable name the field is assigned for assignment.
// This value will always be unique in the context of the application.
// Type variable names do not contain '.' (i.e 'tA' in 'tA.UserID')
// Field variable names are defined by their specifier (i.e '.UserID' in 'domain.Account.UserID').
VariableName string
// The package the field is defined in.
Package string
// The name of the field (i.e `ID` in `ID int`).
Name string
// The type definition of the field (i.e `int` in `ID int`, string, `Logger` in `log.Logger`).
Definition string
// The pointer(s) of the field in string format (i.e **).
Pointer string
// The type or field that contains this field.
Parent *Field
// The field that this field will be copied from (or nil).
// Set in the matcher.
From *Field
// The field that this field will be copied to (or nil).
// Set in the matcher.
To *Field
// The fields of this field.
Fields []*Field
// The custom options of a field.
Options FieldOptions
}
Field represents a field to be copied to/from. A field's struct properties are set in the parser unless its stated otherwise.
func (*Field) AllFields ¶ added in v0.2.0
AllFields gets all the fields in the scope of a field (including itself).
func (*Field) FullName ¶ added in v0.2.0
FullName gets the full name of a field including its parents (i.e domain.Account.User.ID).
func (*Field) FullVariableName ¶ added in v0.2.0
FullVariableName gets the full variable name of a field (i.e tA.User.UserID).
func (*Field) IsPointer ¶ added in v0.2.0
IsPointer returns the type is a pointer of a type definition.
type FieldOptions ¶
type FieldOptions struct {
// The function the field is converted with (as a parameter).
Convert string
// The field to map this field to, if any.
Map string
// The level at which sub-fields are discovered.
Depth int
// Whether the field should be deepcopied.
Deepcopy bool
}
FieldOptions represent options for a Field.
type Function ¶
type Function struct {
Name string // The name of the function.
Options FunctionOptions // The custom options of a function.
From []Type // The types to copy fields from.
To []Type // The types to copy fields to.
}
Function represents the properties of a generated function.
type FunctionOptions ¶
type FunctionOptions struct {
Custom map[string][]string // The custom options of a function (map[option]values).
Manual bool // Whether the function uses a manual matcher (as opposed to an Automatcher).
}
FunctionOptions represent options for a Function.
type Generator ¶
type Generator struct {
Functions []Function // The functions to generate.
Options GeneratorOptions // The custom options for the generator.
Loadpath string // The filepath the loader file is located in.
Setpath string // The filepath the setup file is located in.
Outpath string // The filepath the generated code is output to.
Tempath string // The filepath for the template used to generate code.
Keep []byte // The code that is kept from the setup file.
}
Generator represents a code generator.
type GeneratorOptions ¶ added in v0.2.0
type GeneratorOptions struct {
Custom map[string]interface{} // The custom options of a generator.
}
GeneratorOptions represent options for a Generator.
type Type ¶
type Type struct {
Field *Field // The field information for the type.
}
Type represents a field that isn't contained.
func (Type) ParameterName ¶ added in v0.2.0
ParameterName gets the parameter name of the type.