fromJson static method

EventMetadata? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static EventMetadata? 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 "EventMetadata[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "EventMetadata[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return EventMetadata(
      id: mapValueOfType<int>(json, r'id'),
      eventType: EventMetadataEventTypeEnum.fromJson(json[r'eventType']),
      representationType: mapValueOfType<String>(json, r'representationType'),
      objectType: mapValueOfType<String>(json, r'objectType'),
      objectTypeMapped: EventMetadataObjectTypeMappedEnum.fromJson(json[r'objectTypeMapped']),
      objectId: mapValueOfType<int>(json, r'objectId'),
      objectVersion: mapValueOfType<int>(json, r'objectVersion'),
      otherObjectType: mapValueOfType<String>(json, r'otherObjectType'),
      otherObjectTypeMapped: EventMetadataOtherObjectTypeMappedEnum.fromJson(json[r'otherObjectTypeMapped']),
      otherObjectId: mapValueOfType<int>(json, r'otherObjectId'),
      context: mapValueOfType<String>(json, r'context'),
      subjectName: mapValueOfType<String>(json, r'subjectName'),
      created: mapDateTime(json, r'created', r''),
      received: mapDateTime(json, r'received', r''),
      effectiveDateTime: mapDateTime(json, r'effectiveDateTime', r''),
    );
  }
  return null;
}