fromJson static method

CaptableOptionIn? fromJson(
  1. dynamic value
)

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

Implementation

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

    return CaptableOptionIn(
      boardApprovalDate: mapValueOfType<Object>(json, r'boardApprovalDate'),
      cliffYears: mapValueOfType<Object>(json, r'cliffYears'),
      equityPlanId: mapValueOfType<Object>(json, r'equityPlanId'),
      exercisePrice: mapValueOfType<Object>(json, r'exercisePrice'),
      expirationDate: mapValueOfType<Object>(json, r'expirationDate'),
      grantId: mapValueOfType<Object>(json, r'grantId'),
      issueDate: mapValueOfType<Object>(json, r'issueDate'),
      notes: mapValueOfType<Object>(json, r'notes'),
      quantity: mapValueOfType<Object>(json, r'quantity'),
      rule144Date: mapValueOfType<Object>(json, r'rule144Date'),
      stakeholderId: mapValueOfType<Object>(json, r'stakeholderId'),
      status: mapValueOfType<Object>(json, r'status'),
      type: mapValueOfType<Object>(json, r'type'),
      vestingStartDate: mapValueOfType<Object>(json, r'vestingStartDate'),
      vestingYears: mapValueOfType<Object>(json, r'vestingYears'),
    );
  }
  return null;
}