findSubModule method

Module? findSubModule(
  1. Pattern pattern
)

Searches for one sub-module matching pattern in the same way as findSubModules. If more than one module is found, an exception is thrown.

Implementation

Module? findSubModule(Pattern pattern) {
  final foundSubMods = findSubModules(pattern);
  final iter = foundSubMods.iterator;

  final firstFound = iter.moveNext() ? iter.current : null;
  final secondFound = iter.moveNext() ? iter.current : null;

  if (secondFound != null) {
    throw RohdBridgeException('More than one module found matching $pattern:'
        ' $firstFound and $secondFound');
  } else {
    return firstFound;
  }
}