resolveID<V> method

V? resolveID<V>(
  1. Object? value
)

Implementation

V? resolveID<V>(Object? value) {
  if (value == null) return null;

  if (value is O) {
    return getID(value as O);
  } else if (value is Map) {
    return resolveIDFromMap(value);
  } else if (value is EntityReference) {
    var id = value.id;
    return id as V?;
  } else if (value is EntityReferenceList) {
    var ids = value.idsNotNull;
    var idsLng = ids.length;
    if (idsLng == 0) {
      return null;
    } else if (idsLng == 1) {
      var id = ids.first;
      return id as V?;
    } else {
      return null;
    }
  } else {
    var idType = this.idType();

    if (value.runtimeType == idType) {
      return value as V;
    }

    var idTypeInfo = TypeInfo.fromType(idType);
    return idTypeInfo.parse(value) as V?;
  }
}