Record Class TimespanOverlapItem

java.lang.Object
java.lang.Record
de.gustavblass.fsu.fmi.roombooking.model.room.schedule.TimespanOverlapItem
Record Components:
type - Whether the SeatReservation starts or ends at the set time.
time - When the SeatReservation starts/ends (depending on the type).
value - How many seats in the Reservation.room are occupied during the SeatReservation's timespan.
All Implemented Interfaces:
Comparable<TimespanOverlapItem>

public record TimespanOverlapItem(@NonNull TimespanOverlapItem.Type type, @NonNull LocalTime time, int value) extends Record implements Comparable<TimespanOverlapItem>
Useful to convert a collection of SeatReservations into a RoomSchedule.
  • Field Details

    • type

      @NonNull private final @NonNull TimespanOverlapItem.Type type
      The field for the type record component.
    • time

      @NonNull private final @NonNull LocalTime time
      The field for the time record component.
    • value

      private final int value
      The field for the value record component.
  • Constructor Details

    • TimespanOverlapItem

      public TimespanOverlapItem(@NonNull @NonNull TimespanOverlapItem.Type type, @NonNull @NonNull LocalTime time, int value)
      Creates an instance of a TimespanOverlapItem record class.
      Parameters:
      type - the value for the type record component
      time - the value for the time record component
      value - the value for the value record component
  • Method Details

    • compareTo

      @Contract(pure=true) public int compareTo(@NonNull @NonNull TimespanOverlapItem other)
      Specified by:
      compareTo in interface Comparable<TimespanOverlapItem>
    • compareToWithInverseType

      @Contract(pure=true) public int compareToWithInverseType(@NonNull @NonNull TimespanOverlapItem other)
      Compares this TimespanOverlapItem to another one based on the time field. If both are equal, then this method falls back to the TimespanOverlapItem.Type.inverseComparator(TimespanOverlapItem.Type) of the type.
      Parameters:
      other - The object that this one shall be compared to.
      Returns:
      If this object comes first, less than zero. If the other object comes first, greater than zero. If both have the same time, then the result of TimespanOverlapItem.Type.inverseComparator(TimespanOverlapItem.Type).
    • compareTo

      @Contract(pure=true) public int compareTo(@NonNull @NonNull TimespanOverlapItem other, @NonNull @NonNull Comparator<TimespanOverlapItem.Type> typeComparator)
      Compares this TimespanOverlapItem to another one based on the time field. If both are equal, then this method falls back to the given Comparator.
      Parameters:
      other - The object that this one shall be compared to.
      typeComparator - Will be used if both objects have the same time.
      Returns:
      If this object comes first, less than zero. If the other object comes first, greater than zero. If both have the same time, then the result of the given comparator.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • type

      @NonNull public @NonNull TimespanOverlapItem.Type type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • time

      @NonNull public @NonNull LocalTime time()
      Returns the value of the time record component.
      Returns:
      the value of the time record component
    • value

      public int value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component