types

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TYPE_PRIMITIVE = "primitive"
	TYPE_USER      = "user"
	TYPE_WRAPPER   = "wrapper"
)

Variables

View Source
var ALLOWED_PRIMITIVE_STRING = fmt.Sprintf("[%s]", getPrimitiveString())
View Source
var LIST_WRAPPER_REGEX = "^list<[a-zA-Z0-9<>,\\.]*>$"
View Source
var MAP_WRAPPER_REGEX = "^map<[a-zA-Z0-9<>,\\.]*\\,[a-zA-Z0-9<>,\\.]*>$"
View Source
var OPTIONAL_WRAPPER_REGEX = "^optional<[a-zA-Z0-9<>,\\.]*>$"
View Source
var PRIMITIVES = map[string]TypeInterface{
	"string":  makePrimitive("string", true),
	"byte":    makePrimitive("byte", false),
	"binary":  makePrimitive("[]byte", false),
	"short":   makePrimitive("int16", false),
	"int":     makePrimitive("int", false),
	"long":    makePrimitive("int64", false),
	"float":   makePrimitive("float32", false),
	"double":  makePrimitive("float64", false),
	"boolean": makePrimitive("bool", false),

	"datetime": makeImportPrimitive("time", "Time", false),
}

Functions

func IsPrimitive

func IsPrimitive(str string) bool

func IsWrapped

func IsWrapped(ty string) bool

Types

type BaseType

type BaseType = string

type Import

type Import struct {
	Path    string
	PkgName string
}

func GenerateParsedImport

func GenerateParsedImport(specImport string, baseImportPath string) Import

type ListWrapper

type ListWrapper struct {
	Type TypeInterface
}

type MapWrapper

type MapWrapper struct {
	Type1 TypeInterface
	Type2 TypeInterface
}

type OptionalWrapper

type OptionalWrapper struct {
	Type TypeInterface
}

type Primitive

type Primitive struct {
	Name       string
	ImportPath string
	IsString   bool
}

func (Primitive) GetBaseType

func (t Primitive) GetBaseType() BaseType

func (Primitive) GetWrappedType

func (t Primitive) GetWrappedType() string

func (Primitive) Write

func (t Primitive) Write() *jen.Statement

func (Primitive) WriteStringConverter

func (t Primitive) WriteStringConverter(arg string, inputName string, outputName string) jen.Code

type Type

type Type struct {
	ImportPath string
	Name       string
}

func (Type) GetBaseType

func (t Type) GetBaseType() BaseType

func (Type) GetWrappedType

func (t Type) GetWrappedType() string

func (Type) Write

func (t Type) Write() *jen.Statement

type TypeInterface

type TypeInterface interface {
	Write() *jen.Statement
	GetBaseType() BaseType
	GetWrappedType() string
}

func GetPrimitive

func GetPrimitive(prim string) TypeInterface

func GetWrapper

func GetWrapper(typeStr string, imports map[string]Import) TypeInterface

func ParseType

func ParseType(typeName string, imports map[string]Import) TypeInterface

type Wrapper

type Wrapper struct {
	Types       []TypeInterface
	WrapperType WrapperType
}

func (Wrapper) GetBaseType

func (w Wrapper) GetBaseType() BaseType

func (Wrapper) GetWrappedType

func (w Wrapper) GetWrappedType() WrapperType

func (Wrapper) IsAllPrimitive

func (w Wrapper) IsAllPrimitive() bool

func (Wrapper) Write

func (w Wrapper) Write() *jen.Statement

func (Wrapper) WriteOptionalPrimitiveStringConverter

func (w Wrapper) WriteOptionalPrimitiveStringConverter(varName string, stringName string) jen.Code

type WrapperType

type WrapperType = string
const (
	LIST_WRAPPER     WrapperType = "LIST_WRAPPER"
	MAP_WRAPPER      WrapperType = "MAP_WRAPPER"
	OPTIONAL_WRAPPER WrapperType = "OPTIONAL_WRAPPER"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL