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
FieldsModifier and TypeFieldDescriptionstatic final StringField name used in a database to access theclientIdattribute.static final StringField name used in a database to access thedateattribute.static final StringTable name used in a database to accessReservationentities.Fields inherited from class io.github.marcopaglio.booking.model.BaseEntity
ID_MONGODB, ID_POSTGRESQL -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEmpty 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 TypeMethodDescriptionbooleanOverridden 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.inthashCode()Overridden method for returning a hash code value for the reservation object.voidsetClientId(UUID clientId) Sets the client's identifier of the reservation.voidSets 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 accessReservationentities.- See Also:
-
CLIENTID_DB
Field name used in a database to access theclientIdattribute.- See Also:
-
DATE_DB
Field name used in a database to access thedateattribute.- 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
UUIDof 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
dateof 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:
hashCodein 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:
equalsin classBaseEntity- Parameters:
obj- the reference reservation object with which to compare.- Returns:
trueif this object is the same as theobjargument;falseotherwise.
-
toString
Overridden method for returning a string representation of the reservation.- Specified by:
toStringin classBaseEntity- Returns:
- a string representation of the reservation.
-