Class ServedBookingPresenter
java.lang.Object
io.github.marcopaglio.booking.presenter.served.ServedBookingPresenter
- All Implemented Interfaces:
BookingPresenter
A concrete implementation of the presenter for the booking application using
a single view and delegating operations on repositories to a service layer.
-
Constructor Summary
ConstructorDescriptionServedBookingPresenter
(BookingView view, BookingService bookingService, ClientValidator clientValidator, ReservationValidator reservationValidator) Constructs a presenter for the booking application with a view and a service. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Validates and inserts a new client in the repository and notifies the view about the changes.void
addReservation
(Client client, String date) Validates and inserts a new reservation in the repository and notifies the view about the changes.void
Finds all the existing clients in the repository through the service layer and gives the list to the view for showing them.void
Finds all the existing reservations in the repository through the service layer and gives the list to the view for showing them.void
deleteClient
(Client client) Removes an existing client and all his reservations from the repository and notifies the view about the changes.void
deleteReservation
(Reservation reservation) Removes an existing reservation from the repository and notifies the view about the changes.void
renameClient
(Client client, String newFirstName, String newLastName) Validates and modifies names of an existing client and notifies the view about the changes.void
rescheduleReservation
(Reservation reservation, String newDate) Modifies the date of an existing reservation and notifies the view about the changes.
-
Constructor Details
-
ServedBookingPresenter
public ServedBookingPresenter(BookingView view, BookingService bookingService, ClientValidator clientValidator, ReservationValidator reservationValidator) Constructs a presenter for the booking application with a view and a service.- Parameters:
view
- theView
used to show the user interface.bookingService
- theBookingService
used to interact with repositories.clientValidator
- the inputs checker forClient
entities.reservationValidator
- the inputs checker forReservation
entities.
-
-
Method Details
-
allClients
public void allClients()Finds all the existing clients in the repository through the service layer and gives the list to the view for showing them.- Specified by:
allClients
in interfaceBookingPresenter
-
allReservations
public void allReservations()Finds all the existing reservations in the repository through the service layer and gives the list to the view for showing them.- Specified by:
allReservations
in interfaceBookingPresenter
-
deleteClient
Removes an existing client and all his reservations from the repository and notifies the view about the changes. This method delegates its elimination and of all his reservations to the service layer.- Specified by:
deleteClient
in interfaceBookingPresenter
- Parameters:
client
- the client to delete.
-
deleteReservation
Removes an existing reservation from the repository and notifies the view about the changes. This method delegates its elimination to the service layer.- Specified by:
deleteReservation
in interfaceBookingPresenter
- Parameters:
reservation
- the reservation to delete.
-
addClient
Validates and inserts a new client in the repository and notifies the view about the changes. This method delegates the inserting to the service layer.- Specified by:
addClient
in interfaceBookingPresenter
- Parameters:
firstName
- the name of the client to add.lastName
- the surname of the client to add.
-
addReservation
Validates and inserts a new reservation in the repository and notifies the view about the changes. This method delegates the inserting to the service layer.- Specified by:
addReservation
in interfaceBookingPresenter
- Parameters:
client
- the associated client of the reservation to add.date
- the date of the reservation to add.
-
renameClient
Validates and modifies names of an existing client and notifies the view about the changes. This method delegates the renaming to the service layer only if new names are actually different from the old ones.- Specified by:
renameClient
in interfaceBookingPresenter
- Parameters:
client
- the client to modify.newFirstName
- the new name for the client.newLastName
- the new surname for the client.
-
rescheduleReservation
Modifies the date of an existing reservation and notifies the view about the changes. This method delegates the rescheduling to the service layer only if new date is actually different from the old one.- Specified by:
rescheduleReservation
in interfaceBookingPresenter
- Parameters:
reservation
- the reservation to modify.newDate
- the new date for the reservation.
-