match<T> method

T match<T>({
  1. required T bicycleStart(
    1. BicycleInstructionStart value
    ),
  2. required T bicycleFinish(
    1. BicycleInstructionFinish value
    ),
  3. required T bicycleCrossroad(
    1. BicycleInstructionCrossroad value
    ),
  4. required T carStart(
    1. CarInstructionStart value
    ),
  5. required T carFinish(
    1. CarInstructionFinish value
    ),
  6. required T carCrossroad(
    1. CarInstructionCrossroad value
    ),
  7. required T carRoundabout(
    1. CarInstructionRoundabout value
    ),
  8. required T carUturn(
    1. CarInstructionUTurn value
    ),
  9. required T pedestrianStart(
    1. PedestrianInstructionStart value
    ),
  10. required T pedestrianFinish(
    1. PedestrianInstructionFinish value
    ),
  11. required T pedestrianCrossroad(
    1. PedestrianInstructionCrossroad value
    ),
  12. required T pedestrianIndoorFloorChange(
    1. PedestrianInstructionIndoorFloorChange value
    ),
  13. required T pedestrianIndoorEnter(
    1. PedestrianInstructionIndoorEnter value
    ),
  14. required T pedestrianIndoorExit(
    1. PedestrianInstructionIndoorExit value
    ),
  15. required T scooterStart(
    1. ScooterInstructionStart value
    ),
  16. required T scooterFinish(
    1. ScooterInstructionFinish value
    ),
  17. required T scooterCrossroad(
    1. ScooterInstructionCrossroad value
    ),
})

Implementation

T match<T>({
  required T Function(BicycleInstructionStart value) bicycleStart,
  required T Function(BicycleInstructionFinish value) bicycleFinish,
  required T Function(BicycleInstructionCrossroad value) bicycleCrossroad,
  required T Function(CarInstructionStart value) carStart,
  required T Function(CarInstructionFinish value) carFinish,
  required T Function(CarInstructionCrossroad value) carCrossroad,
  required T Function(CarInstructionRoundabout value) carRoundabout,
  required T Function(CarInstructionUTurn value) carUturn,
  required T Function(PedestrianInstructionStart value) pedestrianStart,
  required T Function(PedestrianInstructionFinish value) pedestrianFinish,
  required T Function(PedestrianInstructionCrossroad value) pedestrianCrossroad,
  required T Function(PedestrianInstructionIndoorFloorChange value) pedestrianIndoorFloorChange,
  required T Function(PedestrianInstructionIndoorEnter value) pedestrianIndoorEnter,
  required T Function(PedestrianInstructionIndoorExit value) pedestrianIndoorExit,
  required T Function(ScooterInstructionStart value) scooterStart,
  required T Function(ScooterInstructionFinish value) scooterFinish,
  required T Function(ScooterInstructionCrossroad value) scooterCrossroad,
}) {
  return switch (this._index) {
    0 => bicycleStart(this._value as BicycleInstructionStart),
    1 => bicycleFinish(this._value as BicycleInstructionFinish),
    2 => bicycleCrossroad(this._value as BicycleInstructionCrossroad),
    3 => carStart(this._value as CarInstructionStart),
    4 => carFinish(this._value as CarInstructionFinish),
    5 => carCrossroad(this._value as CarInstructionCrossroad),
    6 => carRoundabout(this._value as CarInstructionRoundabout),
    7 => carUturn(this._value as CarInstructionUTurn),
    8 => pedestrianStart(this._value as PedestrianInstructionStart),
    9 => pedestrianFinish(this._value as PedestrianInstructionFinish),
    10 => pedestrianCrossroad(this._value as PedestrianInstructionCrossroad),
    11 => pedestrianIndoorFloorChange(this._value as PedestrianInstructionIndoorFloorChange),
    12 => pedestrianIndoorEnter(this._value as PedestrianInstructionIndoorEnter),
    13 => pedestrianIndoorExit(this._value as PedestrianInstructionIndoorExit),
    14 => scooterStart(this._value as ScooterInstructionStart),
    15 => scooterFinish(this._value as ScooterInstructionFinish),
    16 => scooterCrossroad(this._value as ScooterInstructionCrossroad),
    _ => throw NativeException("Unrecognized case index ${this._index}")
  };
}