parse method

T parse(
  1. String value
)

Parses the given value and returns the corresponding enumeration value.

The value should be a string representation of one of the enumeration values. If the value does not match any of the enumeration values, an exception is thrown.

@param value The string value to parse into an enum value. @returns The corresponding enum value. @throws AssertionError if value is empty in debug mode. @throws ArgumentError if the value does not match any enum value.

Implementation

T parse(String value) {
  assert(value.isNotEmpty, 'Value to parse cannot be empty');
  return values.byName(value);
}