fromJson static method

RiskLabelCoverage? fromJson(
  1. dynamic value
)

Returns a new RiskLabelCoverage instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static RiskLabelCoverage? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      requiredKeys.forEach((key) {
        assert(json.containsKey(key), 'Required key "RiskLabelCoverage[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "RiskLabelCoverage[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return RiskLabelCoverage(
      contested: mapValueOfType<int>(json, r'contested'),
      events: mapValueOfType<int>(json, r'events'),
      explore: num.parse('${json[r'explore']}'),
      facts: mapValueOfType<int>(json, r'facts'),
      from: mapValueOfType<String>(json, r'from'),
      horizon: mapValueOfType<int>(json, r'horizon'),
      judged: mapValueOfType<int>(json, r'judged'),
      matured: mapValueOfType<int>(json, r'matured'),
      pending: mapValueOfType<int>(json, r'pending'),
      productive: mapValueOfType<int>(json, r'productive'),
      sources: RiskSourceCoverage.listFromJson(json[r'sources']),
      to: mapValueOfType<String>(json, r'to'),
      unlabelled: mapValueOfType<int>(json, r'unlabelled'),
      unmatured: mapValueOfType<int>(json, r'unmatured'),
      unproductive: mapValueOfType<int>(json, r'unproductive'),
    );
  }
  return null;
}