Class Reservation
java.lang.Object
io.github.marcopaglio.booking.model.BaseEntity
io.github.marcopaglio.booking.model.Reservation
This entity represents the reservation's model of the booking application.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Field name used in a database to access theclientId
attribute.static final String
Field name used in a database to access thedate
attribute.static final String
Table name used in a database to accessReservation
entities.Fields inherited from class io.github.marcopaglio.booking.model.BaseEntity
ID_MONGODB, ID_POSTGRESQL
-
Constructor Summary
ModifierConstructorDescriptionprotected
Empty constructor needed for database purposes.Reservation
(UUID clientId, LocalDate date) Constructs a reservation for the booking application from the associated client's identifier and a date. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Overridden method for indicating whether some other reservation object is "equal to" this one.Retrieves the identifier of the associated client of the reservation.getDate()
Retrieves the date of the reservation.int
hashCode()
Overridden method for returning a hash code value for the reservation object.void
setClientId
(UUID clientId) Sets the client's identifier of the reservation.void
Sets the date of the reservation.toString()
Overridden method for returning a string representation of the reservation.Methods inherited from class io.github.marcopaglio.booking.model.BaseEntity
getId, setId
-
Field Details
-
RESERVATION_TABLE_DB
Table name used in a database to accessReservation
entities.- See Also:
-
CLIENTID_DB
Field name used in a database to access theclientId
attribute.- See Also:
-
DATE_DB
Field name used in a database to access thedate
attribute.- See Also:
-
-
Constructor Details
-
Reservation
Constructs a reservation for the booking application from the associated client's identifier and a date. The constructor checks if the parameters are valid for the creation of the reservation.- Parameters:
clientId
- the identifier of the associated client of the reservation.date
- the date of the reservation.
-
Reservation
protected Reservation()Empty constructor needed for database purposes.
-
-
Method Details
-
getClientId
Retrieves the identifier of the associated client of the reservation. Note: UUID Objects are immutable.- Returns:
- the
UUID
of the associated client of the reservation.
-
setClientId
Sets the client's identifier of the reservation.- Parameters:
clientId
- the client's identifier to set.
-
getDate
Retrieves the date of the reservation. Note: LocalDate Objects are immutable.- Returns:
- the
date
of the reservation.
-
setDate
Sets the date of the reservation.- Parameters:
date
- the date to set.
-
hashCode
public int hashCode()Overridden method for returning a hash code value for the reservation object.- Specified by:
hashCode
in classBaseEntity
- Returns:
- a hash code value for this reservation object.
-
equals
Overridden method for indicating whether some other reservation object is "equal to" this one. Two reservation objects are equal if they have the date and client identifier.- Specified by:
equals
in classBaseEntity
- Parameters:
obj
- the reference reservation object with which to compare.- Returns:
true
if this object is the same as theobj
argument;false
otherwise.
-
toString
Overridden method for returning a string representation of the reservation.- Specified by:
toString
in classBaseEntity
- Returns:
- a string representation of the reservation.
-