Documentation
¶
Index ¶
- Constants
- Variables
- func IndefiniteArticle(word string) string
- type Annotation
- type Attribute
- func (ea *Attribute) Attribute2EnumMap() string
- func (ea *Attribute) Attribute2EnumVarName() string
- func (ea *Attribute) Enum() *Enum
- func (ea *Attribute) Enum2AttributeMap() string
- func (ea *Attribute) Enum2AttributeVarName() string
- func (ea *Attribute) FirstValueBits() int
- func (ea *Attribute) IsValue() bool
- func (ea *Attribute) ParseNumberFuncString() string
- type Config
- type Enum
- func (e *Enum) CheckValid() (err error)
- func (e *Enum) EmptyEnumValue() string
- func (e *Enum) FindAttributeByName(name string) *Attribute
- func (e *Enum) GetItems() []*Item
- func (e *Enum) Names() string
- func (e *Enum) UpdateAttributes(a *api.Annotation) error
- func (e *Enum) UpdateItems(a *api.Annotation) error
- type EnumGenerator
- type Factory
- type Item
Constants ¶
View Source
const ( ItemName = "Name" ItemValue = "Val" )
View Source
const (
BlankIdentifier = "_"
)
Variables ¶
View Source
var ErrInvalidAnnotation = errors.New("not a valid Annotation")
Functions ¶
func IndefiniteArticle ¶
Types ¶
type Annotation ¶
type Annotation string
@Enum {
Enum = "Enum"
EnumConfig = "EnumConfig"
}
const ( // AnnotationEnum is an Annotation of type Enum. AnnotationEnum Annotation = "Enum" // AnnotationEnumConfig is an Annotation of type EnumConfig. AnnotationEnumConfig Annotation = "EnumConfig" )
func ParseAnnotation ¶
func ParseAnnotation(value string) (Annotation, error)
ParseAnnotation converts a string to an Annotation.
func (Annotation) IsValid ¶
func (x Annotation) IsValid() bool
IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values
func (Annotation) String ¶
func (x Annotation) String() string
String implements the Stringer interface.
type Attribute ¶
type Attribute struct {
Name string
Type reflect.Kind
Comment string
// contains filtered or unexported fields
}
func (*Attribute) Attribute2EnumMap ¶
func (*Attribute) Attribute2EnumVarName ¶
func (*Attribute) Enum2AttributeMap ¶
func (*Attribute) Enum2AttributeVarName ¶
func (*Attribute) FirstValueBits ¶
func (*Attribute) ParseNumberFuncString ¶
type Config ¶
type Config struct {
Prefix string // default prefix will be the enum type name
NoPrefix bool `value:"false"` // if true, the enum will use the enum item name direct, else will create enum item with enum type prefix
StringParse bool `value:"true"` // create
StringParseName string `value:"Name"` // parse method use which enum parameter
Flag bool `value:"false"` // if true, create code used with flag
MustParse bool `value:"false"` // if true, create muse parse method
Marshal bool `value:"false"` // if true, create Marshal interface method
MarshalName string `value:"Name"` // Marshal interface use which enum parameter
Sql bool `value:"false"` // if true, create code used with sql
SqlName string `value:"Val"` // sql method use which enum parameter
Names bool `value:"false"` // if true, create enum name list
Values bool `value:"false"` // if true, create enum item list
NoCase bool `value:"false"` // case insensitivity with parse method
NoCamel bool `value:"false"` // if true, do nothing with enum name
NoComments bool `value:"false"` // if true, will not create comments
Ptr bool `value:"false"`
ForceUpper bool `value:"false"`
ForceLower bool `value:"false"`
PanicIfInvalid bool `value:"false"`
// contains filtered or unexported fields
}
func (*Config) CheckValid ¶
func (*Config) SetForceLower ¶
func (*Config) SetForceUpper ¶
func (*Config) SetStringParse ¶
type Enum ¶
type Enum struct {
Name string
Type reflect.Kind
Comment string
Attrs []*Attribute
Items []*Item
Config *Config
}
func AnnotationsToEnum ¶
func (*Enum) CheckValid ¶
func (*Enum) EmptyEnumValue ¶
func (*Enum) FindAttributeByName ¶
func (*Enum) UpdateAttributes ¶
func (e *Enum) UpdateAttributes(a *api.Annotation) error
func (*Enum) UpdateItems ¶
func (e *Enum) UpdateItems(a *api.Annotation) error
type EnumGenerator ¶
type EnumGenerator struct {
api.BaseGenerator[Enum]
}
func NewEnumGenerator ¶
func NewEnumGenerator(allEnums []*Enum) *EnumGenerator
func (*EnumGenerator) GetImports ¶
func (eg *EnumGenerator) GetImports() []string
type Factory ¶
type Factory struct {
}
@Singleton
func (*Factory) Annotations ¶
func (f *Factory) Annotations() map[string][]api.AnnotationType
Source Files
¶
Click to show internal directories.
Click to hide internal directories.