private void maybeSetIndexOfDataSourceWithResult(
        int index, DataSource<T> dataSource, boolean isFinished) {
      int oldIndexOfDataSourceWithResult;
      int newIndexOfDataSourceWithResult;
      synchronized (IncreasingQualityDataSource.this) {
        oldIndexOfDataSourceWithResult = mIndexOfDataSourceWithResult;
        newIndexOfDataSourceWithResult = mIndexOfDataSourceWithResult;
        if (dataSource != getDataSource(index) || index == mIndexOfDataSourceWithResult) {
          return;
        }
        // If we didn't have any result so far, we got one now, so we'll set
        // {@code mIndexOfDataSourceWithResult} to point to the data source with result.
        // If we did have a result which came from another data source,
        // we'll only set {@code mIndexOfDataSourceWithResult} to point to the current data source
        // if it has finished (i.e. the new result is final), and is of higher quality.
        if (getDataSourceWithResult() == null
            || (isFinished && index < mIndexOfDataSourceWithResult)) {
          newIndexOfDataSourceWithResult = index;
          mIndexOfDataSourceWithResult = index;
        }
      }
      // close data sources of lower quality than the one with the result
      for (int i = oldIndexOfDataSourceWithResult; i > newIndexOfDataSourceWithResult; i--) {
        // NULLSAFE_FIXME[Parameter Not Nullable]
        closeSafely(getAndClearDataSource(i));
      }
    }
Creates a new data source supplier with increasing-quality strategy with optional lazy state
creation.

<p>Note: for performance reasons the list doesn't get cloned, so the caller of this method
should not modify the list once passed in here.

@param dataSourceSuppliers list of underlying suppliers
@param dataSourceLazy if true, the state of data source would be created only if necessary
fbcore/src/main/java/com/facebook/datasource/IncreasingQualityDataSourceSupplier.java