valueOf static method

AutowireMode valueOf(
  1. String name
)

Returns the AutowireMode that matches the given name.

The name is case-insensitive. For example:

final mode = AutowireMode.valueOf("by_type");
print(mode == AutowireMode.BY_TYPE); // true

Throws an IllegalArgumentException if no matching mode exists.

Implementation

static AutowireMode valueOf(String name) {
  return switch (name.toLowerCase()) {
    'no' => NO,
    'by_name' => BY_NAME,
    'by_type' => BY_TYPE,
    _ => throw IllegalArgumentException('No AutowireMode with name $name')
  };
}