match<T> method

T match<T>({
  1. required T bicycle(
    1. BicycleRouteSearchOptions value
    ),
  2. required T car(
    1. CarRouteSearchOptions value
    ),
  3. required T pedestrian(
    1. PedestrianRouteSearchOptions value
    ),
  4. required T publicTransport(
    1. PublicTransportRouteSearchOptions value
    ),
  5. required T scooter(
    1. ScooterRouteSearchOptions value
    ),
  6. required T taxi(
    1. TaxiRouteSearchOptions value
    ),
  7. required T truck(
    1. TruckRouteSearchOptions value
    ),
})

Implementation

T match<T>({
  required T Function(BicycleRouteSearchOptions value) bicycle,
  required T Function(CarRouteSearchOptions value) car,
  required T Function(PedestrianRouteSearchOptions value) pedestrian,
  required T Function(PublicTransportRouteSearchOptions value) publicTransport,
  required T Function(ScooterRouteSearchOptions value) scooter,
  required T Function(TaxiRouteSearchOptions value) taxi,
  required T Function(TruckRouteSearchOptions value) truck,
}) {
  return switch (this._index) {
    0 => bicycle(this._value as BicycleRouteSearchOptions),
    1 => car(this._value as CarRouteSearchOptions),
    2 => pedestrian(this._value as PedestrianRouteSearchOptions),
    3 => publicTransport(this._value as PublicTransportRouteSearchOptions),
    4 => scooter(this._value as ScooterRouteSearchOptions),
    5 => taxi(this._value as TaxiRouteSearchOptions),
    6 => truck(this._value as TruckRouteSearchOptions),
    _ => throw NativeException("Unrecognized case index ${this._index}")
  };
}