From 7d7bc3d8f1ddb47f3a82b8423676895b911acaad Mon Sep 17 00:00:00 2001 From: Martijn Bonajo Date: Fri, 6 Sep 2024 13:21:57 +0200 Subject: [PATCH 1/9] build: update to latest parent and bump version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 10a3f34..67fa1f5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,11 +6,11 @@ io.github.fontysvenlo informaticspom - 1.3.3 + 1.3 io.github.fontysvenlo.alda appointmentplanner_api - 1.2.2 + 1.3 jar ALDA AppointmentPlanner API From 0a28b8859ad8bea1b915dbed70047d67b148000f Mon Sep 17 00:00:00 2001 From: Martijn Bonajo Date: Fri, 6 Sep 2024 13:22:24 +0200 Subject: [PATCH 2/9] chore: fix whitespace --- .../api/AbstractAPFactory.java | 36 +++++------ .../api/AppointmentRequest.java | 6 +- .../java/appointmentplanner/api/LocalDay.java | 40 ++++++------ .../appointmentplanner/api/LocalDayPlan.java | 62 +++++++++---------- .../java/appointmentplanner/api/TimeSlot.java | 32 +++++----- .../java/appointmentplanner/api/Timeline.java | 38 ++++++------ 6 files changed, 107 insertions(+), 107 deletions(-) diff --git a/src/main/java/appointmentplanner/api/AbstractAPFactory.java b/src/main/java/appointmentplanner/api/AbstractAPFactory.java index cd91802..2570073 100644 --- a/src/main/java/appointmentplanner/api/AbstractAPFactory.java +++ b/src/main/java/appointmentplanner/api/AbstractAPFactory.java @@ -20,8 +20,8 @@ public interface AbstractAPFactory { * @param endTime no appointments end after this time * @return LocalDayPlan object. */ - default LocalDayPlan createLocalDayPlan( LocalDay day, LocalTime startTime, LocalTime endTime ) { - return createLocalDayPlan( day, day.ofLocalTime( startTime ), day.ofLocalTime( endTime ) ); + default LocalDayPlan createLocalDayPlan(LocalDay day, LocalTime startTime, LocalTime endTime) { + return createLocalDayPlan(day, day.ofLocalTime(startTime), day.ofLocalTime(endTime)); } /** @@ -32,7 +32,7 @@ default LocalDayPlan createLocalDayPlan( LocalDay day, LocalTime startTime, Loca * @param end no appointments end after this time * @return LocalDayPlan object. */ - LocalDayPlan createLocalDayPlan( LocalDay day, Instant start, Instant end ); + LocalDayPlan createLocalDayPlan(LocalDay day, Instant start, Instant end); /** @@ -46,9 +46,9 @@ default LocalDayPlan createLocalDayPlan( LocalDay day, LocalTime startTime, Loca * @return AppointmentData object. * @throws NullPointerException if any of the parameters are null */ - AppointmentData createAppointmentData( String description, + AppointmentData createAppointmentData(String description, Duration duration, - Priority priority ); + Priority priority); /** * Factory method to create an AppointmentData object without specified @@ -60,8 +60,8 @@ AppointmentData createAppointmentData( String description, * @return Appointment object. * @throws NullPointerException if any of the parameters are null */ - default AppointmentData createAppointmentData( String description, Duration duration ) { - return createAppointmentData( description, duration, Priority.LOW ); + default AppointmentData createAppointmentData(String description, Duration duration) { + return createAppointmentData(description, duration, Priority.LOW); } /** @@ -71,8 +71,8 @@ default AppointmentData createAppointmentData( String description, Duration dura * @param startTime time of the request * @return the request. */ - default AppointmentRequest createAppointmentRequest( AppointmentData data, LocalTime startTime ) { - return createAppointmentRequest( data, startTime, TimePreference.UNSPECIFIED ); + default AppointmentRequest createAppointmentRequest(AppointmentData data, LocalTime startTime) { + return createAppointmentRequest(data, startTime, TimePreference.UNSPECIFIED); } /** @@ -82,8 +82,8 @@ default AppointmentRequest createAppointmentRequest( AppointmentData data, Local * @param preference for time, early or late * @return the request */ - default AppointmentRequest createAppointmentRequest( AppointmentData appData, TimePreference preference ) { - return createAppointmentRequest( appData, null, preference ); + default AppointmentRequest createAppointmentRequest(AppointmentData appData, TimePreference preference) { + return createAppointmentRequest(appData, null, preference); } /** @@ -95,9 +95,9 @@ default AppointmentRequest createAppointmentRequest( AppointmentData appData, Ti * @param fallBack when time not available, use fallback TimePreference * @return the request */ - AppointmentRequest createAppointmentRequest( AppointmentData appointmentData, + AppointmentRequest createAppointmentRequest(AppointmentData appointmentData, LocalTime preferredStart, - TimePreference fallBack ); + TimePreference fallBack); /** * Create a time slot between two times. @@ -106,7 +106,7 @@ AppointmentRequest createAppointmentRequest( AppointmentData appointmentData, * @param end date+time * @return the time slot */ - TimeSlot between( Instant start, Instant end ); + TimeSlot between(Instant start, Instant end); /** * Compute time slot on a date between given start- and endTime. @@ -119,10 +119,10 @@ AppointmentRequest createAppointmentRequest( AppointmentData appointmentData, * @param endTime end time * @return the timeslot */ - default TimeSlot between( LocalDay day, LocalTime startTime, LocalTime endTime ) { + default TimeSlot between(LocalDay day, LocalTime startTime, LocalTime endTime) { boolean endBeforeOrAtStart = !endTime.isAfter(startTime); - Instant start = day.ofLocalTime( startTime ); - Instant end = (endBeforeOrAtStart) ? day.plusDays( 1 ).ofLocalTime( endTime ) : day.ofLocalTime( endTime ); - return between( start, end ); + Instant start = day.ofLocalTime(startTime); + Instant end = (endBeforeOrAtStart) ? day.plusDays(1).ofLocalTime(endTime) : day.ofLocalTime(endTime); + return between(start, end); } } diff --git a/src/main/java/appointmentplanner/api/AppointmentRequest.java b/src/main/java/appointmentplanner/api/AppointmentRequest.java index 83c268e..cf985b6 100644 --- a/src/main/java/appointmentplanner/api/AppointmentRequest.java +++ b/src/main/java/appointmentplanner/api/AppointmentRequest.java @@ -39,8 +39,8 @@ public interface AppointmentRequest extends AppointmentData { * @param onDay the LocalDay the time is on. * @return the start time as instant, potentially null. */ - default Instant getStart( LocalDay onDay ) { - return onDay.ofLocalTime( getStartTime() ); + default Instant getStart(LocalDay onDay) { + return onDay.ofLocalTime(getStartTime()); } /** @@ -82,7 +82,7 @@ default Duration getDuration() { * @return true if the two appointments are equal */ @Override - public boolean equals( Object obj ); + public boolean equals(Object obj); /** * Calculate a hash code value for the object. diff --git a/src/main/java/appointmentplanner/api/LocalDay.java b/src/main/java/appointmentplanner/api/LocalDay.java index 49d7c95..bf9d03a 100644 --- a/src/main/java/appointmentplanner/api/LocalDay.java +++ b/src/main/java/appointmentplanner/api/LocalDay.java @@ -22,7 +22,7 @@ public class LocalDay { * @param zone the timezone to use * @param date the LocalDate to use */ - public LocalDay( ZoneId zone, LocalDate date ) { + public LocalDay(ZoneId zone, LocalDate date) { this.zone = zone; this.date = date; } @@ -31,7 +31,7 @@ public LocalDay( ZoneId zone, LocalDate date ) { * Create a LocalDay based on the system default timezone and the current date. */ public LocalDay() { - this( ZoneId.systemDefault(), LocalDate.now() ); + this(ZoneId.systemDefault(), LocalDate.now()); } /** @@ -57,8 +57,8 @@ public ZoneId getZone() { * @param localTime the local time * @return the time as an instant at this date and timezone */ - public Instant ofLocalTime( LocalTime localTime ) { - return localTime.atDate( date ).atZone( zone ).toInstant(); + public Instant ofLocalTime(LocalTime localTime) { + return localTime.atDate(date).atZone(zone).toInstant(); } /** @@ -67,8 +67,8 @@ public Instant ofLocalTime( LocalTime localTime ) { * @param instant to convert to LocalTime * @return the LocalTime of the given instant */ - public LocalTime timeOfInstant( Instant instant ) { - return instant.atZone( zone ).toLocalTime(); + public LocalTime timeOfInstant(Instant instant) { + return instant.atZone(zone).toLocalTime(); } /** @@ -77,8 +77,8 @@ public LocalTime timeOfInstant( Instant instant ) { * @param instant to convert to LocalDate * @return the LocalDate of the given instant */ - public LocalDate dateOfInstant( Instant instant ) { - return instant.atZone( zone ).toLocalDate(); + public LocalDate dateOfInstant(Instant instant) { + return instant.atZone(zone).toLocalDate(); } /** @@ -87,8 +87,8 @@ public LocalDate dateOfInstant( Instant instant ) { * @param days to add * @return the new LocalDay shifted forward or backward in time. */ - public LocalDay plusDays( int days ) { - return new LocalDay( zone, date.plusDays( days ) ); + public LocalDay plusDays(int days) { + return new LocalDay(zone, date.plusDays(days)); } /** @@ -98,8 +98,8 @@ public LocalDay plusDays( int days ) { * @param m the minutes * @return Instant at the given ours and minutes */ - public Instant at( int hm, int m ) { - return ofLocalTime( LocalTime.of( hm, m, 0 ) ); + public Instant at(int hm, int m) { + return ofLocalTime(LocalTime.of(hm, m, 0)); } /** @@ -119,26 +119,26 @@ public String toString() { @Override public int hashCode() { int hash = 7; - hash = 73 * hash + Objects.hashCode( this.zone ); - hash = 73 * hash + Objects.hashCode( this.date ); + hash = 73 * hash + Objects.hashCode(this.zone); + hash = 73 * hash + Objects.hashCode(this.date); return hash; } @Override - public boolean equals( Object obj ) { - if ( this == obj ) { + public boolean equals(Object obj) { + if (this == obj) { return true; } - if ( obj == null ) { + if (obj == null) { return false; } - if ( getClass() != obj.getClass() ) { + if (getClass() != obj.getClass()) { return false; } final LocalDay other = (LocalDay) obj; - if ( !Objects.equals( this.zone, other.zone ) ) { + if (!Objects.equals(this.zone, other.zone)) { return false; } - return Objects.equals( this.date, other.date ); + return Objects.equals(this.date, other.date); } } diff --git a/src/main/java/appointmentplanner/api/LocalDayPlan.java b/src/main/java/appointmentplanner/api/LocalDayPlan.java index c446c47..efa19b0 100644 --- a/src/main/java/appointmentplanner/api/LocalDayPlan.java +++ b/src/main/java/appointmentplanner/api/LocalDayPlan.java @@ -59,7 +59,7 @@ public interface LocalDayPlan { * @return the start time of this plan */ default LocalTime getStartTime() { - return getDay().timeOfInstant(startOfDay() ); + return getDay().timeOfInstant(startOfDay()); } /** @@ -68,7 +68,7 @@ default LocalTime getStartTime() { * @return the end time in this plan */ default LocalTime getEndTime() { - return getDay().timeOfInstant(endOfDay() ); + return getDay().timeOfInstant(endOfDay()); } /** @@ -80,10 +80,10 @@ default LocalTime getEndTime() { * @return an optional of Appointment, which is present when the appointment * was created successfully, or empty when not successful. */ - default Optional addAppointment( AppointmentData appointmentData, + default Optional addAppointment(AppointmentData appointmentData, LocalTime start, - TimePreference fallback ) { - return getTimeline().addAppointment( getDay(), appointmentData, start, fallback ); + TimePreference fallback) { + return getTimeline().addAppointment(getDay(), appointmentData, start, fallback); } /** @@ -94,8 +94,8 @@ default Optional addAppointment( AppointmentData appointmentData, * @param startTime fixed time * @return Optional Appointment */ - default Optional addAppointment( AppointmentData appointmentData, LocalTime startTime ) { - return getTimeline().addAppointment( getDay(), appointmentData, startTime ); + default Optional addAppointment(AppointmentData appointmentData, LocalTime startTime) { + return getTimeline().addAppointment(getDay(), appointmentData, startTime); } /** @@ -107,8 +107,8 @@ default Optional addAppointment( AppointmentData appointmentData, L * @param preference time preference * @return Optional Appointment */ - default Optional addAppointment( AppointmentData appointmentData, TimePreference preference ) { - return getTimeline().addAppointment( getDay(), appointmentData, preference ); + default Optional addAppointment(AppointmentData appointmentData, TimePreference preference) { + return getTimeline().addAppointment(getDay(), appointmentData, preference); } /** @@ -117,8 +117,8 @@ default Optional addAppointment( AppointmentData appointmentData, T * @param appointment the appointment to remove * @return AppointmentRequest, the original appointment request */ - default AppointmentRequest removeAppointment( Appointment appointment ) { - return getTimeline().removeAppointment( appointment ); + default AppointmentRequest removeAppointment(Appointment appointment) { + return getTimeline().removeAppointment(appointment); } /** @@ -127,8 +127,8 @@ default AppointmentRequest removeAppointment( Appointment appointment ) { * @param filter to remove all appointments that match * @return all appointment requests of removed appointments */ - default List removeAppointments( Predicate filter ) { - return getTimeline().removeAppointments( filter ); + default List removeAppointments(Predicate filter) { + return getTimeline().removeAppointments(filter); } /** @@ -148,8 +148,8 @@ default List getAppointments() { * @return the list of gaps this and each of the other plans have in common * with a minimum length of duration. */ - default List getMatchingFreeSlotsOfDuration( Duration duration, List plans ) { - return getTimeline().getMatchingFreeSlotsOfDuration( duration, plans.stream().map( LocalDayPlan::getTimeline ).collect( toList() ) ); + default List getMatchingFreeSlotsOfDuration(Duration duration, List plans) { + return getTimeline().getMatchingFreeSlotsOfDuration(duration, plans.stream().map(LocalDayPlan::getTimeline).collect(toList())); } /** @@ -158,8 +158,8 @@ default List getMatchingFreeSlotsOfDuration( Duration duration, List getGapsFitting( Duration duration ) { - return getTimeline().getGapsFitting( duration ); + default List getGapsFitting(Duration duration) { + return getTimeline().getGapsFitting(duration); } /** @@ -168,8 +168,8 @@ default List getGapsFitting( Duration duration ) { * @param duration the minimum duration that should fit * @return list of timeslots that fit the duration */ - default List getGapsFittingReversed( Duration duration ) { - return getTimeline().getGapsFittingReversed( duration ); + default List getGapsFittingReversed(Duration duration) { + return getTimeline().getGapsFittingReversed(duration); } /** @@ -178,8 +178,8 @@ default List getGapsFittingReversed( Duration duration ) { * @param duration the minimum duration * @return list of gaps fitting the duration */ - default List getGapsFittingLargestFirst( Duration duration ) { - return getTimeline().getGapsFittingLargestFirst( duration ); + default List getGapsFittingLargestFirst(Duration duration) { + return getTimeline().getGapsFittingLargestFirst(duration); } /** @@ -188,8 +188,8 @@ default List getGapsFittingLargestFirst( Duration duration ) { * @param duration the minimum duration * @return list of timeslots fitting the duration */ - default List getGapsFittingSmallestFirst( Duration duration ) { - return getTimeline().getGapsFittingSmallestFirst( duration ); + default List getGapsFittingSmallestFirst(Duration duration) { + return getTimeline().getGapsFittingSmallestFirst(duration); } /** @@ -198,8 +198,8 @@ default List getGapsFittingSmallestFirst( Duration duration ) { * @param duration the minimum duration * @return true of a gap is available, false otherwise */ - default boolean canAddAppointmentOfDuration( Duration duration ) { - return getTimeline().canAddAppointmentOfDuration( duration ); + default boolean canAddAppointmentOfDuration(Duration duration) { + return getTimeline().canAddAppointmentOfDuration(duration); } /** @@ -208,8 +208,8 @@ default boolean canAddAppointmentOfDuration( Duration duration ) { * @param filter to find appointments * @return list of appointments that fit the filter */ - default List findAppointments( Predicate filter ) { - return getTimeline().findAppointments( filter ); + default List findAppointments(Predicate filter) { + return getTimeline().findAppointments(filter); } /** @@ -227,8 +227,8 @@ default List findAppointments( Predicate filter ) { * @param appointment the appointment to check * @return true if present, false otherwise */ - default boolean contains( Appointment appointment ) { - return getTimeline().contains( appointment ); + default boolean contains(Appointment appointment) { + return getTimeline().contains(appointment); } /** @@ -256,8 +256,8 @@ default int getNrOfAppointments() { * @param minute sic * @return the point in time as Instant */ - default Instant at( int hour, int minute ) { - return getDay().at( hour, minute ); + default Instant at(int hour, int minute) { + return getDay().at(hour, minute); } } diff --git a/src/main/java/appointmentplanner/api/TimeSlot.java b/src/main/java/appointmentplanner/api/TimeSlot.java index 53ad474..6ecec81 100644 --- a/src/main/java/appointmentplanner/api/TimeSlot.java +++ b/src/main/java/appointmentplanner/api/TimeSlot.java @@ -51,7 +51,7 @@ public interface TimeSlot extends Comparable { * @return the duration as Duration */ default Duration duration() { - return Duration.between( getStart(), getEnd() ); + return Duration.between(getStart(), getEnd()); } /** @@ -61,8 +61,8 @@ default Duration duration() { * @return comparison result, less than 0, 0 or greater 0. */ @Override - public default int compareTo( TimeSlot other ) { - return this.duration().compareTo( other.duration() ); + public default int compareTo(TimeSlot other) { + return this.duration().compareTo(other.duration()); } /** @@ -72,8 +72,8 @@ public default int compareTo( TimeSlot other ) { * @return true if start and end are sufficiently apart to fit the given * duration. */ - default boolean fits( Duration duration ) { - return this.duration().compareTo( duration ) >= 0; + default boolean fits(Duration duration) { + return this.duration().compareTo(duration) >= 0; } /** @@ -83,9 +83,9 @@ default boolean fits( Duration duration ) { * @return true if other does not start earlier nor ends earlier than this * time slot. */ - default boolean fits( TimeSlot other ) { - return this.getStart().compareTo( other.getStart() ) <= 0 - && this.getEnd().compareTo( other.getEnd() ) >= 0; + default boolean fits(TimeSlot other) { + return this.getStart().compareTo(other.getStart()) <= 0 + && this.getEnd().compareTo(other.getEnd()) >= 0; } /** @@ -94,8 +94,8 @@ default boolean fits( TimeSlot other ) { * @param day for the time * @return end Time. */ - default LocalTime getEndTime( LocalDay day ) { - return day.timeOfInstant( getEnd() ); + default LocalTime getEndTime(LocalDay day) { + return day.timeOfInstant(getEnd()); } /** @@ -104,8 +104,8 @@ default LocalTime getEndTime( LocalDay day ) { * @param day for the time * @return start Time */ - default LocalTime getStartTime( LocalDay day ) { - return day.timeOfInstant( getStart() ); + default LocalTime getStartTime(LocalDay day) { + return day.timeOfInstant(getStart()); } /** @@ -114,8 +114,8 @@ default LocalTime getStartTime( LocalDay day ) { * @param day provides time zone * @return the date on which the TimeSlot starts. */ - default LocalDate getStartDate( LocalDay day ) { - return day.dateOfInstant( getStart() ); + default LocalDate getStartDate(LocalDay day) { + return day.dateOfInstant(getStart()); } /** @@ -124,7 +124,7 @@ default LocalDate getStartDate( LocalDay day ) { * @param day provides time zone * @return the date on which the TimeSlot ends. */ - default LocalDate getEndDate( LocalDay day ) { - return day.dateOfInstant( getEnd() ); + default LocalDate getEndDate(LocalDay day) { + return day.dateOfInstant(getEnd()); } } diff --git a/src/main/java/appointmentplanner/api/Timeline.java b/src/main/java/appointmentplanner/api/Timeline.java index fe8c7b7..9c1349a 100644 --- a/src/main/java/appointmentplanner/api/Timeline.java +++ b/src/main/java/appointmentplanner/api/Timeline.java @@ -87,7 +87,7 @@ public interface Timeline { * appointment can't be met. * @throws NullPointerException If the appointmentData is null */ - Optional addAppointment( LocalDay forDay, AppointmentData appointment, TimePreference timePreference ); + Optional addAppointment(LocalDay forDay, AppointmentData appointment, TimePreference timePreference); /** * Add appointment with a fixed time. If the requested slot is available, @@ -99,7 +99,7 @@ public interface Timeline { * @param startTime preferred start time of the appointment * @return the added appointment or an empty Optional on failure. */ - Optional addAppointment( LocalDay forDay, AppointmentData appointment, LocalTime startTime ); + Optional addAppointment(LocalDay forDay, AppointmentData appointment, LocalTime startTime); /** * Create an appointment based on previous appointmentRequest. @@ -108,10 +108,10 @@ public interface Timeline { * @param appointmentRequest for this appointment. * @return the added appointment or an empty Optional on failure. */ - default Optional addAppointment( LocalDay forDay, - AppointmentRequest appointmentRequest ) { - return addAppointment( forDay, appointmentRequest.getAppointmentData(), - appointmentRequest.getStartTime() ); + default Optional addAppointment(LocalDay forDay, + AppointmentRequest appointmentRequest) { + return addAppointment(forDay, appointmentRequest.getAppointmentData(), + appointmentRequest.getStartTime()); } /** @@ -126,8 +126,8 @@ default Optional addAppointment( LocalDay forDay, * apply. * @return the added appointment or an empty Optional on failure. */ - Optional addAppointment( LocalDay forDay, AppointmentData appointment, - LocalTime startTime, TimePreference fallback ); + Optional addAppointment(LocalDay forDay, AppointmentData appointment, + LocalTime startTime, TimePreference fallback); /** * Removes the given appointment, returning the AppointmentRequest of that appointment, if @@ -138,7 +138,7 @@ Optional addAppointment( LocalDay forDay, AppointmentData appointme * @return the AppointmentRequest of the removed appointment or null * if the appointment is not found. */ - AppointmentRequest removeAppointment( Appointment appointment ); + AppointmentRequest removeAppointment(Appointment appointment); /** * Removes appointments with description that matches a filter. @@ -146,7 +146,7 @@ Optional addAppointment( LocalDay forDay, AppointmentData appointme * @param filter to determine which items to remove. * @return the list of AppointmentRequests of removed appointments. */ - List removeAppointments( Predicate filter ); + List removeAppointments(Predicate filter); /** * Finds all appointments matching given filter. @@ -154,7 +154,7 @@ Optional addAppointment( LocalDay forDay, AppointmentData appointme * @param filter to determine which items to select. * @return list of matching appointments. */ - List findAppointments( Predicate filter ); + List findAppointments(Predicate filter); /** * Finds all appointments for this TimeLine. @@ -162,7 +162,7 @@ Optional addAppointment( LocalDay forDay, AppointmentData appointme * @return list of all appointments. */ default List getAppointments() { - return appointmentStream().collect( Collectors.toList() ); + return appointmentStream().collect(Collectors.toList()); } /** @@ -178,7 +178,7 @@ default List getAppointments() { * @param appointment to search for. * @return true if the Appointment is part of the Timeline, false otherwise. */ - boolean contains( Appointment appointment ); + boolean contains(Appointment appointment); /** @@ -188,7 +188,7 @@ default List getAppointments() { * @param duration the requested duration for an appointment * @return a list of gaps in which the appointment can be scheduled. */ - List getGapsFitting( Duration duration ); + List getGapsFitting(Duration duration); /** * Check if an appointment of the given duration can be scheduled. @@ -196,7 +196,7 @@ default List getAppointments() { * @param duration of the appointment * @return true is there is a sufficiently big gap, false otherwise */ - boolean canAddAppointmentOfDuration( Duration duration ); + boolean canAddAppointmentOfDuration(Duration duration); /** * This method finds all time gaps that can accommodate an appointment of @@ -205,7 +205,7 @@ default List getAppointments() { * @param duration the requested duration for an appointment * @return a list of start times on which an appointment can be scheduled */ - List getGapsFittingReversed( Duration duration ); + List getGapsFittingReversed(Duration duration); /** * Get the gaps matching the given duration, smallest fitting first. @@ -213,7 +213,7 @@ default List getAppointments() { * @param duration required * @return list of all gaps fitting, ordered, smallest gap first. */ - List getGapsFittingSmallestFirst( Duration duration ); + List getGapsFittingSmallestFirst(Duration duration); /** * Get the gaps matching the given duration, largest fitting first. @@ -221,7 +221,7 @@ default List getAppointments() { * @param duration required * @return list of all gaps fitting, ordered, largest gap first. */ - List getGapsFittingLargestFirst( Duration duration ); + List getGapsFittingLargestFirst(Duration duration); /** * Find matching free time slots in this and other TimeLines. To facilitate @@ -231,5 +231,5 @@ default List getAppointments() { * @param other day plans * @return the list of free slots that all DayPlans share. */ - List getMatchingFreeSlotsOfDuration( Duration minLength, List other ); + List getMatchingFreeSlotsOfDuration(Duration minLength, List other); } From 065a8bd6a4361dda78f3e0ca6c7f5eb04f47d507 Mon Sep 17 00:00:00 2001 From: Martijn Bonajo Date: Fri, 6 Sep 2024 13:30:03 +0200 Subject: [PATCH 3/9] ref: Appointment(Request) hold AppointmentData, are not AppointmentData The AppointmentInterface was abused to give functionality to Appointment and AppointmentRequest. Now they only hold a reference to each other, implementer is free to add utility methods to retrieve properties from AppointmentData in e.g. Appointment. --- .../appointmentplanner/api/Appointment.java | 17 +---------------- .../api/AppointmentRequest.java | 3 +-- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/main/java/appointmentplanner/api/Appointment.java b/src/main/java/appointmentplanner/api/Appointment.java index f0eaf08..4f38729 100644 --- a/src/main/java/appointmentplanner/api/Appointment.java +++ b/src/main/java/appointmentplanner/api/Appointment.java @@ -18,22 +18,7 @@ * @author Richard van den Ham {@code r.vandenham@fontys.nl} * @author Pieter van den Hombergh {@code p.vandenhombergh@fontys.nl} */ -public interface Appointment extends TimeSlot, AppointmentData { - - /** - * Get the priority of this appointment. - * - * @return Priority. - */ - @Override - Priority getPriority(); - - /** - * Get the appointment data for this appointment. - * - * @return the data - */ - AppointmentData getAppointmentData(); +public interface Appointment extends TimeSlot { /** * Get the request that led to this appointment. diff --git a/src/main/java/appointmentplanner/api/AppointmentRequest.java b/src/main/java/appointmentplanner/api/AppointmentRequest.java index cf985b6..a9f8144 100644 --- a/src/main/java/appointmentplanner/api/AppointmentRequest.java +++ b/src/main/java/appointmentplanner/api/AppointmentRequest.java @@ -28,7 +28,7 @@ * @author Pieter van den Hombergh * @author Richard van den Ham */ -public interface AppointmentRequest extends AppointmentData { +public interface AppointmentRequest { //TODO Specify how to deal with TimePreferences EARLIEST_AFTER and LATEST_BEFORE together with startTime null @@ -71,7 +71,6 @@ default TimePreference getTimePreference() { * Get the duration of the appointment request. * @return the duration of the request */ - @Override default Duration getDuration() { return getAppointmentData().getDuration(); } From 4bf8b2815630b78dd05e62f1fc209bc07c7099fa Mon Sep 17 00:00:00 2001 From: Martijn Bonajo Date: Fri, 6 Sep 2024 13:53:16 +0200 Subject: [PATCH 4/9] chore: change naming convention for records --- .../appointmentplanner/api/Appointment.java | 23 +------ .../api/AppointmentData.java | 23 +------ .../api/AppointmentRequest.java | 32 +++------ .../java/appointmentplanner/api/LocalDay.java | 65 ++----------------- .../appointmentplanner/api/LocalDayPlan.java | 64 +++++++++--------- .../java/appointmentplanner/api/TimeSlot.java | 26 ++++---- .../java/appointmentplanner/api/Timeline.java | 18 ++--- 7 files changed, 72 insertions(+), 179 deletions(-) diff --git a/src/main/java/appointmentplanner/api/Appointment.java b/src/main/java/appointmentplanner/api/Appointment.java index 4f38729..c0d2cb4 100644 --- a/src/main/java/appointmentplanner/api/Appointment.java +++ b/src/main/java/appointmentplanner/api/Appointment.java @@ -25,32 +25,15 @@ public interface Appointment extends TimeSlot { * * @return the request. */ - AppointmentRequest getRequest(); + AppointmentRequest request(); /** * Override the default toString. toString() returns startTime, endTime, - * description and priority like: "2020-09-12 14:00 - 15:55 ALDA Lesson - * (HIGH)" This will make your testing and debugging life so much easier. + * description and priority like: "2020-09-12 14:00 - 15:55 ALDA Lesson" + * This will make your testing and debugging life so much easier. * * @return String representation of Appointment. */ @Override String toString(); - - /** - * Defines equality. Must be based on all fields of this class. - * - * @param obj the other object to check equality with - * @return true if the two appointments are equal - */ - @Override - public boolean equals(Object obj); - - /** - * Calculate a hash code value for the object. - * - * @return hashCode for this object - */ - @Override - public int hashCode(); } diff --git a/src/main/java/appointmentplanner/api/AppointmentData.java b/src/main/java/appointmentplanner/api/AppointmentData.java index 5676c36..04037ce 100644 --- a/src/main/java/appointmentplanner/api/AppointmentData.java +++ b/src/main/java/appointmentplanner/api/AppointmentData.java @@ -21,21 +21,21 @@ public interface AppointmentData { * * @return the duration of the appointment. */ - Duration getDuration(); + Duration duration(); /** * The description of the appointment. * * @return non-empty string describing the appointment. */ - String getDescription(); + String description(); /** * Get the priority for the appointment. * * @return the priority */ - Priority getPriority(); + Priority priority(); /** * Get the textual representation of AppointmentData. Contains description, @@ -45,21 +45,4 @@ public interface AppointmentData { */ @Override String toString(); - - /** - * Defines equality. Must be based on all fields of this class. - * - * @param obj the other object to check equality with - * @return true if the two appointments are equal - */ - @Override - public boolean equals(Object obj); - - /** - * Calculate a hash code value for the object. - * - * @return hashCode for this object - */ - @Override - public int hashCode(); } diff --git a/src/main/java/appointmentplanner/api/AppointmentRequest.java b/src/main/java/appointmentplanner/api/AppointmentRequest.java index a9f8144..e640c99 100644 --- a/src/main/java/appointmentplanner/api/AppointmentRequest.java +++ b/src/main/java/appointmentplanner/api/AppointmentRequest.java @@ -36,11 +36,12 @@ public interface AppointmentRequest { /** * Get the start time of the intended appointment. * If the time is not specified, this method may return null. + * * @param onDay the LocalDay the time is on. * @return the start time as instant, potentially null. */ - default Instant getStart(LocalDay onDay) { - return onDay.ofLocalTime(getStartTime()); + default Instant start(LocalDay onDay) { + return onDay.ofLocalTime(startTime()); } /** @@ -48,14 +49,14 @@ default Instant getStart(LocalDay onDay) { * * @return the start time */ - LocalTime getStartTime(); + LocalTime startTime(); /** * Get the appointment details of this appointment. * * @return the data */ - AppointmentData getAppointmentData(); + AppointmentData appointmentData(); /** * Time preference given with this appointment request. @@ -63,7 +64,7 @@ default Instant getStart(LocalDay onDay) { * * @return the time preference */ - default TimePreference getTimePreference() { + default TimePreference timePreference() { return TimePreference.UNSPECIFIED; } @@ -71,24 +72,7 @@ default TimePreference getTimePreference() { * Get the duration of the appointment request. * @return the duration of the request */ - default Duration getDuration() { - return getAppointmentData().getDuration(); + default Duration duration() { + return appointmentData().duration(); } - - /** - * Defines equality, must be based on all fields of this class. - * @param obj the other object to check equality with - * @return true if the two appointments are equal - */ - @Override - public boolean equals(Object obj); - - /** - * Calculate a hash code value for the object. - * @return hashCode for this object. - */ - @Override - public int hashCode(); - - } diff --git a/src/main/java/appointmentplanner/api/LocalDay.java b/src/main/java/appointmentplanner/api/LocalDay.java index bf9d03a..359c918 100644 --- a/src/main/java/appointmentplanner/api/LocalDay.java +++ b/src/main/java/appointmentplanner/api/LocalDay.java @@ -11,20 +11,11 @@ * * @author Pieter van den Hombergh {@code p.vandenhombergh@fontys.nl} */ -public class LocalDay { +public record LocalDay(ZoneId zone, LocalDate date) { - private final ZoneId zone; - private final LocalDate date; - - /** - * Create a local day in the given timezone at the given date. - * - * @param zone the timezone to use - * @param date the LocalDate to use - */ - public LocalDay(ZoneId zone, LocalDate date) { - this.zone = zone; - this.date = date; + public LocalDay { + Objects.requireNonNull(zone, "zone cannot be null"); + Objects.requireNonNull(date, "date cannot be null"); } /** @@ -34,23 +25,6 @@ public LocalDay() { this(ZoneId.systemDefault(), LocalDate.now()); } - /** - * Get the date. - * @return the date - */ - public LocalDate getDate() { - return date; - } - - /** - * Get the timezone identifier. - * - * @return timezone identifier - */ - public ZoneId getZone() { - return zone; - } - /** * Get the time as instant. * @@ -110,35 +84,4 @@ public Instant at(int hm, int m) { public static LocalDay now() { return new LocalDay(); } - - @Override - public String toString() { - return "LocalDay{" + "zone=" + zone + ", date=" + date + '}'; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 73 * hash + Objects.hashCode(this.zone); - hash = 73 * hash + Objects.hashCode(this.date); - return hash; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final LocalDay other = (LocalDay) obj; - if (!Objects.equals(this.zone, other.zone)) { - return false; - } - return Objects.equals(this.date, other.date); - } } diff --git a/src/main/java/appointmentplanner/api/LocalDayPlan.java b/src/main/java/appointmentplanner/api/LocalDayPlan.java index efa19b0..9d5e177 100644 --- a/src/main/java/appointmentplanner/api/LocalDayPlan.java +++ b/src/main/java/appointmentplanner/api/LocalDayPlan.java @@ -29,7 +29,7 @@ public interface LocalDayPlan { * * @return the day */ - LocalDay getDay(); + LocalDay day(); /** * Start time of the day, inclusive. @@ -51,15 +51,15 @@ public interface LocalDayPlan { * * @return the timeline used by this LocalDayPlan */ - Timeline getTimeline(); + Timeline timeline(); /** * Get the allowed first time for this day. * * @return the start time of this plan */ - default LocalTime getStartTime() { - return getDay().timeOfInstant(startOfDay()); + default LocalTime startTime() { + return day().timeOfInstant(startOfDay()); } /** @@ -67,8 +67,8 @@ default LocalTime getStartTime() { * * @return the end time in this plan */ - default LocalTime getEndTime() { - return getDay().timeOfInstant(endOfDay()); + default LocalTime endTime() { + return day().timeOfInstant(endOfDay()); } /** @@ -83,7 +83,7 @@ default LocalTime getEndTime() { default Optional addAppointment(AppointmentData appointmentData, LocalTime start, TimePreference fallback) { - return getTimeline().addAppointment(getDay(), appointmentData, start, fallback); + return timeline().addAppointment(day(), appointmentData, start, fallback); } /** @@ -95,7 +95,7 @@ default Optional addAppointment(AppointmentData appointmentData, * @return Optional Appointment */ default Optional addAppointment(AppointmentData appointmentData, LocalTime startTime) { - return getTimeline().addAppointment(getDay(), appointmentData, startTime); + return timeline().addAppointment(day(), appointmentData, startTime); } /** @@ -108,7 +108,7 @@ default Optional addAppointment(AppointmentData appointmentData, Lo * @return Optional Appointment */ default Optional addAppointment(AppointmentData appointmentData, TimePreference preference) { - return getTimeline().addAppointment(getDay(), appointmentData, preference); + return timeline().addAppointment(day(), appointmentData, preference); } /** @@ -118,7 +118,7 @@ default Optional addAppointment(AppointmentData appointmentData, Ti * @return AppointmentRequest, the original appointment request */ default AppointmentRequest removeAppointment(Appointment appointment) { - return getTimeline().removeAppointment(appointment); + return timeline().removeAppointment(appointment); } /** @@ -128,20 +128,20 @@ default AppointmentRequest removeAppointment(Appointment appointment) { * @return all appointment requests of removed appointments */ default List removeAppointments(Predicate filter) { - return getTimeline().removeAppointments(filter); + return timeline().removeAppointments(filter); } /** - * {@link Timeline#getAppointments()}. + * {@link Timeline#appointments()}. * * @return all appointments */ default List getAppointments() { - return getTimeline().getAppointments(); + return timeline().appointments(); } /** - * See {@link Timeline#getMatchingFreeSlotsOfDuration(Duration, List)}. + * See {@link Timeline#findMatchingFreeSlotsOfDuration(Duration, List)}. * * @param duration Minimum duration of the slots * @param plans that could have common gaps @@ -149,47 +149,47 @@ default List getAppointments() { * with a minimum length of duration. */ default List getMatchingFreeSlotsOfDuration(Duration duration, List plans) { - return getTimeline().getMatchingFreeSlotsOfDuration(duration, plans.stream().map(LocalDayPlan::getTimeline).collect(toList())); + return timeline().findMatchingFreeSlotsOfDuration(duration, plans.stream().map(LocalDayPlan::timeline).collect(toList())); } /** - * See {@link Timeline#getGapsFitting(Duration)}. + * See {@link Timeline#findGapsFitting(Duration)}. * * @param duration the minimum duration that should fit * @return list of timeslots that fit the duration */ default List getGapsFitting(Duration duration) { - return getTimeline().getGapsFitting(duration); + return timeline().findGapsFitting(duration); } /** - * {@link Timeline#getGapsFittingReversed(Duration)}. + * {@link Timeline#findGapsFittingReversed(Duration)}. * * @param duration the minimum duration that should fit * @return list of timeslots that fit the duration */ default List getGapsFittingReversed(Duration duration) { - return getTimeline().getGapsFittingReversed(duration); + return timeline().findGapsFittingReversed(duration); } /** - * See{@link Timeline#getGapsFittingLargestFirst(Duration)}. + * See{@link Timeline#findGapsFittingLargestFirst(Duration)}. * * @param duration the minimum duration * @return list of gaps fitting the duration */ default List getGapsFittingLargestFirst(Duration duration) { - return getTimeline().getGapsFittingLargestFirst(duration); + return timeline().findGapsFittingLargestFirst(duration); } /** - * {@link Timeline#getGapsFittingSmallestFirst(Duration)}. + * {@link Timeline#findGapsFittingSmallestFirst(Duration)}. * * @param duration the minimum duration * @return list of timeslots fitting the duration */ default List getGapsFittingSmallestFirst(Duration duration) { - return getTimeline().getGapsFittingSmallestFirst(duration); + return timeline().findGapsFittingSmallestFirst(duration); } /** @@ -199,7 +199,7 @@ default List getGapsFittingSmallestFirst(Duration duration) { * @return true of a gap is available, false otherwise */ default boolean canAddAppointmentOfDuration(Duration duration) { - return getTimeline().canAddAppointmentOfDuration(duration); + return timeline().canAddAppointmentOfDuration(duration); } /** @@ -209,7 +209,7 @@ default boolean canAddAppointmentOfDuration(Duration duration) { * @return list of appointments that fit the filter */ default List findAppointments(Predicate filter) { - return getTimeline().findAppointments(filter); + return timeline().findAppointments(filter); } /** @@ -228,7 +228,7 @@ default List findAppointments(Predicate filter) { * @return true if present, false otherwise */ default boolean contains(Appointment appointment) { - return getTimeline().contains(appointment); + return timeline().contains(appointment); } /** @@ -236,17 +236,17 @@ default boolean contains(Appointment appointment) { * * @return the date according to this LocalDayPlan's time zone */ - default LocalDate getDate() { - return getDay().getDate(); + default LocalDate date() { + return day().date(); } /** - * {@link Timeline#getNrOfAppointments()}. + * {@link Timeline#nrOfAppointments()}. * * @return number of appointments */ - default int getNrOfAppointments() { - return getTimeline().getNrOfAppointments(); + default int nrOfAppointments() { + return timeline().nrOfAppointments(); } /** @@ -257,7 +257,7 @@ default int getNrOfAppointments() { * @return the point in time as Instant */ default Instant at(int hour, int minute) { - return getDay().at(hour, minute); + return day().at(hour, minute); } } diff --git a/src/main/java/appointmentplanner/api/TimeSlot.java b/src/main/java/appointmentplanner/api/TimeSlot.java index 6ecec81..8b49a07 100644 --- a/src/main/java/appointmentplanner/api/TimeSlot.java +++ b/src/main/java/appointmentplanner/api/TimeSlot.java @@ -33,7 +33,7 @@ public interface TimeSlot extends Comparable { * * @return the start time */ - Instant getStart(); + Instant start(); /** * Get the end of the TimeSlot. The end time is NOT included in the @@ -41,7 +41,7 @@ public interface TimeSlot extends Comparable { * * @return the end time */ - Instant getEnd(); + Instant end(); /** * Get the duration of this slot. @@ -51,7 +51,7 @@ public interface TimeSlot extends Comparable { * @return the duration as Duration */ default Duration duration() { - return Duration.between(getStart(), getEnd()); + return Duration.between(start(), end()); } /** @@ -84,8 +84,8 @@ default boolean fits(Duration duration) { * time slot. */ default boolean fits(TimeSlot other) { - return this.getStart().compareTo(other.getStart()) <= 0 - && this.getEnd().compareTo(other.getEnd()) >= 0; + return this.start().compareTo(other.start()) <= 0 + && this.end().compareTo(other.end()) >= 0; } /** @@ -94,8 +94,8 @@ default boolean fits(TimeSlot other) { * @param day for the time * @return end Time. */ - default LocalTime getEndTime(LocalDay day) { - return day.timeOfInstant(getEnd()); + default LocalTime endTime(LocalDay day) { + return day.timeOfInstant(end()); } /** @@ -104,8 +104,8 @@ default LocalTime getEndTime(LocalDay day) { * @param day for the time * @return start Time */ - default LocalTime getStartTime(LocalDay day) { - return day.timeOfInstant(getStart()); + default LocalTime startTime(LocalDay day) { + return day.timeOfInstant(start()); } /** @@ -114,8 +114,8 @@ default LocalTime getStartTime(LocalDay day) { * @param day provides time zone * @return the date on which the TimeSlot starts. */ - default LocalDate getStartDate(LocalDay day) { - return day.dateOfInstant(getStart()); + default LocalDate startDate(LocalDay day) { + return day.dateOfInstant(start()); } /** @@ -124,7 +124,7 @@ default LocalDate getStartDate(LocalDay day) { * @param day provides time zone * @return the date on which the TimeSlot ends. */ - default LocalDate getEndDate(LocalDay day) { - return day.dateOfInstant(getEnd()); + default LocalDate endDate(LocalDay day) { + return day.dateOfInstant(end()); } } diff --git a/src/main/java/appointmentplanner/api/Timeline.java b/src/main/java/appointmentplanner/api/Timeline.java index 9c1349a..ca1f562 100644 --- a/src/main/java/appointmentplanner/api/Timeline.java +++ b/src/main/java/appointmentplanner/api/Timeline.java @@ -34,7 +34,7 @@ public interface Timeline { * * @return Number of appointments on this timeline. */ - int getNrOfAppointments(); + int nrOfAppointments(); /** * Get the number of gaps between start and en of day and between the @@ -110,8 +110,8 @@ public interface Timeline { */ default Optional addAppointment(LocalDay forDay, AppointmentRequest appointmentRequest) { - return addAppointment(forDay, appointmentRequest.getAppointmentData(), - appointmentRequest.getStartTime()); + return addAppointment(forDay, appointmentRequest.appointmentData(), + appointmentRequest.startTime()); } /** @@ -161,7 +161,7 @@ Optional addAppointment(LocalDay forDay, AppointmentData appointmen * * @return list of all appointments. */ - default List getAppointments() { + default List appointments() { return appointmentStream().collect(Collectors.toList()); } @@ -188,7 +188,7 @@ default List getAppointments() { * @param duration the requested duration for an appointment * @return a list of gaps in which the appointment can be scheduled. */ - List getGapsFitting(Duration duration); + List findGapsFitting(Duration duration); /** * Check if an appointment of the given duration can be scheduled. @@ -205,7 +205,7 @@ default List getAppointments() { * @param duration the requested duration for an appointment * @return a list of start times on which an appointment can be scheduled */ - List getGapsFittingReversed(Duration duration); + List findGapsFittingReversed(Duration duration); /** * Get the gaps matching the given duration, smallest fitting first. @@ -213,7 +213,7 @@ default List getAppointments() { * @param duration required * @return list of all gaps fitting, ordered, smallest gap first. */ - List getGapsFittingSmallestFirst(Duration duration); + List findGapsFittingSmallestFirst(Duration duration); /** * Get the gaps matching the given duration, largest fitting first. @@ -221,7 +221,7 @@ default List getAppointments() { * @param duration required * @return list of all gaps fitting, ordered, largest gap first. */ - List getGapsFittingLargestFirst(Duration duration); + List findGapsFittingLargestFirst(Duration duration); /** * Find matching free time slots in this and other TimeLines. To facilitate @@ -231,5 +231,5 @@ default List getAppointments() { * @param other day plans * @return the list of free slots that all DayPlans share. */ - List getMatchingFreeSlotsOfDuration(Duration minLength, List other); + List findMatchingFreeSlotsOfDuration(Duration minLength, List other); } From c96b158eea0ef879268f08c254368258a4767000 Mon Sep 17 00:00:00 2001 From: Martijn Bonajo Date: Fri, 6 Sep 2024 13:56:21 +0200 Subject: [PATCH 5/9] ref: delete Priority as it is never used --- .../api/AbstractAPFactory.java | 20 ++-------------- .../api/AppointmentData.java | 7 ------ .../java/appointmentplanner/api/Priority.java | 24 ------------------- 3 files changed, 2 insertions(+), 49 deletions(-) delete mode 100644 src/main/java/appointmentplanner/api/Priority.java diff --git a/src/main/java/appointmentplanner/api/AbstractAPFactory.java b/src/main/java/appointmentplanner/api/AbstractAPFactory.java index 2570073..81127bb 100644 --- a/src/main/java/appointmentplanner/api/AbstractAPFactory.java +++ b/src/main/java/appointmentplanner/api/AbstractAPFactory.java @@ -37,32 +37,16 @@ default LocalDayPlan createLocalDayPlan(LocalDay day, LocalTime startTime, Local /** * Factory method to create an AppointmentData object without specified - * startTime. The start time will be set (in an Appointment) as soon as the + * startTime. The start time will be set (in an Appointment) as soon as the * appointment is added to the Day schedule. * * @param description of the appointment * @param duration of the appointment - * @param priority of the appointment * @return AppointmentData object. * @throws NullPointerException if any of the parameters are null */ AppointmentData createAppointmentData(String description, - Duration duration, - Priority priority); - - /** - * Factory method to create an AppointmentData object without specified - * startTime. The start time will be set (in an Appointment) as soon as the - * appointment is added to the Day schedule. The priority is set as LOW by default. - * - * @param description of the appointment - * @param duration of the appointment - * @return Appointment object. - * @throws NullPointerException if any of the parameters are null - */ - default AppointmentData createAppointmentData(String description, Duration duration) { - return createAppointmentData(description, duration, Priority.LOW); - } + Duration duration); /** * Create an appointmentRequest with a required start time. diff --git a/src/main/java/appointmentplanner/api/AppointmentData.java b/src/main/java/appointmentplanner/api/AppointmentData.java index 04037ce..60f69ca 100644 --- a/src/main/java/appointmentplanner/api/AppointmentData.java +++ b/src/main/java/appointmentplanner/api/AppointmentData.java @@ -30,13 +30,6 @@ public interface AppointmentData { */ String description(); - /** - * Get the priority for the appointment. - * - * @return the priority - */ - Priority priority(); - /** * Get the textual representation of AppointmentData. Contains description, * duration and priority. diff --git a/src/main/java/appointmentplanner/api/Priority.java b/src/main/java/appointmentplanner/api/Priority.java deleted file mode 100644 index de5ad90..0000000 --- a/src/main/java/appointmentplanner/api/Priority.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2019 Informatics Fontys FHTenL University of Applied Science Venlo - */ -package appointmentplanner.api; - -/** - * Priority of appointments (not used as part of scheduling). - * - * @author Pieter van den Hombergh {@code p.vandenhombergh@fontys.nl} - */ -public enum Priority { - /** - * Low priority. - */ - LOW, - /** - * Medium priority. - */ - MEDIUM, - /** - * High priority. - */ - HIGH -} From b9f367db62e344ee62b4a1218a2f914fd058f6a2 Mon Sep 17 00:00:00 2001 From: Martijn Bonajo Date: Fri, 6 Sep 2024 13:59:56 +0200 Subject: [PATCH 6/9] docs: clarify what happens with invalid time preference If the addAppointment without a fixed time is called with a time preference of EARLIEST_BEFORE or LATEST_AFTER, it is changed to EARLIEST --- src/main/java/appointmentplanner/api/LocalDayPlan.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/appointmentplanner/api/LocalDayPlan.java b/src/main/java/appointmentplanner/api/LocalDayPlan.java index 9d5e177..5bedc23 100644 --- a/src/main/java/appointmentplanner/api/LocalDayPlan.java +++ b/src/main/java/appointmentplanner/api/LocalDayPlan.java @@ -99,9 +99,10 @@ default Optional addAppointment(AppointmentData appointmentData, Lo } /** - * Add and appointment with time preference. This request can fail (Optional - * is not present) if the data's duration does not fit in the (already - * planned day). + * Add and appointment with time preference. This request can fail (Optional is not present) + * if the data's duration does not fit in the (already planned day). + * + * This method only supports TimePreferences EARLIEST or LATEST; Other values are defaulted to EARLIEST * * @param appointmentData data * @param preference time preference From 55825f4a51ac0989c0a8c7c6da0ea8e5021e107e Mon Sep 17 00:00:00 2001 From: Martijn Bonajo Date: Fri, 6 Sep 2024 15:48:11 +0200 Subject: [PATCH 7/9] docs: remove mention of priority --- src/main/java/appointmentplanner/api/Appointment.java | 4 ++-- src/main/java/appointmentplanner/api/AppointmentData.java | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/appointmentplanner/api/Appointment.java b/src/main/java/appointmentplanner/api/Appointment.java index c0d2cb4..bd8da72 100644 --- a/src/main/java/appointmentplanner/api/Appointment.java +++ b/src/main/java/appointmentplanner/api/Appointment.java @@ -28,8 +28,8 @@ public interface Appointment extends TimeSlot { AppointmentRequest request(); /** - * Override the default toString. toString() returns startTime, endTime, - * description and priority like: "2020-09-12 14:00 - 15:55 ALDA Lesson" + * Override the default toString. toString() returns startTime, endTime and description + * like: "2020-09-12 14:00 - 15:55 ALDA Lesson" * This will make your testing and debugging life so much easier. * * @return String representation of Appointment. diff --git a/src/main/java/appointmentplanner/api/AppointmentData.java b/src/main/java/appointmentplanner/api/AppointmentData.java index 60f69ca..2572242 100644 --- a/src/main/java/appointmentplanner/api/AppointmentData.java +++ b/src/main/java/appointmentplanner/api/AppointmentData.java @@ -9,7 +9,7 @@ * taking 45 minutes. * * Another example is having a treatment at a dentist or a beauty parlor. The - * duration, priority, and description are known, but there is no time or date + * duration and description are known, but there is no time or date * allocated yet. * * @author Pieter van den Hombergh {@code p.vandenhombergh@fontys.nl} @@ -31,8 +31,7 @@ public interface AppointmentData { String description(); /** - * Get the textual representation of AppointmentData. Contains description, - * duration and priority. + * Get the textual representation of AppointmentData. Contains description and duration. * * @return AppointmentData text. */ From 29bf2a7ebf3c4f2607353bad40beac416ad9ab47 Mon Sep 17 00:00:00 2001 From: Martijn Bonajo Date: Fri, 6 Sep 2024 15:54:18 +0200 Subject: [PATCH 8/9] ci: update java version --- .github/workflows/pullrequest.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 59d2f13..c5ebe16 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -10,11 +10,11 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: - java-version: '17' + java-version: '21' distribution: 'temurin' cache: maven - name: Make sure that the API can compile From fe369ce698966172746b8b4c728eb2d0c2c77965 Mon Sep 17 00:00:00 2001 From: Martijn Bonajo Date: Fri, 6 Sep 2024 15:58:20 +0200 Subject: [PATCH 9/9] docs: add missing javadoc --- src/main/java/appointmentplanner/api/LocalDay.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/appointmentplanner/api/LocalDay.java b/src/main/java/appointmentplanner/api/LocalDay.java index 359c918..cea67c1 100644 --- a/src/main/java/appointmentplanner/api/LocalDay.java +++ b/src/main/java/appointmentplanner/api/LocalDay.java @@ -13,6 +13,11 @@ */ public record LocalDay(ZoneId zone, LocalDate date) { + /** + * Default constructor. Make sure zone and date are not null. + * @param zone the zoneId + * @param date the date + */ public LocalDay { Objects.requireNonNull(zone, "zone cannot be null"); Objects.requireNonNull(date, "date cannot be null");