when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>({
  1. required TResult read(
    1. Uri base,
    2. R5ResourceType type,
    3. String fhirId,
    4. bool? pretty,
    5. Summary summary,
    6. String? format,
    7. List<String> elements,
    8. List<String> parameters,
    9. MimeType? mimeType,
    10. String accept,
    11. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    12. Map<String, String>? headers,
    ),
  2. required TResult vRead(
    1. Uri base,
    2. R5ResourceType type,
    3. String fhirId,
    4. FhirId vid,
    5. bool? pretty,
    6. Summary summary,
    7. String? format,
    8. List<String> elements,
    9. List<String> parameters,
    10. MimeType? mimeType,
    11. String accept,
    12. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    13. Map<String, String>? headers,
    ),
  3. required TResult update(
    1. Uri base,
    2. Resource resource,
    3. bool? pretty,
    4. Summary summary,
    5. String? format,
    6. List<String> elements,
    7. List<String> parameters,
    8. MimeType? mimeType,
    9. String accept,
    10. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    11. Map<String, String>? headers,
    ),
  4. required TResult patch(
    1. Uri base,
    2. Resource resource,
    3. bool? pretty,
    4. Summary summary,
    5. String? format,
    6. List<String> elements,
    7. List<String> parameters,
    8. MimeType? mimeType,
    9. String accept,
    10. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    11. Map<String, String>? headers,
    ),
  5. required TResult delete(
    1. Uri base,
    2. R5ResourceType type,
    3. String fhirId,
    4. bool? pretty,
    5. Summary summary,
    6. String? format,
    7. List<String> elements,
    8. List<String> parameters,
    9. MimeType? mimeType,
    10. String accept,
    11. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    12. Map<String, String>? headers,
    ),
  6. required TResult create(
    1. Uri base,
    2. Resource resource,
    3. bool? pretty,
    4. Summary summary,
    5. String? format,
    6. List<String> elements,
    7. List<String> parameters,
    8. MimeType? mimeType,
    9. String accept,
    10. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    11. Map<String, String>? headers,
    ),
  7. required TResult search(
    1. Uri base,
    2. R5ResourceType type,
    3. bool? pretty,
    4. Summary summary,
    5. String? format,
    6. List<String> elements,
    7. List<String> parameters,
    8. bool usePost,
    9. RestfulRequest restfulRequest,
    10. MimeType? mimeType,
    11. String accept,
    12. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    13. Map<String, String>? headers,
    ),
  8. required TResult searchAll(
    1. Uri base,
    2. bool? pretty,
    3. Summary summary,
    4. String? format,
    5. List<String> elements,
    6. List<String> parameters,
    7. MimeType? mimeType,
    8. String accept,
    9. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    10. Map<String, String>? headers,
    ),
  9. required TResult capabilities(
    1. Uri base,
    2. bool? pretty,
    3. Summary summary,
    4. String? format,
    5. List<String> elements,
    6. List<String> parameters,
    7. Mode mode,
    8. MimeType? mimeType,
    9. String accept,
    10. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    11. Map<String, String>? headers,
    ),
  10. required TResult transaction(
    1. Uri base,
    2. bool? pretty,
    3. Summary summary,
    4. String? format,
    5. List<String> elements,
    6. List<String> parameters,
    7. Bundle bundle,
    8. MimeType? mimeType,
    9. String accept,
    10. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    11. Map<String, String>? headers,
    ),
  11. required TResult batch(
    1. Uri base,
    2. bool? pretty,
    3. Summary summary,
    4. String? format,
    5. List<String> elements,
    6. List<String> parameters,
    7. Bundle bundle,
    8. MimeType? mimeType,
    9. String accept,
    10. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    11. Map<String, String>? headers,
    ),
  12. required TResult history(
    1. Uri base,
    2. R5ResourceType type,
    3. String fhirId,
    4. bool? pretty,
    5. Summary summary,
    6. String? format,
    7. List<String> elements,
    8. List<String> parameters,
    9. int? count,
    10. FhirInstant? since,
    11. FhirDateTime? at,
    12. String? reference,
    13. MimeType? mimeType,
    14. String accept,
    15. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    16. Map<String, String>? headers,
    ),
  13. required TResult historyType(
    1. Uri base,
    2. R5ResourceType type,
    3. bool? pretty,
    4. Summary summary,
    5. String? format,
    6. List<String> elements,
    7. List<String> parameters,
    8. int? count,
    9. FhirInstant? since,
    10. FhirDateTime? at,
    11. String? reference,
    12. MimeType? mimeType,
    13. String accept,
    14. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    15. Map<String, String>? headers,
    ),
  14. required TResult historyAll(
    1. Uri base,
    2. bool? pretty,
    3. Summary summary,
    4. String? format,
    5. List<String> elements,
    6. List<String> parameters,
    7. int? count,
    8. FhirInstant? since,
    9. FhirDateTime? at,
    10. String? reference,
    11. MimeType? mimeType,
    12. String accept,
    13. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    14. Map<String, String>? headers,
    ),
  15. required TResult operation(
    1. Uri base,
    2. R5ResourceType? type,
    3. String? fhirId,
    4. bool? pretty,
    5. Summary summary,
    6. String? format,
    7. List<String> elements,
    8. List<String> parameters,
    9. Parameters? fhirParameter,
    10. String operation,
    11. bool usePost,
    12. bool useFormData,
    13. MimeType? mimeType,
    14. String accept,
    15. @JsonKey.new(includeFromJson: false, includeToJson: false) Client? client,
    16. Map<String, String>? headers,
    ),
})

A switch-like method, using callbacks.

As opposed to map, this offers destructuring. It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case Subclass2(:final field2):
    return ...;
}

Implementation

@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function( Uri base,  R5ResourceType type,  String fhirId,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  read,required TResult Function( Uri base,  R5ResourceType type,  String fhirId,  FhirId vid,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  vRead,required TResult Function( Uri base,  Resource resource,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  update,required TResult Function( Uri base,  Resource resource,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  patch,required TResult Function( Uri base,  R5ResourceType type,  String fhirId,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  delete,required TResult Function( Uri base,  Resource resource,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  create,required TResult Function( Uri base,  R5ResourceType type,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  bool usePost,  RestfulRequest restfulRequest,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  search,required TResult Function( Uri base,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  searchAll,required TResult Function( Uri base,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  Mode mode,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  capabilities,required TResult Function( Uri base,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  Bundle bundle,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  transaction,required TResult Function( Uri base,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  Bundle bundle,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  batch,required TResult Function( Uri base,  R5ResourceType type,  String fhirId,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  int? count,  FhirInstant? since,  FhirDateTime? at,  String? reference,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  history,required TResult Function( Uri base,  R5ResourceType type,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  int? count,  FhirInstant? since,  FhirDateTime? at,  String? reference,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  historyType,required TResult Function( Uri base,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  int? count,  FhirInstant? since,  FhirDateTime? at,  String? reference,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  historyAll,required TResult Function( Uri base,  R5ResourceType? type,  String? fhirId,  bool? pretty,  Summary summary,  String? format,  List<String> elements,  List<String> parameters,  Parameters? fhirParameter,  String operation,  bool usePost,  bool useFormData,  MimeType? mimeType,  String accept, @JsonKey(includeFromJson: false, includeToJson: false)  Client? client,  Map<String, String>? headers)  operation,}) {final _that = this;
switch (_that) {
case FhirReadRequest():
return read(_that.base,_that.type,_that.fhirId,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirVReadRequest():
return vRead(_that.base,_that.type,_that.fhirId,_that.vid,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirUpdateRequest():
return update(_that.base,_that.resource,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirPatchRequest():
return patch(_that.base,_that.resource,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirDeleteRequest():
return delete(_that.base,_that.type,_that.fhirId,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirCreateRequest():
return create(_that.base,_that.resource,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirSearchRequest():
return search(_that.base,_that.type,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.usePost,_that.restfulRequest,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirSearchAllRequest():
return searchAll(_that.base,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirCapabilitiesRequest():
return capabilities(_that.base,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.mode,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirTransactionRequest():
return transaction(_that.base,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.bundle,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirBatchRequest():
return batch(_that.base,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.bundle,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirHistoryRequest():
return history(_that.base,_that.type,_that.fhirId,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.count,_that.since,_that.at,_that.reference,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirHistoryTypeRequest():
return historyType(_that.base,_that.type,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.count,_that.since,_that.at,_that.reference,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirHistoryAllRequest():
return historyAll(_that.base,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.count,_that.since,_that.at,_that.reference,_that.mimeType,_that.accept,_that.client,_that.headers);case FhirOperationRequest():
return operation(_that.base,_that.type,_that.fhirId,_that.pretty,_that.summary,_that.format,_that.elements,_that.parameters,_that.fhirParameter,_that.operation,_that.usePost,_that.useFormData,_that.mimeType,_that.accept,_that.client,_that.headers);}
}