Class SetupController.Interval
java.lang.Object
page.codeberg.friedolyn.gui.controllers.SetupController.Interval
- Enclosing class:
SetupController
Represents a time span in days, hours, and minutes. Can be normalised to minutes using the
toMinutes()
method. Each object is thread-safe, i.e. it makes use of locks and synchronisation to ensure that two threads
cannot interfere with each other when modifying the object's state.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
lock()
void
setDays
(int days) Updates the number of days in the interval.void
setHours
(int hours) Updates the number of hours in the interval.void
setMinutes
(int minutes) Updates the number of minutes in the interval.int
Normalises the interval to minutes, i.e.void
unlock()
-
Field Details
-
days
private int days -
hours
private int hours -
minutes
private int minutes -
lock
-
-
Constructor Details
-
Interval
private Interval()
-
-
Method Details
-
lock
public void lock() -
unlock
public void unlock() -
setDays
Updates the number of days in the interval.- Parameters:
days
- The new number of days. Must not be negative.- Throws:
IllegalArgumentException
- If the number of days is negative.
-
setHours
Updates the number of hours in the interval.- Parameters:
hours
- The new number of hours. Must not be negative or greater than 23.- Throws:
IllegalArgumentException
- If the number of hours is negative or greater than 23.
-
setMinutes
Updates the number of minutes in the interval.- Parameters:
minutes
- The new number of minutes. Must not be below 0 or above 59.- Throws:
IllegalArgumentException
- If the number of minutes is negative or greater than 59.
-
toMinutes
public int toMinutes()Normalises the interval to minutes, i.e. the number of days is multiplied by 24 * 60 and the number of hours by 60, and then the sum of days, hours and minutes is returned.- Returns:
- The entire time span converted to minutes.
-