Enum

This guide demonstrates basics of enum type.

Enum value

The tableau parser accepts three enum value forms:

  1. enum value name.
  2. enum value number.
  3. 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 numberEnum value nameEnum value alias
0FRUIT_TYPE_UNKNOWNUnknown
1FRUIT_TYPE_APPLEApple
2FRUIT_TYPE_ORANGEOrange
3FRUIT_TYPE_BANANABanana

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.