Typekeys and typelists

Many Guidewire entity data model entities contain properties that contain typekeys. A typekey is similar to an enumeration. A typelist encapsulates a list of typekeys. Each typekey has a unique immutable code as a String, in addition to a user-readable (and localized) name. The code for a typekey is also known as a typecode.

For example, the typelist called AddressType contains typekey values BUSINESS, HOME, and OTHER, which are available as constants on the typelist type with some changes to the name.

Typelist Literals

In most cases, to get a literal for a typelist, you can type the typelist name in the appropriate programming context. Ambiguity about the name or package of the typelist might occur in some programming contexts. To resolve this ambiguity, type the fully qualified syntax typekey.TYPELISTNAME. For example, typekey.AddressType.

Typecode Literals

To reference an existing typecode from Gosu, access the typecode by using the typelist name and the typecode value in capital letters and the prefix TC_:

TYPELISTNAME.TC_TYPECODENAME

For example, to select from the AddressType typelist a reference to the typekey with code BUSINESS, use:

AddressType.TC_BUSINESS

In the data model configuration, the typecode definition has an optional identifierCode attribute, which changes how the application generates the programmatic typekey name in Gosu. The value of the identifierCode attribute can include only characters that are valid for a Gosu identifier such as a class or variable name. For example, you cannot include a hyphen (-) character in the value of the identifierCode attribute. The maximum length of the identifier code value is three characters fewer than the maximum length of a Gosu identifier name. For practical purposes, this length is unlimited.

PolicyCenter uses the following rules to generate the typecode literal:

  • If the optional identifierCode attribute exists, PolicyCenter transforms the identifierCode attribute to upper case, and adds the prefix TC_. Using the identifierCode attribute ensures that all identifier names are unique, which prevents name conflicts among typecode literals.
  • If the identifierCode attribute does not exist for a typecode, PolicyCenter generates the typecode literal from the code attribute. PolicyCenter transforms the code attribute to upper case, replaces invalid characters with underscores (_), and adds the prefix TC_. For example, codes abc, 123, and a-b become the identifiers TC_ABC, TC_123, and TC_A_B, respectively. The substitution of invalid characters by underscores might cause two codes to become the same identifier. For example, codes A_B and A-B both become TC_A_B, which is a conflict that causes compilation errors.