Skip to content
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

Feature/10 conditional holidays #22

Merged
merged 7 commits into from
Jun 19, 2021
Merged

Conversation

ckunki
Copy link
Collaborator

@ckunki ckunki commented Jun 8, 2021

fixes #10

@ckunki ckunki requested a review from kaklakariada June 8, 2021 12:18
@Override
public boolean applies(Year year) {
if (pivot == null) {
throw new UnspecifiedPivotDateException("Cannot apply DayOfWeekCondition with unspecified pivot date.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If pivot is mandatory, you should make it a final field and check that it is not null in the constructor. If you want to keep withPivotDate() for constructing an object, consider using a builder.

Copy link
Collaborator Author

@ckunki ckunki Jun 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, if I understood correctly.

My idea was to support two flavors of Conditions:

  • a) with individual pivot date
  • b) with pivot date inherited from Holiday, example:
    Condition isSunday = new DayOfWeekCondition(DayOfWeek.SUNDAY);
    Holiday KONINGSDAG = new FixedDateHoliday("holiday", "Koningsdag", MonthDay.of(4, 27))
    .withAlternative(isSunday, MonthDay.of(4, 26));

In case b) the isolated condition is incomplete and unusable as long as it is not added to a holiday.

Do I understand your proposal correctly then, to

  1. create a class ConditionBuilder and
  2. pass an instance of that to Holiday
  3. in order to instantiate the Condition
    • only after that and
    • from within the holiday instance and
    • including the pivot date copied from the date of the holiday?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next step: try approach as described above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kaklakariada, I started to use a builder for conditions and it feels quite good, see branch 28-refactor-conditional-holidays.

I plan to use a builder for Holidays, too.
Stay tuned for updates 😄

@kaklakariada kaklakariada merged commit 5a2c855 into main Jun 19, 2021
@kaklakariada kaklakariada deleted the Feature/10-Conditional-holidays branch June 19, 2021 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for conditional holidays
2 participants