Question: I have this code

```
    public Stream<PaymentEntity> getPayments(List<String> paymentIds) {
        return paymentIds.stream()
                .flatMap(id -> paymentsRepository.getById(id))

}

```

`paymentsRepository.getById(id)` is returning `Single<PaymentEntity>`

But i got compile time error

> 
> no instance(s) of type variable(s) R exist so that
>  Single conforms to Stream
> 
> 
> 

Edit, to anyone asking about `Single` <http://reactivex.io/documentation/single.html>

Answer: 
You can use 

```
return paymentIds.stream()
            .map(id -> paymentsRepository.getById(id).toBlocking().value());

```

Or in `rxjava 2` you can use :

```
 return paymentIds.stream()
            .map(id -> paymentsRepository.getById(id).blockingGet());

```

---

After comment I think you can go with this solution :

```
 List<PaymentEntity> result = new ArrayList<>();
 paymentIds.forEach(id -> paymentsRepository.getById(id).toObservable().subscribe(result::add));
 return result.stream();

```
Alternate solution:

```
public Stream<PaymentEntity> getPayments(List<String> paymentIds) {
    return Observable.fromIterable(paymentIds)
            .flatMapSingle(id -> paymentsRepository.getById(id))
            .toList()
            .blockingGet()
            .stream();
}

```