Skip to content

Commit

Permalink
Merge pull request #6 from FontysVenlo/v2024
Browse files Browse the repository at this point in the history
V2024
  • Loading branch information
Bonajo authored Sep 6, 2024
2 parents b5d5139 + fe369ce commit 4fbdc4f
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 313 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<parent>
<groupId>io.github.fontysvenlo</groupId>
<artifactId>informaticspom</artifactId>
<version>1.3.3</version>
<version>1.3</version>
</parent>
<groupId>io.github.fontysvenlo.alda</groupId>
<artifactId>appointmentplanner_api</artifactId>
<version>1.2.2</version>
<version>1.3</version>
<packaging>jar</packaging>
<name>ALDA AppointmentPlanner API</name>
<properties>
Expand Down
50 changes: 17 additions & 33 deletions src/main/java/appointmentplanner/api/AbstractAPFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand All @@ -32,37 +32,21 @@ 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);


/**
* 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 );
}
AppointmentData createAppointmentData(String description,
Duration duration);

/**
* Create an appointmentRequest with a required start time.
Expand All @@ -71,8 +55,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);
}

/**
Expand All @@ -82,8 +66,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);
}

/**
Expand All @@ -95,9 +79,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.
Expand All @@ -106,7 +90,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.
Expand All @@ -119,10 +103,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);
}
}
42 changes: 5 additions & 37 deletions src/main/java/appointmentplanner/api/Appointment.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,54 +18,22 @@
* @author Richard van den Ham {@code [email protected]}
* @author Pieter van den Hombergh {@code [email protected]}
*/
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.
*
* @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.
* 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.
*/
@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();
}
33 changes: 4 additions & 29 deletions src/main/java/appointmentplanner/api/AppointmentData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]}
Expand All @@ -21,45 +21,20 @@ 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();

/**
* Get the textual representation of AppointmentData. Contains description,
* duration and priority.
* Get the textual representation of AppointmentData. Contains description and duration.
*
* @return AppointmentData text.
*/
@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();
}
35 changes: 9 additions & 26 deletions src/main/java/appointmentplanner/api/AppointmentRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,68 +28,51 @@
* @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


/**
* 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());
}

/**
* Get the requested local start time.
*
* @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.
* The default is TimePreference.UNSPECIFIED.
*
* @return the time preference
*/
default TimePreference getTimePreference() {
default TimePreference timePreference() {
return TimePreference.UNSPECIFIED;
}

/**
* Get the duration of the appointment request.
* @return the duration of the request
*/
@Override
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();


}
Loading

0 comments on commit 4fbdc4f

Please sign in to comment.