Class ProtoGenerator
java.lang.Object
io.github.anupambasak.gradle.plugins.pojo2proto.ProtoGenerator
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA generated message wrapping a repeated field, used where protobuf does not allowrepeated: as a map value (Map<String, List<MyPojo>>) or as the element of another list (List<List<MyPojo>>). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateEnum(com.github.javaparser.ast.body.EnumDeclaration enumDeclaration) generateEnums(List<com.github.javaparser.ast.body.EnumDeclaration> enumDeclarations) generateHeader(String packageName, Set<String> imports) generateMessage(com.github.javaparser.ast.CompilationUnit cu, List<com.github.javaparser.ast.body.EnumDeclaration> enumDeclarations) generateMessages(List<com.github.javaparser.ast.CompilationUnit> cus, List<com.github.javaparser.ast.body.EnumDeclaration> enumDeclarations) generateMessageWithNestedEnums(com.github.javaparser.ast.CompilationUnit cu, List<com.github.javaparser.ast.body.EnumDeclaration> nestedEnums, List<com.github.javaparser.ast.body.EnumDeclaration> allEnums) getImports(com.github.javaparser.ast.CompilationUnit cu, List<com.github.javaparser.ast.body.EnumDeclaration> enumDeclarations) The wrapper messages to generate as top-level messages (their own files in multi-file mode).protoName(com.github.javaparser.ast.body.TypeDeclaration<?> type) The proto name of a top-level type: its Java name unlessregisterTypes(List)renamed it.All proto names of the registered top-level types.registerTypes(List<com.github.javaparser.ast.CompilationUnit> cus) Registers every top-level type that will be generated and assigns its proto name.
-
Constructor Details
-
ProtoGenerator
public ProtoGenerator() -
ProtoGenerator
public ProtoGenerator(boolean prefixEnumNames)
-
-
Method Details
-
registerTypes
Registers every top-level type that will be generated and assigns its proto name.All generated types share one proto package, and generated file names and Java classes clash on case-insensitive file systems (Windows, macOS). So when two types have names that differ only in case (
FareDetailDTO/FareDetailDto) or are equal (Statusin two packages), each of them is renamed by prefixing its Java package's last segment in PascalCase (com.x.pricing.FareDetailDTO -> PricingFareDetailDTO). More segments are used if that is still ambiguous. Types without a clash keep their name. References, imports and file names follow the new names.- Returns:
- renamed types, fully qualified Java name to proto name
-
protoName
The proto name of a top-level type: its Java name unlessregisterTypes(List)renamed it. -
registeredProtoNames
-
generateHeader
-
generateMessages
-
generateMessage
-
generateMessageWithNestedEnums
-
generateEnums
-
generateEnum
-
getImports
-
getTopLevelWrappers
The wrapper messages to generate as top-level messages (their own files in multi-file mode). -
generateWrapperMessage
-