SHARE
TWEET

Update entity

a guest Oct 23rd, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void update(Trip trip) {
  2.         Map<UUID, Reservation> grouped = trip.getReservations()
  3.                                              .stream()
  4.                                              .collect(toMap(x -> x.getId(), x -> x));
  5.  
  6.         for (ReservationEntity reservationEntity: reservations) {
  7.             Reservation reservation = grouped.get(reservationEntity.getId());
  8.             reservationEntity.setStatus(reservation.getStatus().name());
  9.             grouped.remove(reservation.getId());
  10.         }
  11.  
  12.         for (Reservation reservation: grouped.values()) {
  13.             ReservationEntity reservationEntity = new ReservationEntity();
  14.             reservationEntity.setId(reservation.getId());
  15.             reservationEntity.setUserId(reservation.getUserId());
  16.             reservationEntity.setStatus(reservation.getStatus().name());
  17.             reservations.add(reservationEntity);
  18.         }
  19.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top