-
Notifications
You must be signed in to change notification settings - Fork 147
Feat: Joiners contains and containedIn #972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces new specialized Joiners (contain, containedIn, and containAny) to replace generic filtering joiners in the conference scheduling constraint provider, improving code readability and expressiveness while maintaining semantic equivalence.
Changes:
- Replaced individual Joiners static imports with a wildcard import
- Refactored 10 constraint methods to use new specialized joiners instead of
filteringlambdas - Maintained all existing penalty calculations and scoring logic
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import static ai.timefold.solver.core.api.score.stream.Joiners.greaterThan; | ||
| import static ai.timefold.solver.core.api.score.stream.Joiners.lessThan; | ||
| import static ai.timefold.solver.core.api.score.stream.Joiners.overlapping; | ||
| import static ai.timefold.solver.core.api.score.stream.Joiners.*; |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wildcard static imports can reduce code clarity and IDE support. Consider using explicit imports for each Joiner method (equal, greaterThan, lessThan, overlapping, filtering, contain, containedIn, containAny) to improve code maintainability and make dependencies more explicit.
| import static ai.timefold.solver.core.api.score.stream.Joiners.*; | |
| import static ai.timefold.solver.core.api.score.stream.Joiners.equal; | |
| import static ai.timefold.solver.core.api.score.stream.Joiners.greaterThan; | |
| import static ai.timefold.solver.core.api.score.stream.Joiners.lessThan; | |
| import static ai.timefold.solver.core.api.score.stream.Joiners.overlapping; | |
| import static ai.timefold.solver.core.api.score.stream.Joiners.filtering; | |
| import static ai.timefold.solver.core.api.score.stream.Joiners.contain; | |
| import static ai.timefold.solver.core.api.score.stream.Joiners.containedIn; | |
| import static ai.timefold.solver.core.api.score.stream.Joiners.containAny; |
| .join(Speaker.class, | ||
| filtering((talk, speaker) -> talk.hasSpeaker(speaker) | ||
| && speaker.getUnavailableTimeslots().contains(talk.getTimeslot()))) | ||
| contain(Talk::getSpeakers, speaker -> speaker), |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lambda expression speaker -> speaker is an identity function. Depending on the API design, this could potentially be simplified to a method reference or omitted if the API supports it. Verify if the Joiners API provides a simpler alternative for identity mapping.
Uh oh!
There was an error while loading. Please reload this page.