match<T> method

T match<T>({
  1. required T bicycle(
    1. BicycleBriefRouteInfo value
    ),
  2. required T car(
    1. CarBriefRouteInfo value
    ),
  3. required T pedestrian(
    1. PedestrianBriefRouteInfo value
    ),
  4. required T publicTransport(
    1. PublicBriefRouteInfo value
    ),
  5. required T scooter(
    1. ScooterBriefRouteInfo value
    ),
})

Implementation

T match<T>({
  required T Function(BicycleBriefRouteInfo value) bicycle,
  required T Function(CarBriefRouteInfo value) car,
  required T Function(PedestrianBriefRouteInfo value) pedestrian,
  required T Function(PublicBriefRouteInfo value) publicTransport,
  required T Function(ScooterBriefRouteInfo value) scooter,
}) {
  return switch (this._index) {
    0 => bicycle(this._value as BicycleBriefRouteInfo),
    1 => car(this._value as CarBriefRouteInfo),
    2 => pedestrian(this._value as PedestrianBriefRouteInfo),
    3 => publicTransport(this._value as PublicBriefRouteInfo),
    4 => scooter(this._value as ScooterBriefRouteInfo),
    _ => throw NativeException("Unrecognized case index ${this._index}")
  };
}