getInstanceByClassId<TSubsystem extends Subsystem> method

TSubsystem getInstanceByClassId<TSubsystem extends Subsystem>(
  1. String classId
)

Retrieves an instance of this type by its classId.

Throws SubsystemNotFoundException if no instance with classId exists.

Implementation

TSubsystem getInstanceByClassId<TSubsystem extends Subsystem>(String classId) {
  final reg = getRegistry();
  final instance = reg.findByClassId(classId);
  if (instance == null) {
    throw SubsystemNotFoundException(
      'No instance found for class ID: $classId in type ID: $serviceTypeId',
      typeId: serviceTypeId,
      classId: classId,
    );
  }
  return instance as TSubsystem;
}