Class TimeSlot

java.lang.Object
at.htl.timetableGenerator.model.TimeSlot

public final class TimeSlot extends Object
This class represents a time slot in a timetable. A time slot is defined by a day of the week and an hour of the day.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TimeSlot(DayOfWeek day, int hour)
    Constructs a new TimeSlot with the specified day and hour.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(@Nullable Object obj)
    Checks if this time slot is equal to the specified object.
    Returns the day of the week for this time slot.
    int
    Returns the hour of the day for this time slot.
    int
    Returns a hash code value for this time slot.
    @NotNull TimeSlot
    Returns a new TimeSlot that represents the next day at the same hour.
    @NotNull TimeSlot
    Returns a new TimeSlot that represents the same day at the next hour.
    @NotNull TimeSlot
    Returns a new TimeSlot that represents the previous day at the same hour.
    @NotNull TimeSlot
    Returns a new TimeSlot that represents the same day at the previous hour.
    void
    Sets the day of the week for this time slot.
    void
    setHour(int hour)
    Sets the hour of the day for this time slot.
    @NotNull String
    Returns a string representation of this time slot.

    Methods inherited from class java.lang.Object

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

    • TimeSlot

      public TimeSlot(DayOfWeek day, int hour)
      Constructs a new TimeSlot with the specified day and hour.
      Parameters:
      day - the day of the week
      hour - the hour of the day (0-indexed)
  • Method Details

    • getDay

      public DayOfWeek getDay()
      Returns the day of the week for this time slot.
      Returns:
      the day of the week
    • setDay

      public void setDay(DayOfWeek day)
      Sets the day of the week for this time slot.
      Parameters:
      day - the day of the week
    • getHour

      public int getHour()
      Returns the hour of the day for this time slot.
      Returns:
      the hour of the day
    • setHour

      public void setHour(int hour)
      Sets the hour of the day for this time slot.
      Parameters:
      hour - the hour of the day
    • equals

      public boolean equals(@Nullable @Nullable Object obj)
      Checks if this time slot is equal to the specified object. The result is true if and only if the argument is not null and is a TimeSlot object that has the same day and hour as this object.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare this TimeSlot against
      Returns:
      true if the given object represents a TimeSlot with the same day and hour to this time slot, false otherwise
    • hashCode

      public int hashCode()
      Returns a hash code value for this time slot.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this time slot
    • toString

      @Contract(pure=true) @NotNull public @NotNull String toString()
      Returns a string representation of this time slot.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this time slot
    • nextDay

      @Contract(" -> new") @NotNull public @NotNull TimeSlot nextDay()
      Returns a new TimeSlot that represents the next day at the same hour.
      Returns:
      a new TimeSlot that represents the next day at the same hour
    • prevDay

      @Contract(" -> new") @NotNull public @NotNull TimeSlot prevDay()
      Returns a new TimeSlot that represents the previous day at the same hour.
      Returns:
      a new TimeSlot that represents the previous day at the same hour
    • nextHour

      @Contract(value=" -> new", pure=true) @NotNull public @NotNull TimeSlot nextHour()
      Returns a new TimeSlot that represents the same day at the next hour.
      Returns:
      a new TimeSlot that represents the same day at the next hour
    • prevHour

      @Contract(" -> new") @NotNull public @NotNull TimeSlot prevHour()
      Returns a new TimeSlot that represents the same day at the previous hour. Throws an IllegalArgumentException if the hour is 0.
      Returns:
      a new TimeSlot that represents the same day at the previous hour
      Throws:
      IllegalArgumentException - if the hour is 0