when<R> method
Implementation
// It takes a [Map] of [Enum]s to functions, and returns the result of
/// calling the function corresponding to the [Enum] of the object.
R when<R>(Map<Enum, R Function()> map) {
return map[this]!();
}