Is there any way so that the below can be performed as one set of stream operations, instead of explicitly checking if recommendedProducts is empty then return default list else return the filtered list?
public List<Product> getRecommendedProducts() {
List<Product> recommendedProducts
= this.newProducts
.stream()
.filter(isAvailable)
.collect(Collectors.toList());
if (recommendedProducts.isEmpty()) {
return DEFAULT_PRODUCTS;
}
return recommededProducts;
}