fromJson static method
Returns a new TarificationDto instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static TarificationDto? fromJson(dynamic value) {
if (value is TarificationDto) {
return 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 "TarificationDto[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "TarificationDto[$key]" has a null value in JSON.');
});
return true;
}());
return TarificationDto(
id: mapValueOfType<String>(json, r'id')!,
rev: mapValueOfType<String>(json, r'rev'),
deletionDate: mapValueOfType<int>(json, r'deletionDate'),
label: mapCastOfType<String, String>(json, r'label') ?? const {},
context: mapValueOfType<String>(json, r'context'),
type: mapValueOfType<String>(json, r'type'),
code: mapValueOfType<String>(json, r'code'),
version: mapValueOfType<String>(json, r'version'),
author: mapValueOfType<String>(json, r'author'),
regions: json[r'regions'] is Set
? (json[r'regions'] as Set).cast<String>()
: json[r'regions'] is List
? ((json[r'regions'] as List).toSet()).cast<String>()
: const {},
periodicity: PeriodicityDto.listFromJson(json[r'periodicity'])!,
level: mapValueOfType<int>(json, r'level'),
links: json[r'links'] is List ? (json[r'links'] as List).cast<String>() : const [],
qualifiedLinks: json[r'qualifiedLinks'] == null ? const {} : mapWithListOfStringsFromJson(json[r'qualifiedLinks']),
flags: CodeDtoFlagsEnum.listFromJson(json[r'flags'])!.toSet(),
searchTerms: json[r'searchTerms'] == null ? const {} : mapWithSetOfStringsFromJson(json[r'searchTerms']),
data: mapValueOfType<String>(json, r'data'),
appendices: mapCastOfType<String, String>(json, r'appendices')!,
disabled: mapValueOfType<bool>(json, r'disabled')!,
valorisations: ValorisationDto.listFromJson(json[r'valorisations'])!.toSet(),
category: mapCastOfType<String, String>(json, r'category')!,
consultationCode: mapValueOfType<bool>(json, r'consultationCode'),
hasRelatedCode: mapValueOfType<bool>(json, r'hasRelatedCode'),
needsPrescriber: mapValueOfType<bool>(json, r'needsPrescriber'),
relatedCodes: json[r'relatedCodes'] is Set
? (json[r'relatedCodes'] as Set).cast<String>()
: json[r'relatedCodes'] is List
? ((json[r'relatedCodes'] as List).toSet()).cast<String>()
: const {},
ngroup: mapValueOfType<String>(json, r'ngroup'),
letterValues: LetterValueDto.listFromJson(json[r'letterValues'])!,
);
}
return null;
}