Instantly share code, notes, and snippets.

Embed
What would you like to do?
3rd version of ReservationService - with null check and addition of ReservationNotFoundException
@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