diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 2c4c16a..077da42 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -25,9 +25,6 @@ jobs:
with:
fetch-depth: 2
- - run: git checkout HEAD^2
- if: ${{ github.event_name == 'pull_request' }}
-
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 77f3a08..976e381 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-## [0.2.1] - unreleased
+## [0.2.2] - unreleased
+
+## [0.2.1] - 2024-07-07
- [#30](https://github.com/itsallcode/holiday-calculator/issues/30) Updated and enhanced [README.md](README.md).
- [#53](https://github.com/itsallcode/holiday-calculator/pull/53) Upgrade dependencies.
diff --git a/README.md b/README.md
index 2279964..073e391 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ repositories {
mavenCentral()
}
dependencies {
- compile 'org.itsallcode:holiday-calculator:0.2.0'
+ compile 'org.itsallcode:holiday-calculator:0.2.1'
}
```
@@ -43,7 +43,7 @@ dependencies {
org.itsallcode
holiday-calculator
- 0.2.0
+ 0.2.1
```
diff --git a/build.gradle b/build.gradle
index 11d0468..c389446 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,7 +3,6 @@ plugins {
id 'signing'
id 'maven-publish'
id 'jacoco'
- id 'com.github.hierynomus.license' version '0.16.1'
id 'org.sonarqube' version '5.1.0.4882'
id "io.github.gradle-nexus.publish-plugin" version "2.0.0"
id "com.github.ben-manes.versions" version '0.51.0'
@@ -73,15 +72,6 @@ testing {
}
}
-license {
- header = file('gradle/license-header.txt')
- ext.project = 'holiday-calculator'
- ext.year = 2022
- ext.name = 'itsallcode'
- ext.email = 'github@kuhnke.net'
- include '**/*.java'
-}
-
jacocoTestReport {
dependsOn test
reports {
diff --git a/gradle/license-header.txt b/gradle/license-header.txt
deleted file mode 100644
index a5a78e6..0000000
--- a/gradle/license-header.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-${project}
-Copyright (C) ${year} ${name} <${email}>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/Easter.java b/src/main/java/org/itsallcode/holidays/calculator/logic/Easter.java
index 2b2487c..83fdd15 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/Easter.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/Easter.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic;
import java.time.LocalDate;
@@ -89,4 +72,4 @@ public static LocalDate orthodox(int year) {
return LocalDate.of(year, 5, day - 30);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/Formatter.java b/src/main/java/org/itsallcode/holidays/calculator/logic/Formatter.java
index 7b05fd2..137bfb6 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/Formatter.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/Formatter.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic;
import java.time.DayOfWeek;
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/HolidaySet.java b/src/main/java/org/itsallcode/holidays/calculator/logic/HolidaySet.java
index 553c558..b39f1db 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/HolidaySet.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/HolidaySet.java
@@ -1,30 +1,7 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic;
import java.time.LocalDate;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
import org.itsallcode.holidays.calculator.logic.variants.Holiday;
@@ -65,7 +42,7 @@ public HolidaySet(final Collection definitions) {
* @return List of holidays occurring on the given date. If there is no holiday
* on given date, then list is empty.
*/
- public List instances(LocalDate date) {
+ public List instances(final LocalDate date) {
cacheHolidays(date.getYear());
final List instances = holidayInstances.get(date);
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/Condition.java b/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/Condition.java
index f68da6e..752a2ba 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/Condition.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/Condition.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.conditions;
import java.time.MonthDay;
@@ -36,7 +19,7 @@ public abstract class Condition {
* @param other other condition to be negated
* @return new condition
*/
- public static final Condition not(Condition other) {
+ public static final Condition not(final Condition other) {
return new NegatedCondition(other);
}
@@ -71,7 +54,7 @@ public Condition() {
* @param pivot pivot date
* @return self for fluent programming
*/
- public Condition withPivotDate(MonthDay pivot) {
+ public Condition withPivotDate(final MonthDay pivot) {
return this;
}
@@ -88,7 +71,7 @@ public String toString() {
* @return string representation of the current condition using the specified
* prefix.
*/
- public String toString(String prefix) {
+ public String toString(final String prefix) {
return toString(prefix, false);
}
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/ConstantCondition.java b/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/ConstantCondition.java
index acd3eda..a5a0c8b 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/ConstantCondition.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/ConstantCondition.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.conditions;
import java.time.Year;
@@ -33,12 +16,12 @@ public class ConstantCondition extends Condition {
*
* @param value value for the constant condition
*/
- public ConstantCondition(boolean value) {
+ public ConstantCondition(final boolean value) {
this.value = value;
}
@Override
- public boolean applies(Year year) {
+ public boolean applies(final Year year) {
return value;
}
@@ -52,7 +35,7 @@ public boolean isValue() {
}
@Override
- public String toString(String prefix, boolean negated) {
+ public String toString(final String prefix, final boolean negated) {
return ((negated ? !value : value) ? "" : "never");
}
@@ -62,7 +45,7 @@ public int hashCode() {
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/DayOfWeekCondition.java b/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/DayOfWeekCondition.java
index f657512..4950a41 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/DayOfWeekCondition.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/DayOfWeekCondition.java
@@ -1,31 +1,9 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.conditions;
import static java.util.stream.Collectors.joining;
-import java.time.DayOfWeek;
-import java.time.MonthDay;
-import java.time.Year;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Set;
+import java.time.*;
+import java.util.*;
import org.itsallcode.holidays.calculator.logic.Formatter;
@@ -50,7 +28,7 @@ public class DayOfWeekCondition extends Condition {
* @param daysOfWeek days of the week on which the current condition shall be
* {@code true}.
*/
- public DayOfWeekCondition(DayOfWeek... daysOfWeek) {
+ public DayOfWeekCondition(final DayOfWeek... daysOfWeek) {
this(null, daysOfWeek);
}
@@ -61,18 +39,18 @@ public DayOfWeekCondition(DayOfWeek... daysOfWeek) {
* @param pivot pivot date
* @param daysOfWeek days of the week
*/
- public DayOfWeekCondition(MonthDay pivot, DayOfWeek... daysOfWeek) {
+ public DayOfWeekCondition(final MonthDay pivot, final DayOfWeek... daysOfWeek) {
this.pivot = pivot;
this.daysOfWeek.addAll(Arrays.asList(daysOfWeek));
}
@Override
- public boolean applies(Year year) {
+ public boolean applies(final Year year) {
return daysOfWeek.contains(year.atMonthDay(pivot).getDayOfWeek());
}
@Override
- public Condition withPivotDate(MonthDay pivot) {
+ public Condition withPivotDate(final MonthDay pivot) {
if (this.pivot == null) {
this.pivot = pivot;
}
@@ -80,7 +58,7 @@ public Condition withPivotDate(MonthDay pivot) {
}
@Override
- public String toString(String prefix, boolean negated) {
+ public String toString(final String prefix, final boolean negated) {
final String days = Arrays.asList(daysOfWeek.toArray(new DayOfWeek[0]))
.stream()
.sorted(DayOfWeek::compareTo)
@@ -99,7 +77,7 @@ public int hashCode() {
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/NegatedCondition.java b/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/NegatedCondition.java
index 392a90b..c2bec2d 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/NegatedCondition.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/NegatedCondition.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.conditions;
import java.time.Year;
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/builder/ConditionBuilder.java b/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/builder/ConditionBuilder.java
index f3eac44..53d8948 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/builder/ConditionBuilder.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/conditions/builder/ConditionBuilder.java
@@ -1,28 +1,10 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.conditions.builder;
import java.time.DayOfWeek;
import java.time.MonthDay;
+import java.util.List;
-import org.itsallcode.holidays.calculator.logic.conditions.Condition;
-import org.itsallcode.holidays.calculator.logic.conditions.DayOfWeekCondition;
-import org.itsallcode.holidays.calculator.logic.conditions.NegatedCondition;
+import org.itsallcode.holidays.calculator.logic.conditions.*;
import org.itsallcode.holidays.calculator.logic.variants.Holiday;
/**
@@ -73,8 +55,8 @@ public Condition build() {
* @param daysOfWeek days of the week.
* @return self for fluent programming
*/
- public ConditionBuilder withDaysOfWeek(DayOfWeek... daysOfWeek) {
- this.daysOfWeek = daysOfWeek;
+ public ConditionBuilder withDaysOfWeek(final List daysOfWeek) {
+ this.daysOfWeek = daysOfWeek.toArray(DayOfWeek[]::new);
return this;
}
@@ -86,7 +68,7 @@ public ConditionBuilder withDaysOfWeek(DayOfWeek... daysOfWeek) {
* @param monthDay month and day
* @return self for fluent programming
*/
- public ConditionBuilder withPivotDate(MonthDay monthDay) {
+ public ConditionBuilder withPivotDate(final MonthDay monthDay) {
this.pivotDate = monthDay;
return this;
}
@@ -99,7 +81,7 @@ public ConditionBuilder withPivotDate(MonthDay monthDay) {
* @param holiday holiday to use as optional pivot date
* @return self for fluent programming
*/
- public ConditionBuilder withOptionalPivotDateFrom(Holiday holiday) {
+ public ConditionBuilder withOptionalPivotDateFrom(final Holiday holiday) {
if (pivotDate == null) {
this.pivotDate = holiday.getMonthDay();
}
@@ -116,5 +98,4 @@ public ConditionBuilder negated() {
this.negated = !this.negated;
return this;
}
-
}
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/AbbreviationParser.java b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/AbbreviationParser.java
index 27c0769..5addc75 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/AbbreviationParser.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/AbbreviationParser.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.parser;
import java.util.HashMap;
@@ -27,8 +10,8 @@
public class AbbreviationParser> {
/**
- * Exception indicating an ambiguous abbreviation for the name of a month or
- * day of the week, e.g. "T" for the day of the week that could either mean
+ * Exception indicating an ambiguous abbreviation for the name of a month or day
+ * of the week, e.g. "T" for the day of the week that could either mean
* "Tuesday" or "Thursday".
*/
public static class AmbigueAbbreviationException extends RuntimeException {
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/HolidayParser.java b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/HolidayParser.java
index d2ae297..cdddf65 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/HolidayParser.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/HolidayParser.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.parser;
import org.itsallcode.holidays.calculator.logic.parser.matcher.HolidayMatcher;
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/HolidaysFileParser.java b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/HolidaysFileParser.java
index 572dc5e..cda53d1 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/HolidaysFileParser.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/HolidaysFileParser.java
@@ -1,26 +1,6 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.parser;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
+import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/Token.java b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/Token.java
index 798baa5..d400711 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/Token.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/Token.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.parser;
import java.util.regex.Pattern;
@@ -65,8 +48,9 @@ public static Pattern buildRegexp(final Object... elements) {
public final String pattern;
/**
- * Each token is represented as a named-group in the returned regular expression.
- * This way you can get the token's match data by specifying its group-name.
+ * Each token is represented as a named-group in the returned regular
+ * expression. This way you can get the token's match data by specifying its
+ * group-name.
*
* @param groupName name of the token's regex group
* @param pattern regex pattern to match the token
@@ -84,4 +68,4 @@ public Token(String groupName, String pattern) {
public String getRegex() {
return String.format("(?<%s>%s)", groupName, pattern);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/EasterBasedMatcher.java b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/EasterBasedMatcher.java
index a0b1663..5d24bcd 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/EasterBasedMatcher.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/EasterBasedMatcher.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.parser.matcher;
import java.util.regex.Matcher;
@@ -34,4 +17,4 @@ Holiday createHoliday(Matcher matcher) {
matcher.group(Patterns.NAME_GROUP),
Integer.parseInt(matcher.group(Patterns.OFFSET_GROUP)));
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/FixedDateMatcher.java b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/FixedDateMatcher.java
index 8ba934c..e7a327a 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/FixedDateMatcher.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/FixedDateMatcher.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.parser.matcher;
import java.time.MonthDay;
@@ -22,10 +5,7 @@
import java.util.regex.Pattern;
import org.itsallcode.holidays.calculator.logic.conditions.builder.ConditionBuilder;
-import org.itsallcode.holidays.calculator.logic.variants.ConditionalHoliday;
-import org.itsallcode.holidays.calculator.logic.variants.FixedDateHoliday;
-import org.itsallcode.holidays.calculator.logic.variants.Holiday;
-import org.itsallcode.holidays.calculator.logic.variants.HolidayWithAlternative;
+import org.itsallcode.holidays.calculator.logic.variants.*;
class FixedDateMatcher extends HolidayMatcher {
FixedDateMatcher() {
@@ -33,7 +13,7 @@ class FixedDateMatcher extends HolidayMatcher {
}
@Override
- FixedDateHoliday createHoliday(Matcher matcher) {
+ FixedDateHoliday createHoliday(final Matcher matcher) {
return new FixedDateHoliday(
matcher.group(Patterns.CATEGORY_GROUP),
matcher.group(Patterns.NAME_GROUP),
@@ -46,7 +26,7 @@ static class Conditional extends HolidayMatcher {
}
@Override
- Holiday createHoliday(Matcher matcher) {
+ Holiday createHoliday(final Matcher matcher) {
final ConditionBuilder conditionBuilder = createConditionBuilder(matcher) //
.withPivotDate(monthDay(matcher, Patterns.MONTH_GROUP_2, Patterns.DAY_GROUP_2));
return new ConditionalHoliday( //
@@ -58,13 +38,13 @@ Holiday createHoliday(Matcher matcher) {
static class Alternative extends HolidayMatcher {
private final boolean negated;
- Alternative(Pattern pattern) {
+ Alternative(final Pattern pattern) {
super(new FixedDateMatcher(), pattern);
this.negated = (pattern == Patterns.ALTERNATIVE_DATE_HOLIDAY_NEGATED_DAY_OF_WEEK);
}
@Override
- Holiday createHoliday(Matcher matcher) {
+ Holiday createHoliday(final Matcher matcher) {
final MonthDay originalDate = monthDay(matcher, Patterns.MONTH_GROUP, Patterns.DAY_GROUP);
final ConditionBuilder conditionBuilder = createConditionBuilder(matcher).withPivotDate(originalDate);
final MonthDay alternateDate = monthDay(matcher, Patterns.MONTH_GROUP_2, Patterns.DAY_GROUP_2);
@@ -74,4 +54,4 @@ Holiday createHoliday(Matcher matcher) {
alternateDate);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/FloatingDateMatcher.java b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/FloatingDateMatcher.java
index 65cc537..d69b6b1 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/FloatingDateMatcher.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/FloatingDateMatcher.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.parser.matcher;
import java.time.DayOfWeek;
@@ -32,7 +15,7 @@ class FloatingDateMatcher extends HolidayMatcher {
}
@Override
- Holiday createHoliday(Matcher matcher) {
+ Holiday createHoliday(final Matcher matcher) {
final DayOfWeek dayOfWeek = dayOfWeek(matcher.group(Patterns.DAY_OF_WEEK_GROUP));
if (dayOfWeek == null) {
return null;
@@ -59,10 +42,10 @@ static class OffsetMatcher extends HolidayMatcher {
}
@Override
- Holiday createHoliday(Matcher matcher) {
+ Holiday createHoliday(final Matcher matcher) {
final Direction direction = Direction.parse(matcher.group(Patterns.DIRECTION_GROUP_2));
final int offset = Integer.parseInt(matcher.group(Patterns.OFFSET_GROUP_2));
return createOriginalHoliday(matcher).withOffsetInDays(direction == Direction.BEFORE ? -offset : offset);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/HolidayMatcher.java b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/HolidayMatcher.java
index 20b725d..744a27c 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/HolidayMatcher.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/HolidayMatcher.java
@@ -1,28 +1,8 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.parser.matcher;
-import static java.util.stream.Collectors.toList;
-
-import java.time.DayOfWeek;
-import java.time.Month;
-import java.time.MonthDay;
+import java.time.*;
import java.util.Arrays;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -35,28 +15,6 @@
*/
public abstract class HolidayMatcher {
- /**
- * Return a list of all available holiday specification matchers.
- *
- * @return list of available matchers
- */
- public static HolidayMatcher[] matchers() {
- return new HolidayMatcher[] {
- new NegatedConditionMatcher(new FixedDateMatcher(),
- Patterns.FIXED_HOLIDAY_CONDITIONAL_NEGATED),
- new FixedDateMatcher.Conditional(),
- new FixedDateMatcher(),
- new FixedDateMatcher.Alternative(Patterns.ALTERNATIVE_DATE_HOLIDAY_NEGATED_DAY_OF_WEEK),
- new FixedDateMatcher.Alternative(Patterns.ALTERNATIVE_DATE_HOLIDAY),
- new FloatingDateMatcher.OffsetMatcher(),
- new FloatingDateMatcher(),
- new EasterBasedMatcher(),
- new OrthodoxEasterBasedMatcher()
- };
- }
-
- abstract Holiday createHoliday(Matcher matcher);
-
private static final Pattern MONTH_NAME_PATTERN = Pattern.compile(
Patterns.NAME_REGEXP, Pattern.CASE_INSENSITIVE);
@@ -73,7 +31,7 @@ public static HolidayMatcher[] matchers() {
* @param pattern pattern for detecting the current matcher to be used for
* parsing the holiday from the specification.
*/
- protected HolidayMatcher(Pattern pattern) {
+ protected HolidayMatcher(final Pattern pattern) {
this(null, pattern);
}
@@ -87,11 +45,33 @@ protected HolidayMatcher(Pattern pattern) {
* @param pattern pattern for detecting the current matcher to be used
* for parsing the holiday from the specification.
*/
- protected HolidayMatcher(HolidayMatcher originalMatcher, Pattern pattern) {
+ protected HolidayMatcher(final HolidayMatcher originalMatcher, final Pattern pattern) {
this.originalMatcher = originalMatcher;
this.pattern = pattern;
}
+ /**
+ * Return a list of all available holiday specification matchers.
+ *
+ * @return list of available matchers
+ */
+ public static HolidayMatcher[] matchers() {
+ return new HolidayMatcher[] {
+ new NegatedConditionMatcher(new FixedDateMatcher(),
+ Patterns.FIXED_HOLIDAY_CONDITIONAL_NEGATED),
+ new FixedDateMatcher.Conditional(),
+ new FixedDateMatcher(),
+ new FixedDateMatcher.Alternative(Patterns.ALTERNATIVE_DATE_HOLIDAY_NEGATED_DAY_OF_WEEK),
+ new FixedDateMatcher.Alternative(Patterns.ALTERNATIVE_DATE_HOLIDAY),
+ new FloatingDateMatcher.OffsetMatcher(),
+ new FloatingDateMatcher(),
+ new EasterBasedMatcher(),
+ new OrthodoxEasterBasedMatcher()
+ };
+ }
+
+ abstract Holiday createHoliday(Matcher matcher);
+
/**
* Return the original holiday specified, e.g. if the condition is
* {@code false}.
@@ -100,7 +80,7 @@ protected HolidayMatcher(HolidayMatcher originalMatcher, Pattern pattern) {
* the original holiday
* @return the original holiday
*/
- protected Holiday createOriginalHoliday(Matcher matcher) {
+ protected Holiday createOriginalHoliday(final Matcher matcher) {
return originalMatcher.createHoliday(matcher);
}
@@ -110,7 +90,7 @@ protected Holiday createOriginalHoliday(Matcher matcher) {
* @param line textual specification for the holiday
* @return holiday parsed from the specification
*/
- public Holiday createHoliday(String line) {
+ public Holiday createHoliday(final String line) {
final Matcher matcher = pattern.matcher(line);
if (!matcher.matches()) {
return null;
@@ -124,7 +104,7 @@ public Holiday createHoliday(String line) {
* @param arg (abbreviated) name of month or number as String
* @return number of month as integer
*/
- protected int monthNumber(String arg) {
+ protected int monthNumber(final String arg) {
if (MONTH_NAME_PATTERN.matcher(arg).matches()) {
return monthNameParser.getEnumFor(arg).getValue();
} else {
@@ -141,7 +121,7 @@ protected int monthNumber(String arg) {
* from
* @return {@link MonthDay} instance
*/
- protected MonthDay monthDay(Matcher matcher, String monthGroup, String dayGroup) {
+ protected MonthDay monthDay(final Matcher matcher, final String monthGroup, final String dayGroup) {
return MonthDay.of(monthNumber(matcher.group(monthGroup)), Integer.parseInt(matcher.group(dayGroup)));
}
@@ -154,7 +134,7 @@ protected MonthDay monthDay(Matcher matcher, String monthGroup, String dayGroup)
* either "Tuesday" or "Thursday".
* @return {@link DayOfWeek} instance
*/
- protected DayOfWeek dayOfWeek(String prefix) {
+ protected DayOfWeek dayOfWeek(final String prefix) {
return dayOfWeekParser.getEnumFor(prefix);
}
@@ -165,11 +145,10 @@ protected DayOfWeek dayOfWeek(String prefix) {
* @param commaSeparatedList string to parse the days of week from
* @return list of instances of {@link DayOfWeek}
*/
- protected DayOfWeek[] daysOfWeek(String commaSeparatedList) {
+ protected List daysOfWeek(final String commaSeparatedList) {
return Arrays.asList(commaSeparatedList.split(","))
.stream().map(this::dayOfWeek)
- .collect(toList())
- .toArray(new DayOfWeek[0]);
+ .toList();
}
/**
@@ -180,7 +159,7 @@ protected DayOfWeek[] daysOfWeek(String commaSeparatedList) {
* for the condition
* @return condition builder
*/
- protected ConditionBuilder createConditionBuilder(Matcher matcher) {
+ protected ConditionBuilder createConditionBuilder(final Matcher matcher) {
return new ConditionBuilder()
.withDaysOfWeek(daysOfWeek(matcher.group(Patterns.PIVOT_DAYS_OF_WEEK_GROUP)));
}
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/NegatedConditionMatcher.java b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/NegatedConditionMatcher.java
index 0614999..c6c0690 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/NegatedConditionMatcher.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/NegatedConditionMatcher.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.parser.matcher;
import java.time.MonthDay;
@@ -26,12 +9,12 @@
class NegatedConditionMatcher extends HolidayMatcher {
- NegatedConditionMatcher(HolidayMatcher originalMatcher, Pattern pattern) {
+ NegatedConditionMatcher(final HolidayMatcher originalMatcher, final Pattern pattern) {
super(originalMatcher, pattern);
}
@Override
- Holiday createHoliday(Matcher matcher) {
+ Holiday createHoliday(final Matcher matcher) {
final MonthDay pivotDate = monthDay(matcher, Patterns.MONTH_GROUP_2, Patterns.DAY_GROUP_2);
return new ConditionalHoliday( //
createConditionBuilder(matcher).withPivotDate(pivotDate).negated(),
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/OrthodoxEasterBasedMatcher.java b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/OrthodoxEasterBasedMatcher.java
index ca38302..10a0389 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/OrthodoxEasterBasedMatcher.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/OrthodoxEasterBasedMatcher.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.parser.matcher;
import java.util.regex.Matcher;
@@ -34,4 +17,4 @@ Holiday createHoliday(Matcher matcher) {
matcher.group(Patterns.NAME_GROUP),
Integer.parseInt(matcher.group(Patterns.OFFSET_GROUP)));
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/Patterns.java b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/Patterns.java
index 98521bd..2fb8dfe 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/Patterns.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/parser/matcher/Patterns.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.parser.matcher;
import static org.itsallcode.holidays.calculator.logic.parser.Token.buildRegexp;
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/ConditionalHoliday.java b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/ConditionalHoliday.java
index 9b9956d..c095ed3 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/ConditionalHoliday.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/ConditionalHoliday.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.variants;
import java.time.LocalDate;
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/EasterBasedHoliday.java b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/EasterBasedHoliday.java
index 2d831cd..0ca361c 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/EasterBasedHoliday.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/EasterBasedHoliday.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.variants;
import java.time.LocalDate;
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/FixedDateHoliday.java b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/FixedDateHoliday.java
index 2a6edd3..a43750b 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/FixedDateHoliday.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/FixedDateHoliday.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.variants;
import java.time.LocalDate;
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/FloatingHoliday.java b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/FloatingHoliday.java
index 378c7b7..bea88ef 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/FloatingHoliday.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/FloatingHoliday.java
@@ -1,25 +1,6 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.variants;
-import java.time.DayOfWeek;
-import java.time.LocalDate;
-import java.time.MonthDay;
+import java.time.*;
import java.time.temporal.TemporalAdjusters;
import java.util.Objects;
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/Holiday.java b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/Holiday.java
index e326289..bfc3cd7 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/Holiday.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/Holiday.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.variants;
import java.time.LocalDate;
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/HolidayWithAlternative.java b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/HolidayWithAlternative.java
index e3e6921..e8a5c3e 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/HolidayWithAlternative.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/HolidayWithAlternative.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.variants;
import java.time.*;
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/OrthodoxEasterBasedHoliday.java b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/OrthodoxEasterBasedHoliday.java
index 6b96a15..8970671 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/OrthodoxEasterBasedHoliday.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/OrthodoxEasterBasedHoliday.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.variants;
import java.time.LocalDate;
diff --git a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/PivotDateBasedHoliday.java b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/PivotDateBasedHoliday.java
index 9cb4215..dea0789 100644
--- a/src/main/java/org/itsallcode/holidays/calculator/logic/variants/PivotDateBasedHoliday.java
+++ b/src/main/java/org/itsallcode/holidays/calculator/logic/variants/PivotDateBasedHoliday.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.variants;
import java.util.Objects;
diff --git a/src/test/java/org/itsallcode/holidays/calculator/logic/EasterTest.java b/src/test/java/org/itsallcode/holidays/calculator/logic/EasterTest.java
index 81627ec..d07e92a 100644
--- a/src/test/java/org/itsallcode/holidays/calculator/logic/EasterTest.java
+++ b/src/test/java/org/itsallcode/holidays/calculator/logic/EasterTest.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic;
import static org.assertj.core.api.Assertions.assertThat;
@@ -115,7 +98,7 @@ void testEquals() {
"2096, 2096-04-15, 2096-04-15", "2097, 2097-03-31, 2097-05-05", "2098, 2098-04-20, 2098-04-27",
"2099, 2099-04-12, 2099-04-12"
}, nullValues = "NULL")
- void easterDaters(int year, LocalDate expectedGaussEaster, LocalDate expectedOrthodoxEaster) {
+ void easterDaters(final int year, final LocalDate expectedGaussEaster, final LocalDate expectedOrthodoxEaster) {
assertThat(Easter.gauss(year)).isEqualTo(expectedGaussEaster);
assertThat(Easter.orthodox(year)).isEqualTo(expectedOrthodoxEaster);
}
diff --git a/src/test/java/org/itsallcode/holidays/calculator/logic/HolidayCalculationTest.java b/src/test/java/org/itsallcode/holidays/calculator/logic/HolidayCalculationTest.java
index 081677e..d08e899 100644
--- a/src/test/java/org/itsallcode/holidays/calculator/logic/HolidayCalculationTest.java
+++ b/src/test/java/org/itsallcode/holidays/calculator/logic/HolidayCalculationTest.java
@@ -1,42 +1,17 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import java.time.DayOfWeek;
-import java.time.LocalDate;
-import java.time.MonthDay;
-import java.time.YearMonth;
+import java.time.*;
import java.util.Arrays;
import java.util.List;
import org.itsallcode.holidays.calculator.logic.conditions.builder.ConditionBuilder;
import org.itsallcode.holidays.calculator.logic.parser.AbbreviationParser;
-import org.itsallcode.holidays.calculator.logic.variants.ConditionalHoliday;
-import org.itsallcode.holidays.calculator.logic.variants.EasterBasedHoliday;
-import org.itsallcode.holidays.calculator.logic.variants.FixedDateHoliday;
-import org.itsallcode.holidays.calculator.logic.variants.FloatingHoliday;
+import org.itsallcode.holidays.calculator.logic.variants.*;
import org.itsallcode.holidays.calculator.logic.variants.FloatingHoliday.Day;
import org.itsallcode.holidays.calculator.logic.variants.FloatingHoliday.Direction;
-import org.itsallcode.holidays.calculator.logic.variants.Holiday;
-import org.itsallcode.holidays.calculator.logic.variants.HolidayWithAlternative;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
@@ -59,18 +34,18 @@ class HolidayCalculationTest {
static final Holiday INDEPENDENCE_DAY_SUN;
private static ConditionBuilder isSunday() {
- return new ConditionBuilder().withDaysOfWeek(DayOfWeek.SUNDAY);
+ return new ConditionBuilder().withDaysOfWeek(List.of(DayOfWeek.SUNDAY));
}
static {
final ConditionBuilder dec25SatSun = new ConditionBuilder()
- .withDaysOfWeek(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY)
+ .withDaysOfWeek(List.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY))
.withPivotDate(MonthDay.of(12, 25));
final Holiday bankHolidayDec27 = new FixedDateHoliday("holiday", "Bank Holiday 1", MonthDay.of(12, 27));
BANK_HOLIDAY_DEC_27 = new ConditionalHoliday(dec25SatSun, bankHolidayDec27);
final ConditionBuilder dec26SatSun = new ConditionBuilder()
- .withDaysOfWeek(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY)
+ .withDaysOfWeek(List.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY))
.withPivotDate(MonthDay.of(12, 26));
final Holiday bankHolidayDec28 = new FixedDateHoliday("holiday", "Bank Holiday 2", MonthDay.of(12, 28));
BANK_HOLIDAY_DEC_28 = new ConditionalHoliday(dec26SatSun, bankHolidayDec28);
@@ -78,9 +53,9 @@ private static ConditionBuilder isSunday() {
final Holiday defaultKoningsdag = new FixedDateHoliday("holiday", "Koningsdag", MonthDay.of(4, 27));
KONINGSDAG = new HolidayWithAlternative(defaultKoningsdag, isSunday(), MonthDay.of(4, 26));
- final ConditionBuilder isAnyDayButSunday = new ConditionBuilder().withDaysOfWeek(
+ final ConditionBuilder isAnyDayButSunday = new ConditionBuilder().withDaysOfWeek(List.of(
DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY,
- DayOfWeek.THURSDAY, DayOfWeek.FRIDAY, DayOfWeek.SATURDAY);
+ DayOfWeek.THURSDAY, DayOfWeek.FRIDAY, DayOfWeek.SATURDAY));
KONINGSDAG_WITH_NEGATED_DAYS_OF_WEEK = new HolidayWithAlternative(
defaultKoningsdag, isAnyDayButSunday.negated(), MonthDay.of(4, 26));
@@ -88,7 +63,7 @@ private static ConditionBuilder isSunday() {
BANK_HOLIDAYS_DECEMBER = new HolidaySet(Arrays.asList(BANK_HOLIDAY_DEC_27, BANK_HOLIDAY_DEC_28));
final ConditionBuilder dec25FriSat = new ConditionBuilder()
- .withDaysOfWeek(DayOfWeek.FRIDAY, DayOfWeek.SATURDAY)
+ .withDaysOfWeek(List.of(DayOfWeek.FRIDAY, DayOfWeek.SATURDAY))
.withPivotDate(MonthDay.of(12, 25));
final Holiday boxingDay = new FixedDateHoliday("holiday", "Boxing day is extra day off", MonthDay.of(12, 26));
CONDITIONAL_HOLIDAY_WITH_NEGATED_DAYS_OF_WEEK = new ConditionalHoliday(dec25FriSat.negated(),
@@ -110,10 +85,10 @@ void toStringTest() {
.hasToString("FixedDateHoliday(birthday My Birthday: JUL 31)");
assertThat(new FloatingHoliday(
"holiday", "1. Advent", 4, DayOfWeek.SUNDAY, Direction.BEFORE, MonthDay.of(12, 24)))
- .hasToString("FloatingHoliday(holiday 1. Advent: 4th Sunday before DEC 24)");
+ .hasToString("FloatingHoliday(holiday 1. Advent: 4th Sunday before DEC 24)");
assertThat(new FloatingHoliday(
"holiday", "Father's Day", 3, DayOfWeek.SUNDAY, Direction.AFTER, MonthDay.of(6, 1)))
- .hasToString("FloatingHoliday(holiday Father's Day: 3rd Sunday after JUN 1)");
+ .hasToString("FloatingHoliday(holiday Father's Day: 3rd Sunday after JUN 1)");
assertThat(new EasterBasedHoliday("holiday", "Good Friday", -2))
.hasToString("EasterBasedHoliday(holiday Good Friday: 2 days before Easter)");
assertThat(new EasterBasedHoliday("holiday", "Easter Monday", +1))
@@ -161,7 +136,7 @@ void invalidDate() {
"2016, 1, -",
"2017, -, -",
})
- void conditionalHoliday(int year, String holiday1, String holiday2) {
+ void conditionalHoliday(final int year, final String holiday1, final String holiday2) {
final YearMonth yearMonth = YearMonth.of(year, 12);
List instances = BANK_HOLIDAYS_DECEMBER.instances(yearMonth.atDay(27));
@@ -203,7 +178,7 @@ void alternativeDateHoliday() {
"2016, Y",
"2017, Y",
})
- void negatedDaysOfWeekHolidays(int year, String holiday) {
+ void negatedDaysOfWeekHolidays(final int year, final String holiday) {
final YearMonth yearMonth = YearMonth.of(year, 12);
final List instances = NEGATED_DAYS_OF_WEEK_HOLIDAYS.instances(yearMonth.atDay(26));
@@ -222,8 +197,9 @@ void negatedDaysOfWeekHolidays(int year, String holiday) {
"1, MON, before, 2021, 05, last-day, 2021-05-31",
"6, MON, before, 2021, 05, last-day, 2021-04-26"
})
- void floatingHoliday(int offset, String dayOfWeek, String direction, int year, int month, String dayString,
- LocalDate expected) {
+ void floatingHoliday(final int offset, final String dayOfWeek, final String direction, final int year,
+ final int month, final String dayString,
+ final LocalDate expected) {
final String name = String.format("%d %s %s %s-%02d-%s",
offset, dayOfWeek, direction, year, month, dayString);
@@ -260,7 +236,7 @@ void floatingHolidayWithNegativeOffset() {
"2015, 19", "2016, 24", "2017, 23", "2018, 22", "2019, 21",
"2020, 19", "2021, 25"
})
- void midsommarAfton_floatingHolidayWithOffsetInDays(int year, int day) {
+ void midsommarAfton_floatingHolidayWithOffsetInDays(final int year, final int day) {
assertThat(MIDSOMMARAFTON.of(year)).isEqualTo(LocalDate.of(year, 6, day));
}
}
diff --git a/src/test/java/org/itsallcode/holidays/calculator/logic/HolidayParserTest.java b/src/test/java/org/itsallcode/holidays/calculator/logic/HolidayParserTest.java
index 549beb3..192d5a8 100644
--- a/src/test/java/org/itsallcode/holidays/calculator/logic/HolidayParserTest.java
+++ b/src/test/java/org/itsallcode/holidays/calculator/logic/HolidayParserTest.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic;
import static org.assertj.core.api.Assertions.assertThat;
@@ -27,13 +10,9 @@
import org.itsallcode.holidays.calculator.logic.parser.AbbreviationParser.AmbigueAbbreviationException;
import org.itsallcode.holidays.calculator.logic.parser.AbbreviationParser.InvalidAbbreviationException;
import org.itsallcode.holidays.calculator.logic.parser.HolidayParser;
-import org.itsallcode.holidays.calculator.logic.variants.EasterBasedHoliday;
-import org.itsallcode.holidays.calculator.logic.variants.FixedDateHoliday;
-import org.itsallcode.holidays.calculator.logic.variants.FloatingHoliday;
+import org.itsallcode.holidays.calculator.logic.variants.*;
import org.itsallcode.holidays.calculator.logic.variants.FloatingHoliday.Day;
import org.itsallcode.holidays.calculator.logic.variants.FloatingHoliday.Direction;
-import org.itsallcode.holidays.calculator.logic.variants.Holiday;
-import org.itsallcode.holidays.calculator.logic.variants.OrthodoxEasterBasedHoliday;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -221,14 +200,14 @@ void orthodoxEaster() {
void conditionalHoliday() {
assertThat(holidayParser.parse(
"holiday if DEC 25 is Sat,Sun then fixed DEC 27 Bank Holiday 1"))
- .isEqualTo(HolidayCalculationTest.BANK_HOLIDAY_DEC_27);
+ .isEqualTo(HolidayCalculationTest.BANK_HOLIDAY_DEC_27);
}
@Test
void conditionalHolidayWithNegatedDaysOfWeek() {
assertThat(holidayParser.parse(
"holiday if DEC 25 is not Fri,Sat then fixed DEC 26 Boxing day is extra day off"))
- .isEqualTo(HolidayCalculationTest.CONDITIONAL_HOLIDAY_WITH_NEGATED_DAYS_OF_WEEK);
+ .isEqualTo(HolidayCalculationTest.CONDITIONAL_HOLIDAY_WITH_NEGATED_DAYS_OF_WEEK);
}
@Test
diff --git a/src/test/java/org/itsallcode/holidays/calculator/logic/HolidaySetTest.java b/src/test/java/org/itsallcode/holidays/calculator/logic/HolidaySetTest.java
index fca96c7..19fb641 100644
--- a/src/test/java/org/itsallcode/holidays/calculator/logic/HolidaySetTest.java
+++ b/src/test/java/org/itsallcode/holidays/calculator/logic/HolidaySetTest.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/src/test/java/org/itsallcode/holidays/calculator/logic/conditions/ConditionTest.java b/src/test/java/org/itsallcode/holidays/calculator/logic/conditions/ConditionTest.java
index 93e5051..9e919d0 100644
--- a/src/test/java/org/itsallcode/holidays/calculator/logic/conditions/ConditionTest.java
+++ b/src/test/java/org/itsallcode/holidays/calculator/logic/conditions/ConditionTest.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.conditions;
import java.util.List;
diff --git a/src/test/java/org/itsallcode/holidays/calculator/logic/variants/HolidayTest.java b/src/test/java/org/itsallcode/holidays/calculator/logic/variants/HolidayTest.java
index cf3af74..5c842e0 100644
--- a/src/test/java/org/itsallcode/holidays/calculator/logic/variants/HolidayTest.java
+++ b/src/test/java/org/itsallcode/holidays/calculator/logic/variants/HolidayTest.java
@@ -1,20 +1,3 @@
-/**
- * holiday-calculator
- * Copyright (C) 2022 itsallcode
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
package org.itsallcode.holidays.calculator.logic.variants;
import java.util.List;