Package com.salesforce.jprotoc
Class Generator
- java.lang.Object
-
- com.salesforce.jprotoc.Generator
-
- Direct Known Subclasses:
DumpGenerator,Jdk8Generator
public abstract class Generator extends Object
Generator is the base class for all protoc generators managed byProtocPlugin.
-
-
Constructor Summary
Constructors Constructor Description Generator()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected 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.usegenerateFiles(PluginProtos.CodeGeneratorRequest)and return a List instead of a Stream.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.FilemakeFile(String fileName, byte[] fileContent)Creates a protobuf file message from a given name and content.protected com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.FilemakeFile(String fileName, String fileContent)Creates a protobuf file message from a given name and content.protected List<com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.Feature>supportedFeatures()Signals to protoc which additional generator features this Generator supports.
-
-
-
Method Detail
-
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
protected String applyTemplate(@Nonnull String resourcePath, @Nonnull Object generatorContext)
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.
-
-