Enum
This guide demonstrates basics of enum type.
On this page
Enum value
The tableau parser accepts three enum value forms:
- enum value name.
- enum value number.
- enum value alias. It is another name in English, Chinese, or any other language, which can be specified by tableau.evalue by extending google.protobuf.EnumValueOptions.
For example, enum type FruitType
in common.proto
is defined as:
enum FruitType {
FRUIT_TYPE_UNKNOWN = 0 [(tableau.evalue).name = "Unknown"];
FRUIT_TYPE_APPLE = 1 [(tableau.evalue).name = "Apple"];
FRUIT_TYPE_ORANGE = 2 [(tableau.evalue).name = "Orange"];
FRUIT_TYPE_BANANA = 3 [(tableau.evalue).name = "Banana"];
}
Then the three forms of enum value are all accepted:
Enum value number | Enum value name | Enum value alias |
---|---|---|
0 | FRUIT_TYPE_UNKNOWN | Unknown |
1 | FRUIT_TYPE_APPLE | Apple |
2 | FRUIT_TYPE_ORANGE | Orange |
3 | FRUIT_TYPE_BANANA | Banana |
NOTE: Enum type must be predefined.
Go to read details about predefiend Enum type: Predefined types â.
Validation
As enum type is predefined, so the tableau parser will auto validate the enum value.