Interface Generator
- All Known Implementing Classes:
CodecGenerator, JsonCodecGenerator, ModelGenerator, SchemaGenerator, TestGenerator
public interface Generator
Interface for a code generator from protobuf message definition
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Map<Class<? extends Generator>, Function<FileSetWriter, JavaFileWriter>> All generators. -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerate(Protobuf3Parser.MessageDefContext msgDef, JavaFileWriter writer, ContextualLookupHelper lookupHelper) Generate a code from protobuf message typestatic booleanA utility method to check if a type being generated is an inner message or not.
-
Field Details
-
GENERATORS
All generators.
-
-
Method Details
-
generate
void generate(Protobuf3Parser.MessageDefContext msgDef, JavaFileWriter writer, ContextualLookupHelper lookupHelper) throws IOException Generate a code from protobuf message type- Parameters:
msgDef- the parsed messagelookupHelper- Lookup helper for global context lookups- Throws:
IOException- if there was a problem writing generated code
-
isInner
A utility method to check if a type being generated is an inner message or not. The result returned by this method should only affect minor details of the generated code, such as whether to add a `static` modifier to the class definition and similar. The result MUST NOT be used to choose whether to actually inline the type definition or go and create physical files on disk with an actual top-level type definition. This method is NOT SUPPOSED to help make such decisions. A Generator implementation MUST NEVER create new files for top-level types generation on its own. The Generator MUST emit all generated code into a given JavaFileWriter instance and let it (and its owner) decide where the output should go.- Parameters:
msgDef- a MessageDefContext object- Returns:
- true if the given MessageDefContext is nested inside an outer MessageDefContext
-