I have a protobuf enum like
enum MyEnum {
A = 0;
B = 1;
C = 2;
}
At runtime, I want to loop over all possible values for the enum like this:
MyEnum().uniqueValues.forEach(println)
How might I do this with scalapb or just in scala?
I have a protobuf enum like
enum MyEnum {
A = 0;
B = 1;
C = 2;
}
At runtime, I want to loop over all possible values for the enum like this:
MyEnum().uniqueValues.forEach(println)
How might I do this with scalapb or just in scala?
Copyright © 2021 Jogjafile Inc.
if you use scalapb with default settings, a following protobuf enumeration type
will be converted into an abstract class with a companion object
And the companion object
MyEnum
will be providing methodvalues
you needSo, you can access it via
MyEnum.values
or viaMyEnum.A.companion.values