Documentation
¶
Index ¶
- type Array
- func (array *Array) AddProperties(set set.Set, safe bool) error
- func (array *Array) ChangeName(mark name.Mark)
- func (array *Array) CollectObjects(limit, offset int) (set.Set, error)
- func (array *Array) CollectProperties(limit, offset int) (set.Set, error)
- func (array *Array) Compress(source, destination hash.IHashable)
- func (array *Array) ContainsObject() bool
- func (array *Array) Copy() Item
- func (array *Array) Default(suffix string) string
- func (array *Array) GenerateGetter(variable, argument, interfaceSuffix string, depth int) string
- func (array *Array) GenerateSetter(variable, argument, typeSuffix string, depth int) string
- func (array *Array) GetChildren() []hash.IHashable
- func (array *Array) InterfaceType(suffix string) string
- func (array *Array) IsNull() bool
- func (array *Array) MakeRequired()
- func (array *Array) Parse(context ParseContext) (err error)
- func (array *Array) ToString() string
- func (array *Array) Type(suffix string) string
- type DBKind
- type Item
- type JSONKind
- type Kind
- type Object
- func (object *Object) AddProperties(properties set.Set, safe bool) error
- func (object *Object) ChangeName(mark name.Mark)
- func (object *Object) CollectObjects(limit, offset int) (set.Set, error)
- func (object *Object) CollectProperties(limit, offset int) (set.Set, error)
- func (object *Object) Compress(source, destination hash.IHashable)
- func (object *Object) ContainsObject() bool
- func (object *Object) Copy() Item
- func (object *Object) Default(suffix string) string
- func (object *Object) Empty() bool
- func (object *Object) GenerateConstructor(suffix string) string
- func (object *Object) GenerateFetch(packageName, suffix string, params crud.Params) string
- func (object *Object) GenerateGetter(variable, argument, interfaceSuffix string, depth int) string
- func (object *Object) GenerateImplementation(interfaceSuffix, typeSuffix string) string
- func (object *Object) GenerateInterface(suffix string) string
- func (object *Object) GenerateList(packageName, suffix string, params crud.Params) string
- func (object *Object) GenerateMutableInterface(interfaceSuffix, typeSuffix string) string
- func (object *Object) GenerateSchemaName(goextPackage, typename string) string
- func (object *Object) GenerateSetter(variable, argument, typeSuffix string, depth int) string
- func (object *Object) GenerateStruct(suffix string) string
- func (object *Object) GetChildren() []hash.IHashable
- func (object *Object) InterfaceType(suffix string) string
- func (object *Object) IsNull() bool
- func (object *Object) MakeRequired()
- func (object *Object) Name() string
- func (object *Object) Parse(context ParseContext) error
- func (object *Object) ToString() string
- func (object *Object) Type(suffix string) string
- type ParseContext
- type PlainItem
- func (plainItem *PlainItem) AddProperties(set set.Set, safe bool) error
- func (plainItem *PlainItem) ChangeName(mark name.Mark)
- func (plainItem *PlainItem) CollectObjects(limit, offset int) (set.Set, error)
- func (plainItem *PlainItem) CollectProperties(limit, offset int) (set.Set, error)
- func (plainItem *PlainItem) Compress(hash.IHashable, hash.IHashable)
- func (plainItem *PlainItem) ContainsObject() bool
- func (plainItem *PlainItem) Copy() Item
- func (plainItem *PlainItem) Default(suffix string) string
- func (plainItem *PlainItem) GenerateGetter(variable, argument, interfaceSuffix string, depth int) string
- func (plainItem *PlainItem) GenerateSetter(variable, argument, typeSuffix string, depth int) string
- func (plainItem *PlainItem) GetChildren() []hash.IHashable
- func (plainItem *PlainItem) InterfaceType(suffix string) string
- func (plainItem *PlainItem) IsNull() bool
- func (plainItem *PlainItem) MakeRequired()
- func (plainItem *PlainItem) Parse(context ParseContext) (err error)
- func (plainItem *PlainItem) ToString() string
- func (plainItem *PlainItem) Type(suffix string) string
- type Property
- func (property *Property) AddProperties(set set.Set, safe bool) error
- func (property *Property) ChangeName(mark name.Mark)
- func (property *Property) CollectObjects(limit, offset int) (set.Set, error)
- func (property *Property) CollectProperties(limit, offset int) (set.Set, error)
- func (property *Property) Compress(source, destination hash.IHashable)
- func (property *Property) CompressObjects()
- func (property *Property) GenerateConstructor(suffix string) string
- func (property *Property) GenerateGetter(variable, suffix string) string
- func (property *Property) GenerateProperty(suffix string) string
- func (property *Property) GenerateSetter(variable, interfaceSuffix, typeSuffix string) string
- func (property *Property) GetChildren() []hash.IHashable
- func (property *Property) GetterHeader(suffix string) string
- func (property *Property) IsObject() bool
- func (property *Property) MakeRequired() bool
- func (property *Property) Name() string
- func (property *Property) Parse(context ParseContext) (err error)
- func (property *Property) SetterHeader(suffix string, argument bool) string
- func (property *Property) ToString() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
Array is an implementation of Item interface
func (*Array) AddProperties ¶
AddProperties implementation
func (*Array) CollectObjects ¶
CollectObjects implementation
func (*Array) CollectProperties ¶
CollectProperties implementation
func (*Array) ContainsObject ¶
ContainsObject implementation
func (*Array) GenerateGetter ¶
GenerateGetter implementation
func (*Array) GenerateSetter ¶
GenerateSetter implementation
func (*Array) GetChildren ¶
GetChildren implementation
func (*Array) InterfaceType ¶
InterfaceType implementation
func (*Array) Parse ¶
func (array *Array) Parse(context ParseContext) (err error)
Parse implementation
type DBKind ¶
type DBKind struct {
}
DBKind is an implementation of Kind interface
func (*DBKind) Annotation ¶
Annotation implementation
func (*DBKind) InterfaceType ¶
InterfaceType implementation
type Item ¶
type Item interface {
hash.IHashable
// Copy should make a copy of an item
Copy() Item
// ChangeName should change the name of an item recursively
// args:
// 1. name.Mark - mark that changes the items name
ChangeName(name.Mark)
// IsNull checks if an item can be null
// return:
// true iff. item can be null
IsNull() bool
// MakeRequired should not allow item to be null
MakeRequired()
// ContainsObject checks if an item contains an object
// return:
// true iff. item contains an object
ContainsObject() bool
// Default should return a default value for an item
// args:
// 1. string - a suffix added to a type
// return:
// default value of an item
Default(string) string
// Type should return a go type of item
// args:
// 1. string - a suffix added to a type
// return:
// type of item with suffix appended
Type(string) string
// InterfaceType should return an interface type of item
// args:
// 1. string - a suffix added to a type
// return:
// interface type of item with suffix appended
InterfaceType(string) string
// AddProperties should add properties to an item
// args:
// 1. set.Set [Property] - a set of properties
// 2. bool - flag; if in the set exists a property with the same type
// as one of the items properties, then if flag is set
// an error should be returned,
// otherwise that property should be ignored
// return:
// 1. error during execution
AddProperties(set.Set, bool) error
// Parse should create an item from given map
// args:
// 1. context - ParseContext; context used for parsing
// return:
// 1. error during execution
Parse(ParseContext) error
// CollectObjects should return a set of objects contained within an item
// args:
// 1. int - limit; how deep to search for an object; starting from 1;
// if limit is negative this parameter is ignored.
// 2. int - offset; from which level gathering objects should begin;
// starting from 0;
// return:
// 1. set of collected objects
// 2. error during execution
// example:
// let objects be denoted by o and other items by i
// suppose we have the following tree:
// o1
// / \
// o2 o3
// / \ \
// o4 o5 o6
// / \ \ \
// o7 i1 i2 i3
//
// CollectObjects(3, 1) should return a set of o2, o3, o4, o5, o6
// CollectObjects(2, 2) should return an empty set
// CollectObjects(-1, 4) should return a set of o7
CollectObjects(int, int) (set.Set, error)
// CollectProperties should return a set properties contained within an item
// args:
// 1. int - limit; how deep to search for a property; starting from 1;
// if limit is negative this parameter is ignored.
// 2. int - offset; from which level gathering properties should begin;
// starting from 0;
// return:
// 1. set of collected properties
// 2. error during execution
CollectProperties(int, int) (set.Set, error)
// GenerateGetter should return a body of a getter function for given item
// args:
// 1. string - variable; a name of a variable to get
// 2. string - argument; a name of a result
// 3. string - suffix; a suffix added to items type
// 4. int - depth; a width of an indent
// return:
// string representing a body of a getter function
GenerateGetter(string, string, string, int) string
// GenerateSetter should return a body of a setter function for given item
// args:
// 1. string - variable; a name of a variable to set
// 2. string - argument; a name of an argument of the function
// 3. string - suffix; a suffix added to items type
// 4. int - depth; a width of an indent
// return:
// string representing a body of a setter function
GenerateSetter(string, string, string, int) string
}
Item is an interface for a type of a variable
func CreateItem ¶
CreateItem is a factory for items
type JSONKind ¶
type JSONKind struct {
}
JSONKind is an implementation of Kind interface
func (*JSONKind) Annotation ¶
Annotation implementation
func (*JSONKind) InterfaceType ¶
InterfaceType implementation
type Kind ¶
type Kind interface {
// Type should return a go type of a property
// args:
// 1. string - a suffix added to a type
// 2. item - an item of a property
// return:
// go type of a property
Type(string, Item) string
// Type should return an interface type of a property
// args:
// 1. string - a suffix added to a type
// 2. item - an item of a property
// return:
// interface type of a property
InterfaceType(string, Item) string
// Annotation should return an annotation for a property is a go struct
// args:
// 1. string - a name of a property
// 2. item - an item of a property
// return:
// go annotation of a property
Annotation(string, Item) string
// Default should return a default value for a property
// args:
// 1. string - a name of a property
// 2. item - an item of a property
// return:
// default value of a property as string
Default(string, Item) string
}
Kind is an interface for a type of property it can be either db or json
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object is an implementation of Item interface
func (*Object) AddProperties ¶
AddProperties implementation
func (*Object) ChangeName ¶
ChangeName implementation
func (*Object) CollectObjects ¶
CollectObjects implementation
func (*Object) CollectProperties ¶
CollectProperties implementation
func (*Object) ContainsObject ¶
ContainsObject implementation
func (*Object) GenerateConstructor ¶
GenerateConstructor creates a constructor for an object
func (*Object) GenerateFetch ¶
GenerateFetch generates a fetch function for an object
func (*Object) GenerateGetter ¶
func (object *Object) GenerateGetter( variable, argument, interfaceSuffix string, depth int, ) string
GenerateGetter implementation
func (*Object) GenerateImplementation ¶
GenerateImplementation creates an implementation of an objects getter and setter methods
func (*Object) GenerateInterface ¶
GenerateInterface creates an interface of an object with suffix added to objects type
func (*Object) GenerateList ¶
GenerateList generates a list function for an object
func (*Object) GenerateMutableInterface ¶
GenerateMutableInterface creates an interface of an object with suffix added to objects type this interface can be edited
func (*Object) GenerateSchemaName ¶
func (*Object) GenerateSetter ¶
GenerateSetter implementation
func (*Object) GenerateStruct ¶
GenerateStruct creates a struct of an object with suffix added to type name of each field
func (*Object) GetChildren ¶
GetChildren implementation
func (*Object) InterfaceType ¶
InterfaceType implementation
type ParseContext ¶
type ParseContext struct {
Prefix string
Level int
Required bool
Defaults interface{}
Data map[interface{}]interface{}
}
ParseContext represents context used in parsing
type PlainItem ¶
type PlainItem struct {
// contains filtered or unexported fields
}
PlainItem is an implementation of Item interface
func (*PlainItem) AddProperties ¶
AddProperties implementation
func (*PlainItem) ChangeName ¶
ChangeName implementation
func (*PlainItem) CollectObjects ¶
CollectObjects implementation
func (*PlainItem) CollectProperties ¶
CollectProperties implementation
func (*PlainItem) ContainsObject ¶
ContainsObject implementation
func (*PlainItem) GenerateGetter ¶
func (plainItem *PlainItem) GenerateGetter( variable, argument, interfaceSuffix string, depth int, ) string
GenerateGetter implementation
func (*PlainItem) GenerateSetter ¶
func (plainItem *PlainItem) GenerateSetter( variable, argument, typeSuffix string, depth int, ) string
GenerateSetter implementation
func (*PlainItem) GetChildren ¶
GetChildren implementation
func (*PlainItem) InterfaceType ¶
InterfaceType implementation
func (*PlainItem) MakeRequired ¶
func (plainItem *PlainItem) MakeRequired()
MakeRequired implementation
func (*PlainItem) Parse ¶
func (plainItem *PlainItem) Parse(context ParseContext) (err error)
Parse implementation
type Property ¶
type Property struct {
// contains filtered or unexported fields
}
Property is a type for an item with name
func (*Property) AddProperties ¶
AddProperties adds properties to items of given property args:
set set.Set [Property] - a set of properties
safe bool - flag; if in the set exists a property with the same type
as one of the items properties, then if flag is set
an error should be returned,
otherwise that property should be ignored
return:
- error during execution
func (*Property) ChangeName ¶
ChangeName should change name of items of a property
func (*Property) CollectObjects ¶
CollectObjects should return a set of objects contained within a property args:
- int - limit; how deep to search for an object; starting from 0; if limit is negative this parameter is ignored.
- int - offset; from which level gathering objects should begin;
return:
- set of collected objects
- error during execution
func (*Property) CollectProperties ¶
CollectProperties should return a set properties contained within a property args:
- int - limit; how deep to search for a property; starting from 0; if limit is negative this parameter is ignored.
- int - offset; from which level gathering properties should begin;
return:
- set of collected properties
- error during execution
func (*Property) CompressObjects ¶
func (property *Property) CompressObjects()
CompressObjects removes duplicate objects from an object tree rooted at a property
func (*Property) GenerateConstructor ¶
GenerateConstructor creates a constructor for a property
func (*Property) GenerateGetter ¶
GenerateGetter returns a getter for a property
func (*Property) GenerateProperty ¶
GenerateProperty creates a property of a go struct from given property with suffix added to type name
func (*Property) GenerateSetter ¶
GenerateSetter returns a setter for a property
func (*Property) GetChildren ¶
GetChildren implementation
func (*Property) GetterHeader ¶
GetterHeader returns a header of a getter for a property
func (*Property) MakeRequired ¶
MakeRequired makes an item in property required returns true if property was changed
func (*Property) Parse ¶
func (property *Property) Parse(context ParseContext) (err error)
Parse creates property from given map, prefix and level prefix is used to determine a go type of an item level is used to determine a kind of a property args:
context ParseContext - a context used for parsing
return:
- error during execution
func (*Property) SetterHeader ¶
SetterHeader returns a header of a setter for a property