Class ProtoGenerator.Options
java.lang.Object
io.github.anupambasak.gradle.plugins.pojo2proto.ProtoGenerator.Options
- Enclosing class:
ProtoGenerator
Generation settings. Defaults reproduce the original behaviour: one shared proto package, no name suffix.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjavaPackageSuffix(String javaPackageSuffix) Appended to the Java package to formoption java_package, e.g.nameSuffix(String nameSuffix) Appended to the name of every generated top-level message and enum (and so to its file name):Address -> AddressProtoinAddressProto.proto.optionalFields(boolean optionalFields) Mark every singular fieldoptional(proto3 explicit presence), so an unset field can be told apart from one set to its default (0,false,"", first enum value) viahasX()andclearX().prefixEnumNames(boolean prefixEnumNames) Prefix enum values with the enum name in UPPER_SNAKE_CASE.sharedPackage(String sharedPackage) The proto package shared by all files whenusePojoPackagesis off; ignored with it.usePojoPackages(boolean usePojoPackages) Use each POJO's Java package as the protopackageand write its file into the matching directory (com.x.dtos.Address -> com/x/dtos/Address.proto).
-
Constructor Details
-
Options
public Options()
-
-
Method Details
-
prefixEnumNames
Prefix enum values with the enum name in UPPER_SNAKE_CASE. -
nameSuffix
Appended to the name of every generated top-level message and enum (and so to its file name):Address -> AddressProtoinAddressProto.proto. -
usePojoPackages
Use each POJO's Java package as the protopackageand write its file into the matching directory (com.x.dtos.Address -> com/x/dtos/Address.proto). -
javaPackageSuffix
Appended to the Java package to formoption java_package, e.g.".proto". WithusePojoPackagesit is part of the proto package and directory as well (com.x.dtos.Address -> com/x/dtos/proto/AddressProto.proto,package com.x.dtos.proto), so file location, proto package and java_package all match. With the shared package it only affectsjava_package. -
optionalFields
Mark every singular fieldoptional(proto3 explicit presence), so an unset field can be told apart from one set to its default (0,false,"", first enum value) viahasX()andclearX().repeatedandmapfields cannot be optional in protobuf and are left as is.
-