when<R> method

R when<R>({
  1. required R ifPointGraphic(
    1. PointGraphic feature
    ),
  2. required R ifPolylineGraphic(
    1. PolylineGraphic feature
    ),
  3. required R ifPolygonGraphic(
    1. PolygonGraphic feature
    ),
})

Implementation

R when<R>({
  required R Function(PointGraphic feature) ifPointGraphic,
  required R Function(PolylineGraphic feature) ifPolylineGraphic,
  required R Function(PolygonGraphic feature) ifPolygonGraphic,
}) {
  final self = this;
  if (self is PointGraphic) {
    return ifPointGraphic(self);
  } else if (self is PolylineGraphic) {
    return ifPolylineGraphic(self);
  } else if (self is PolygonGraphic) {
    return ifPolygonGraphic(self);
  } else {
    throw Exception("Unknown graphic $self");
  }
}