equalsEntityID method

bool? equalsEntityID(
  1. Object? otherEntity
)

Implementation

bool? equalsEntityID(Object? otherEntity) {
  if (otherEntity == null) {
    return isNull;
  }

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

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

    if (otherEntity.isNull) {
      return isNull;
    }

    if (otherEntity.isEntitySet &&
        isEntitySet &&
        identical(entity, otherEntity.entity)) {
      return true;
    }

    if (otherEntity.isIdSet) {
      if (isIdSet) {
        return id == otherEntity.id;
      } else {
        return false;
      }
    } else {
      if (isIdSet) {
        return false;
      } else {
        return null;
      }
    }
  } else if (otherEntity is T) {
    if (isEntitySet && identical(entity, otherEntity)) return true;

    var entityHandler = this.entityHandler;

    if (entityHandler != null) {
      var otherId = _getEntityIDImpl(entityHandler, otherEntity as T);
      return id == otherId;
    }

    return null;
  } else if (otherEntity.isEntityIDType) {
    return id == otherEntity;
  } else {
    return null;
  }
}