fromJson static method
Returns a new LicenseAttributes instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static LicenseAttributes? 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 "LicenseAttributes[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "LicenseAttributes[$key]" has a null value in JSON.');
});
return true;
}());
return LicenseAttributes(
name: mapValueOfType<String>(json, r'name'),
key: mapValueOfType<String>(json, r'key')!,
expiry: mapDateTime(json, r'expiry', r''),
status: LicenseAttributesStatusEnum.fromJson(json[r'status'])!,
uses: mapValueOfType<int>(json, r'uses')!,
protected: mapValueOfType<bool>(json, r'protected')!,
version: mapValueOfType<String>(json, r'version'),
suspended: mapValueOfType<bool>(json, r'suspended')!,
floating: mapValueOfType<bool>(json, r'floating')!,
scheme: LicenseAttributesSchemeEnum.fromJson(json[r'scheme']),
strict: mapValueOfType<bool>(json, r'strict')!,
maxMachines: mapValueOfType<int>(json, r'maxMachines'),
maxProcesses: mapValueOfType<int>(json, r'maxProcesses'),
maxCores: mapValueOfType<int>(json, r'maxCores'),
maxUses: mapValueOfType<int>(json, r'maxUses'),
requireHeartbeat: mapValueOfType<bool>(json, r'requireHeartbeat')!,
requireCheckIn: mapValueOfType<bool>(json, r'requireCheckIn')!,
lastValidated: mapDateTime(json, r'lastValidated', r''),
lastCheckOut: mapDateTime(json, r'lastCheckOut', r''),
lastCheckIn: mapDateTime(json, r'lastCheckIn', r''),
nextCheckIn: mapDateTime(json, r'nextCheckIn', r''),
metadata: mapCastOfType<String, Object>(json, r'metadata')!,
created: mapDateTime(json, r'created', r'')!,
updated: mapDateTime(json, r'updated', r'')!,
);
}
return null;
}