@Override public void handleEvent(PersonMoneyEvent event) { // trip totalPayments = totalPayments + (-1. * event.getAmount()); int tripNumber = this.personId2currentTripNumber.get(event.getPersonId()); double amountBefore = personId2tripNumber2amount.get(event.getPersonId()).get(tripNumber); double updatedAmount = amountBefore + (-1. * event.getAmount()); Map<Integer, Double> tripNumber2amount = personId2tripNumber2amount.get(event.getPersonId()); tripNumber2amount.put(tripNumber, updatedAmount); personId2tripNumber2amount.put(event.getPersonId(), tripNumber2amount); // person if (this.personId2totalpayments.get(event.getPersonId()) == null) { this.personId2totalpayments.put(event.getPersonId(), event.getAmount() * (-1.)); } else { double amountSoFar = this.personId2totalpayments.get(event.getPersonId()); double amountNew = amountSoFar + (event.getAmount() * (-1.)); this.personId2totalpayments.put(event.getPersonId(), amountNew); } }
@Override public void handleEvent(PersonMoneyEvent event) { if (isStucking(event.getPersonId())) { // ignore this person } else { Id<Person> id = event.getPersonId(); Double amountByEvent = event.getAmount(); Double amountSoFar = id2amount.get(id); if (amountSoFar == null) { id2amount.put(id, amountByEvent); } else { amountSoFar += amountByEvent; id2amount.put(id, amountSoFar); } } }