AnalysisUpdateContentParams.fromJson constructor

AnalysisUpdateContentParams.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json, {
  4. ClientUriConverter? clientUriConverter,
})

Implementation

factory AnalysisUpdateContentParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'analysis.updateContent params'",
      json,
    );
  }
  Map<String, Object> files;
  if (json case {'files': var encodedFiles}) {
    files = jsonDecoder.decodeMap(
      '$jsonPath.files',
      encodedFiles,
      keyDecoder: (String jsonPath, Object? json) =>
          clientUriConverter?.fromClientFilePath(
            jsonDecoder.decodeString(jsonPath, json),
          ) ??
          jsonDecoder.decodeString(jsonPath, json),
      valueDecoder: (String jsonPath, Object? json) =>
          jsonDecoder.decodeUnion(jsonPath, json, 'type', {
            'add': (String jsonPath, Object? json) =>
                AddContentOverlay.fromJson(
                  jsonDecoder,
                  jsonPath,
                  json,
                  clientUriConverter: clientUriConverter,
                ),
            'change': (String jsonPath, Object? json) =>
                ChangeContentOverlay.fromJson(
                  jsonDecoder,
                  jsonPath,
                  json,
                  clientUriConverter: clientUriConverter,
                ),
            'remove': (String jsonPath, Object? json) =>
                RemoveContentOverlay.fromJson(
                  jsonDecoder,
                  jsonPath,
                  json,
                  clientUriConverter: clientUriConverter,
                ),
          }),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'files'", json);
  }
  return AnalysisUpdateContentParams(files);
}