operator [] method

MModel? operator [](
  1. MSchemaRef ref
)

Implementation

MModel? operator [](MSchemaRef ref) {
  final results = allResults.whereType<MModel>().where((_) => _.mtype == ref);
  if (results.isEmpty) {
    log.warning(
        "No result found with type ${ref.baseCode} ${allResults.isEmpty ? '(the results were empty)' : '- but we found ${allResults.map((_) => _.resultType)}'}");
    return null;
  } else if (results.length > 1) {
    return illegalState(
        "Found more than one result for ${ref.baseCode}, but found ${results.length}");
  } else {
    return results.first;
  }
}