Package com.salesforce.jprotoc
Class Generator
java.lang.Object
com.salesforce.jprotoc.Generator
- Direct Known Subclasses:
InterfaceProtocPlugin
Generator is the base class for all protoc generators managed by
ProtocPlugin.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringapplyTemplate(String resourcePath, Object generatorContext) Executes a mustache template against a generatorContext object to generate an output string.Stream<com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File> generate(com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest request) Deprecated.List<com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File> generateFiles(com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest request) Processes a generator request into a set of files to output.protected com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.FileCreates a protobuf file message from a given name and content.protected com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.FileCreates a protobuf file message from a given name and content.protected List<com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.Feature> Signals to protoc which additional generator features this Generator supports.
-
Constructor Details
-
Generator
public Generator()
-
-
Method Details
-
generate
@Deprecated public Stream<com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File> generate(com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest request) throws GeneratorException Deprecated.usegenerateFiles(PluginProtos.CodeGeneratorRequest)and return a List instead of a Stream.Processes a generator request into a set of files to output.- Parameters:
request- The raw generator request from protoc.- Returns:
- The completed files to write out.
- Throws:
GeneratorException
-
generateFiles
public List<com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File> generateFiles(com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest request) throws GeneratorException Processes a generator request into a set of files to output.- Parameters:
request- The raw generator request from protoc.- Returns:
- The completed files to write out.
- Throws:
GeneratorException
-
supportedFeatures
protected List<com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.Feature> supportedFeatures()Signals to protoc which additional generator features this Generator supports. By default, this method returns FEATURE_NONE. You must override this method and supply a value, like FEATURE_PROTO3_OPTIONAL.- Returns:
- A list of enumerated features.
-
applyTemplate
Executes a mustache template against a generatorContext object to generate an output string.- Parameters:
resourcePath- Embedded resource template to use.generatorContext- Context object to bind the template to.- Returns:
- The string that results.
-
makeFile
protected com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File makeFile(String fileName, String fileContent) Creates a protobuf file message from a given name and content.- Parameters:
fileName- The name of the file to generate.fileContent- The content of the generated file.- Returns:
- The protobuf file.
-
makeFile
protected com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File makeFile(String fileName, byte[] fileContent) Creates a protobuf file message from a given name and content.- Parameters:
fileName- The name of the file to generate.fileContent- The content of the generated file.- Returns:
- The protobuf file.
-
generateFiles(PluginProtos.CodeGeneratorRequest)and return a List instead of a Stream.