Skip to content

Instantly share code, notes, and snippets.

Last active Jan 16, 2017
What would you like to do?
Mutable Models Bug
* Provides a stream of vehicles that have a price.
public class PricedVehicles {
private Observable<List<Vehicle>> pricedVehicles;
public PricedVehicles(VehicleStream vehicleStream, PricingStream pricingStream) {
this.pricedVehicles = Observable.combineLatest(
* @return a stream that emits lists of priced vehicles.
public Observable<List<Vehicle>> stream() {
return pricedVehicles;
* Removes vehicles that don't have a price in the prices map.
* @param vehicles the list of vehicles that are available.
* @param prices a map containing the prices of vehicles.
private static List<Vehicle> filterVehiclesWithoutPrice(
List<Vehicle> vehicles,
Map<VehicleId, Price> prices) {
List<Vehicle> vehiclesToRemove = new ArrayList<>();
for(Vehicle vehicle : vehicles) {
if (prices.get( == null) {
return vehicles;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment