diff --git a/optaplanner-examples/src/main/java/org/optaplanner/examples/flightcrewscheduling/domain/Flight.java b/optaplanner-examples/src/main/java/org/optaplanner/examples/flightcrewscheduling/domain/Flight.java index 23cdff3c061..89de59e9201 100644 --- a/optaplanner-examples/src/main/java/org/optaplanner/examples/flightcrewscheduling/domain/Flight.java +++ b/optaplanner-examples/src/main/java/org/optaplanner/examples/flightcrewscheduling/domain/Flight.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Red Hat, Inc. and/or its affiliates. + * Copyright 2022 Red Hat, Inc. and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,11 +26,11 @@ public class Flight extends AbstractPersistable implements Comparable { - private static final Comparator COMPARATOR = Comparator.comparing(Flight::getDepartureUTCDate) + private static final Comparator COMPARATOR = Comparator.comparing(Flight::getDepartureUTCDateTime) .thenComparing(Flight::getDepartureAirport) - .thenComparing(Flight::getDepartureUTCDateTime) + .thenComparing(Flight::getArrivalUTCDateTime) .thenComparing(Flight::getArrivalAirport) - .thenComparing(Flight::getArrivalUTCDateTime); + .thenComparing(Flight::getFlightNumber); private String flightNumber; private Airport departureAirport; diff --git a/optaplanner-examples/src/main/java/org/optaplanner/examples/flightcrewscheduling/domain/FlightAssignment.java b/optaplanner-examples/src/main/java/org/optaplanner/examples/flightcrewscheduling/domain/FlightAssignment.java index 2a80574fa44..a065cfc349f 100644 --- a/optaplanner-examples/src/main/java/org/optaplanner/examples/flightcrewscheduling/domain/FlightAssignment.java +++ b/optaplanner-examples/src/main/java/org/optaplanner/examples/flightcrewscheduling/domain/FlightAssignment.java @@ -1,5 +1,5 @@ /* - * Copyright 2018 Red Hat, Inc. and/or its affiliates. + * Copyright 2022 Red Hat, Inc. and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,9 +25,8 @@ @PlanningEntity public class FlightAssignment extends AbstractPersistable implements Comparable { - private static final Comparator PILLAR_SEQUENCE_COMPARATOR = Comparator - .comparing((FlightAssignment a) -> a.getFlight().getDepartureUTCDateTime()) - .thenComparing(a -> a.getFlight().getArrivalUTCDateTime()) + // Needs to be kept consistent with equals on account of Employee's flightAssignmentSet, which is a SortedSet. + private static final Comparator COMPARATOR = Comparator.comparing(FlightAssignment::getFlight) .thenComparing(FlightAssignment::getIndexInFlight); private Flight flight; @@ -87,6 +86,6 @@ public void setEmployee(Employee employee) { @Override public int compareTo(FlightAssignment o) { - return PILLAR_SEQUENCE_COMPARATOR.compare(this, o); + return COMPARATOR.compare(this, o); } }