Enums¶
An enum defines a fixed set of named values. In SimPaths, enums represent categories such as country, education level and labour-market status. They also identify scheduled processes and regressions.
A SimPaths example¶
The model uses simpaths.model.enums.Gender, whose categories are Male and Female. A minimal usage example is:
import simpaths.model.enums.Gender;
Gender category = Gender.Female;
boolean isFemale = category == Gender.Female;
This uses the existing enum; it does not create a new definition or describe every attribute of the Person entity. See the Gender source for its complete implementation.
Persistence and regression coding¶
Persisted enum fields in SimPaths use string-valued categories. For example, the ethnicity field in Person is declared as:
The initial-population parser maps input category codes to the enum names. Renaming a persisted category can make existing databases incompatible. Changing a category's meaning also requires checking the input parser, regressors and parameter workbooks.
Use the variable codebook and Introduce a New Variable guide before adding categories. The Java enum guide explains the language feature independently of SimPaths.