First time here? Check out the Help page!
The general implementation is described here, see the section starting "Field Getters and Setters", particularly "Choice Fields".
Generally, whether an Optional is returned is based on the corresponding EnergyPlus idd field type.