equalsEntitiesIDs method

bool? equalsEntitiesIDs(
  1. Object? otherEntities
)

Implementation

bool? equalsEntitiesIDs(Object? otherEntities) {
  if (otherEntities == null) {
    return isNull;
  }

  if (identical(this, otherEntities)) {
    return true;
  }

  if (otherEntities is EntityReference) {
    if (type != otherEntities.type) return false;

    if (otherEntities.isNull) {
      return isNull;
    }

    if (otherEntities.isEntitySet &&
        isEntitiesSet &&
        _listIdenticalEquality.equals(entities, [otherEntities.entity])) {
      return true;
    }

    if (otherEntities.isIdSet) {
      if (isIDsSet) {
        return _idsEquality.equals(ids, [otherEntities.id]);
      } else {
        return false;
      }
    } else {
      if (isIDsSet) {
        return false;
      } else {
        return null;
      }
    }
  } else if (otherEntities is EntityReferenceList) {
    if (type != otherEntities.type) return false;

    if (otherEntities.isNull) {
      return isNull;
    }

    if (otherEntities.isEntitiesSet &&
        isEntitiesSet &&
        _listIdenticalEquality.equals(entities, otherEntities.entities)) {
      return true;
    }

    if (otherEntities.isIDsSet) {
      if (isIDsSet) {
        return _idsEquality.equals(ids, otherEntities.ids);
      } else {
        return false;
      }
    } else {
      if (isIDsSet) {
        return false;
      } else {
        return null;
      }
    }
  } else if (otherEntities is T) {
    if (isEntitiesSet &&
        _listIdenticalEquality.equals(entities, [otherEntities])) return true;

    var entityHandler = this.entityHandler;

    if (entityHandler != null) {
      var otherIDs = [_getEntityIDImpl(entityHandler, otherEntities as T)];
      return _idsEquality.equals(ids, otherIDs);
    }

    return null;
  } else if (otherEntities is List<T?>) {
    if (isEntitiesSet &&
        _listIdenticalEquality.equals(entities, otherEntities)) return true;

    var entityHandler = this.entityHandler;

    if (entityHandler != null) {
      var otherIDs = otherEntities
          .map((e) => _getEntityIDImpl(entityHandler, e as T))
          .toList();
      return _idsEquality.equals(ids, otherIDs);
    }

    return null;
  } else if (otherEntities is List &&
      otherEntities.every((Object? e) => e == null || e.isEntityIDType)) {
    return _idsEquality.equals(ids, otherEntities);
  } else {
    return null;
  }
}