map<R> method

R map<R>({
  1. required ResponseMap<NodesIdGetResponse200, R> on200,
  2. required ResponseMap<NodesIdGetResponse404, R> on404,
  3. ResponseMap<NodesIdGetResponse, R>? onElse,
})

Implementation

R map<R>({
  required ResponseMap<NodesIdGetResponse200, R> on200,
  required ResponseMap<NodesIdGetResponse404, R> on404,
  ResponseMap<NodesIdGetResponse, R>? onElse,
}) {
  if (this is NodesIdGetResponse200) {
    return on200((this as NodesIdGetResponse200));
  } else if (this is NodesIdGetResponse404) {
    return on404((this as NodesIdGetResponse404));
  } else if (onElse != null) {
    return onElse(this);
  } else {
    throw StateError('Invalid instance of type $this');
  }
}