getTriggerExecutor function Null safety

TriggerExecutor getTriggerExecutor(
  1. Trigger trigger
)

Returns the relevant TriggerExecutor based on the type of trigger.

Implementation

TriggerExecutor getTriggerExecutor(Trigger trigger) {
  switch (trigger.runtimeType) {
    case ImmediateTrigger:
      return ImmediateTriggerExecutor(trigger);
    case DelayedTrigger:
      return DelayedTriggerExecutor(trigger as DelayedTrigger);
    case DeploymentDelayedTrigger:
      return DeploymentDelayedTriggerExecutor(
          trigger as DeploymentDelayedTrigger);
    case ElapsedTimeTrigger:
      return ElapsedTimeTriggerExecutor(trigger as ElapsedTimeTrigger);
    case PeriodicTrigger:
      return PeriodicTriggerExecutor(trigger as PeriodicTrigger);
    case DateTimeTrigger:
      return DateTimeTriggerExecutor(trigger as DateTimeTrigger);
    case RecurrentScheduledTrigger:
      return RecurrentScheduledTriggerExecutor(
          trigger as RecurrentScheduledTrigger);
    case CronScheduledTrigger:
      return CronScheduledTriggerExecutor(trigger as CronScheduledTrigger);
    case SamplingEventTrigger:
      return SamplingEventTriggerExecutor(trigger as SamplingEventTrigger);
    case ConditionalSamplingEventTrigger:
      return ConditionalSamplingEventTriggerExecutor(
          trigger as ConditionalSamplingEventTrigger);
    case RandomRecurrentTrigger:
      return RandomRecurrentTriggerExecutor(trigger as RandomRecurrentTrigger);
    case PassiveTrigger:
      return PassiveTriggerExecutor(trigger as PassiveTrigger);
    default:
      warning(
          "Unknown trigger used - cannot find a TriggerExecutor for the trigger of type '${trigger.runtimeType}'. Using an 'ImmediateTriggerExecutor' instead.");
      return ImmediateTriggerExecutor(trigger);
  }
}