Class Reservation

java.lang.Object
io.github.marcopaglio.booking.model.BaseEntity
io.github.marcopaglio.booking.model.Reservation

@Entity public class Reservation extends BaseEntity
This entity represents the reservation's model of the booking application.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Field name used in a database to access the clientId attribute.
    static final String
    Field name used in a database to access the date attribute.
    static final String
    Table name used in a database to access Reservation entities.

    Fields inherited from class io.github.marcopaglio.booking.model.BaseEntity

    ID_MONGODB, ID_POSTGRESQL
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    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 Type
    Method
    Description
    boolean
    Overridden method for indicating whether some other reservation object is "equal to" this one.
    Retrieves the identifier of the associated client of the reservation.
    Retrieves the date of the reservation.
    int
    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.
    Overridden method for returning a string representation of the reservation.

    Methods inherited from class io.github.marcopaglio.booking.model.BaseEntity

    getId, setId

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • RESERVATION_TABLE_DB

      public static final String RESERVATION_TABLE_DB
      Table name used in a database to access Reservation entities.
      See Also:
    • CLIENTID_DB

      public static final String CLIENTID_DB
      Field name used in a database to access the clientId attribute.
      See Also:
    • DATE_DB

      public static final String DATE_DB
      Field name used in a database to access the date attribute.
      See Also:
  • Constructor Details

    • Reservation

      public Reservation(UUID clientId, LocalDate date)
      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

      public UUID 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

      public void setClientId(UUID clientId)
      Sets the client's identifier of the reservation.
      Parameters:
      clientId - the client's identifier to set.
    • getDate

      public LocalDate getDate()
      Retrieves the date of the reservation. Note: LocalDate Objects are immutable.
      Returns:
      the date of the reservation.
    • setDate

      public void setDate(LocalDate date)
      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 class BaseEntity
      Returns:
      a hash code value for this reservation object.
    • equals

      public boolean equals(Object obj)
      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 class BaseEntity
      Parameters:
      obj - the reference reservation object with which to compare.
      Returns:
      true if this object is the same as the obj argument; false otherwise.
    • toString

      public String toString()
      Overridden method for returning a string representation of the reservation.
      Specified by:
      toString in class BaseEntity
      Returns:
      a string representation of the reservation.