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 NoPrefix bool `value:"false"` // 所有生成的枚举不携带类型名称前缀 StringParse bool `value:"true"` StringParseName string `value:"Name"` Flag bool `value:"false"` MustParse bool `value:"false"` Marshal bool `value:"false"` MarshalName string `value:"Name"` Sql bool `value:"false"` SqlName string `value:"Val"` Names bool `value:"false"` // enum name list Values bool `value:"false"` // enum item list NoCase bool `value:"false"` // case insensitivity NoCamel bool `value:"false"` NoComments bool `value:"false"` 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.