Removing values from Enums

14 views
Skip to first unread message

Abhay Garg

unread,
Jul 5, 2021, 5:25:57 AM7/5/21
to Protocol Buffers
Hi, 

When I print a proto class object it also includes values corresponding to the enums contained in it. e/g - 

message License {
  string license_name = 1;
  PrimaryLinkType primary_link_type = 4;
}

enum PrimaryLinkType {
  UNSPECIFIED = 0;
  SCRAPE_DIRECTLY = 1;
  SCRAPE_FROM_LOCAL_COPY = 2;
  SHOW_LINK_ONLY = 3;
  NEEDS_INTERVENTION = 4;
}

Now when I do this in my Kotlin program - 

val license = License
            .newBuilder()
            .setLicenseName("Some Licenses")
            .setPrimaryLinkType(PrimaryLinkType.SCRAPE_DIRECTLY)
            .build()
println(license)


Output - 

license_name: "Some License"
primary_link_type: SCRAPE_DIRECTLY
primary_link_value: 1


I don't want primary_link_value in the output, is there any way to configure it to not include value in the output?

Reply all
Reply to author
Forward
0 new messages