Last active
March 11, 2018 03:02
-
-
Save dhaval201279/7d6918f80b26073107e425be8ace01d3 to your computer and use it in GitHub Desktop.
3rd version of ReservationService - with null check and addition of ReservationNotFoundException
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
public class ReservationService { | |
private ReservationRepository reservationRepository; | |
public ReservationService(ReservationRepository reservationRepository) { | |
this.reservationRepository = reservationRepository; | |
} | |
public Reservation getReservationDetails(String name) { | |
System.out.println("Entering and leaving ReservationService : getReservationDetails " | |
+ "after calling reservationRepository.findByFirstName"); | |
Reservation aReservation = reservationRepository.findByFirstName(name); | |
if (aReservation == null) { | |
throw new ReservationNotFoundException(); | |
} | |
return aReservation; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment