fromJson static method
Returns a new RiskModelState instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static RiskModelState? 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 "RiskModelState[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "RiskModelState[$key]" has a null value in JSON.');
});
return true;
}());
return RiskModelState(
aggregates: RiskAggregates.fromJson(json[r'aggregates']),
blind: mapCastOfType<String, int>(json, r'blind') ?? const {},
cut: num.parse('${json[r'cut']}'),
descends: mapValueOfType<String>(json, r'descends'),
disposed: mapValueOfType<int>(json, r'disposed'),
learned: mapValueOfType<int>(json, r'learned'),
live: mapValueOfType<bool>(json, r'live'),
policy: mapValueOfType<int>(json, r'policy'),
realised: num.parse('${json[r'realised']}'),
refused: mapCastOfType<String, int>(json, r'refused') ?? const {},
sample: num.parse('${json[r'sample']}'),
saturated: mapValueOfType<bool>(json, r'saturated'),
shape: mapValueOfType<String>(json, r'shape'),
stated: num.parse('${json[r'stated']}'),
surface: RiskSurface.fromJson(json[r'surface']),
tenant: mapValueOfType<String>(json, r'tenant'),
values: RiskModelValue.listFromJson(json[r'values']),
warm: mapValueOfType<bool>(json, r'warm'),
);
}
return null;
}