Documentation ¶
Index ¶
- Constants
- func CamelCase(s string) string
- func CamelCaseSlice(elem []string) string
- type Descriptor
- type EnumDescriptor
- type FileDescriptor
- type Generator
- func (g *Generator) BuildTypeNameMap()
- func (g *Generator) CommandLineParameters(parameter string)
- func (g *Generator) Error(err error, msgs ...string)
- func (g *Generator) Fail(msgs ...string)
- func (g *Generator) GenerateAllFiles()
- func (g *Generator) In()
- func (g *Generator) Newline()
- func (g *Generator) ObjectNamed(typeName string) Object
- func (g *Generator) Out()
- func (g *Generator) P(str ...interface{})
- func (g *Generator) PrintComments(path string) bool
- func (g *Generator) WrapTypes()
- type ImportedDescriptor
- type JavaImportPath
- type JavaPackageName
- type Object
Constants ¶
const ( // GeneratorName of this generator GeneratorName = "protoc-gen-bean" // DefaultIndent for tab or space DefaultIndent = " " )
const ( FlavorKotlin = iota FlavorJava )
Variables ¶
This section is empty.
Functions ¶
func CamelCaseSlice ¶
CamelCaseSlice is like CamelCase, but the argument is a slice of strings to be joined with "_".
Types ¶
type Descriptor ¶
type Descriptor struct { *descriptor.DescriptorProto // contains filtered or unexported fields }
Descriptor represents a protocol buffer message.
func (*Descriptor) File ¶
func (c *Descriptor) File() *FileDescriptor
func (*Descriptor) JavaImportPath ¶
func (c *Descriptor) JavaImportPath() JavaImportPath
JavaImportPath is the import path of the Java package containing the type.
func (*Descriptor) TypeName ¶
func (d *Descriptor) TypeName() []string
TypeName returns the elements of the dotted type name. The package name is not part of this name.
type EnumDescriptor ¶
type EnumDescriptor struct { *descriptor.EnumDescriptorProto // contains filtered or unexported fields }
EnumDescriptor describes an enum. If it's at top level, its parent will be nil. Otherwise it will be the descriptor of the message in which it is defined.
func (*EnumDescriptor) File ¶
func (c *EnumDescriptor) File() *FileDescriptor
func (*EnumDescriptor) JavaImportPath ¶
func (c *EnumDescriptor) JavaImportPath() JavaImportPath
JavaImportPath is the import path of the Java package containing the type.
func (*EnumDescriptor) TypeName ¶
func (e *EnumDescriptor) TypeName() (s []string)
TypeName returns the elements of the dotted type name. The package name is not part of this name.
type FileDescriptor ¶
type FileDescriptor struct { *descriptor.FileDescriptorProto // contains filtered or unexported fields }
FileDescriptor describes an protocol buffer descriptor file (.proto). It includes slices of all the messages and enums defined within it. Those slices are constructed by WrapTypes.
func (*FileDescriptor) VarName ¶
func (d *FileDescriptor) VarName() string
VarName is the variable name we'll use in the generated code to refer to the compressed bytes of this descriptor. It is not exported, so it is only valid inside the generated package.
type Generator ¶
type Generator struct { *bytes.Buffer Request *plugin.CodeGeneratorRequest // The input. Response *plugin.CodeGeneratorResponse // The output. Param map[string]string // Command-line parameters. ValueObjectPackage string // Java value object output package NoTime bool // DO NOT generate timestamp in header // contains filtered or unexported fields }
Generator is the type whose methods generate the output, stored in the associated response structure.
func New ¶
func New() *Generator
New creates a new generator and allocates the request and response protobufs.
func (*Generator) BuildTypeNameMap ¶
func (g *Generator) BuildTypeNameMap()
BuildTypeNameMap builds the map from fully qualified type names to object. The key names for the map come from the input data, which puts a period at the beginning. It should be called after SetPackageNames and before GenerateAllFiles.
func (*Generator) CommandLineParameters ¶
CommandLineParameters breaks the comma-separated list of key=value pairs in the parameter (a member of the request protobuf) into a key/value map. It then sets file name mappings defined by those entries.
func (*Generator) GenerateAllFiles ¶
func (g *Generator) GenerateAllFiles()
GenerateAllFiles generates the output for all the files we're outputting.
func (*Generator) ObjectNamed ¶ added in v0.2.3
ObjectNamed given fully-qualified input type name as it appears in the input data, returns the descriptor for the message or enum with that name
func (*Generator) P ¶
func (g *Generator) P(str ...interface{})
P prints the arguments to the generated output. It handles strings and int32s, plus handling indirections because they may be *string, etc. Any inputs of type AnnotatedAtoms may emit annotations in a .meta file in addition to outputting the atoms themselves (if g.annotateCode is true).
func (*Generator) PrintComments ¶
PrintComments prints any comments from the source .proto file. The path is a comma-separated list of integers. It returns an indication of whether any comments were printed. See descriptor.proto for its format.
func (*Generator) WrapTypes ¶
func (g *Generator) WrapTypes()
WrapTypes walks the incoming data, wrapping DescriptorProtos, EnumDescriptorProtos and FileDescriptorProtos into file-referenced objects within the Generator. It also creates the list of files to generate and so should be called before GenerateAllFiles.
type ImportedDescriptor ¶
type ImportedDescriptor struct {
// contains filtered or unexported fields
}
ImportedDescriptor describes a type that has been publicly imported from another file.
func (*ImportedDescriptor) File ¶
func (c *ImportedDescriptor) File() *FileDescriptor
func (*ImportedDescriptor) JavaImportPath ¶
func (c *ImportedDescriptor) JavaImportPath() JavaImportPath
JavaImportPath is the import path of the Java package containing the type.
func (*ImportedDescriptor) TypeName ¶
func (id *ImportedDescriptor) TypeName() []string
type JavaImportPath ¶
type JavaImportPath string
A JavaImportPath is the import path of a Java package. e.g., "com.google.genproto.protobuf".
func (JavaImportPath) String ¶
func (p JavaImportPath) String() string
type JavaPackageName ¶
type JavaPackageName string
A JavaPackageName is the name of a Java package. e.g., "com.google.protobuf".
type Object ¶
type Object interface { JavaImportPath() JavaImportPath TypeName() []string File() *FileDescriptor }
Object is an interface abstracting the abilities shared by enums, messages, extensions and imported objects.