Skip to content

Instantly share code, notes, and snippets.

@dhaval201279
Last active March 11, 2018 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhaval201279/7d6918f80b26073107e425be8ace01d3 to your computer and use it in GitHub Desktop.
Save dhaval201279/7d6918f80b26073107e425be8ace01d3 to your computer and use it in GitHub Desktop.
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