ContextData.fromJson constructor

ContextData.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json
)

Implementation

factory ContextData.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    String name;
    if (json.containsKey('name')) {
      name = jsonDecoder.decodeString('$jsonPath.name', json['name']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'name');
    }
    int explicitFileCount;
    if (json.containsKey('explicitFileCount')) {
      explicitFileCount = jsonDecoder.decodeInt(
          '$jsonPath.explicitFileCount', json['explicitFileCount']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'explicitFileCount');
    }
    int implicitFileCount;
    if (json.containsKey('implicitFileCount')) {
      implicitFileCount = jsonDecoder.decodeInt(
          '$jsonPath.implicitFileCount', json['implicitFileCount']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'implicitFileCount');
    }
    int workItemQueueLength;
    if (json.containsKey('workItemQueueLength')) {
      workItemQueueLength = jsonDecoder.decodeInt(
          '$jsonPath.workItemQueueLength', json['workItemQueueLength']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'workItemQueueLength');
    }
    List<String> cacheEntryExceptions;
    if (json.containsKey('cacheEntryExceptions')) {
      cacheEntryExceptions = jsonDecoder.decodeList(
          '$jsonPath.cacheEntryExceptions',
          json['cacheEntryExceptions'],
          jsonDecoder.decodeString);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'cacheEntryExceptions');
    }
    return ContextData(name, explicitFileCount, implicitFileCount,
        workItemQueueLength, cacheEntryExceptions);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'ContextData', json);
  }
}