Skip to content

Commit

Permalink
Spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
chipkent committed Jan 10, 2024
1 parent 18ed1fd commit 847acd6
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private YearData getYearData(final int year) {

// region Getters

//TODO: should there be a string equivalent?
// TODO: should there be a string equivalent?
/**
* Returns the first valid date for the business calendar.
*
Expand All @@ -175,7 +175,7 @@ public LocalDate firstValidDate() {
return firstValidDate;
}

//TODO: should there be a string equivalent?
// TODO: should there be a string equivalent?
/**
* Returns the last valid date for the business calendar.
*
Expand Down Expand Up @@ -1222,8 +1222,9 @@ public String[] businessDates(final String start, final String end, final boolea
return null;
}

final LocalDate[] dates = businessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive,
endInclusive);
final LocalDate[] dates =
businessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive,
endInclusive);
return dates == null ? null : Arrays.stream(dates).map(DateTimeUtils::formatDate).toArray(String[]::new);
}

Expand Down Expand Up @@ -1366,8 +1367,9 @@ public String[] nonBusinessDates(final String start, final String end, final boo
return null;
}

final LocalDate[] dates = nonBusinessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive,
endInclusive);
final LocalDate[] dates =
nonBusinessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive,
endInclusive);
return dates == null ? null : Arrays.stream(dates).map(DateTimeUtils::formatDate).toArray(String[]::new);
}

Expand Down Expand Up @@ -2097,7 +2099,7 @@ public ZonedDateTime minusNonBusinessDays(final ZonedDateTime time, final int da
return plusNonBusinessDays(time, -days);
}

//TODO: should there be a string equivalent?
// TODO: should there be a string equivalent?
/**
* Adds a specified number of business days to the current date. Adding negative days is equivalent to subtracting
* days.
Expand All @@ -2115,7 +2117,7 @@ public LocalDate futureBusinessDate(final int days) {
return plusBusinessDays(calendarDate(), days);
}

//TODO: should there be a string equivalent?
// TODO: should there be a string equivalent?
/**
* Subtracts a specified number of business days from the current date. Subtracting negative days is equivalent to
* adding days.
Expand All @@ -2133,7 +2135,7 @@ public LocalDate pastBusinessDate(final int days) {
return minusBusinessDays(calendarDate(), days);
}

//TODO: should there be a string equivalent?
// TODO: should there be a string equivalent?
/**
* Adds a specified number of non-business days to the current date. Adding negative days is equivalent to
* subtracting days.
Expand All @@ -2151,7 +2153,7 @@ public LocalDate futureNonBusinessDate(final int days) {
return this.plusNonBusinessDays(calendarDate(), days);
}

//TODO: should there be a string equivalent?
// TODO: should there be a string equivalent?
/**
* Subtracts a specified number of non-business days to the current date. Subtracting negative days is equivalent to
* adding days.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public String toString() {

// region Now

//TODO: should there be a string equivalent?
// TODO: should there be a string equivalent?
/**
* The current date for the calendar.
*
Expand Down Expand Up @@ -119,7 +119,7 @@ public DayOfWeek dayOfWeek(final LocalDate date) {
return DateTimeUtils.dayOfWeek(date);
}

//TODO: should this return a String?
// TODO: should this return a String?
/**
* The current day of the week for the calendar.
*
Expand Down Expand Up @@ -397,7 +397,7 @@ public ZonedDateTime minusDays(final ZonedDateTime time, final int days) {
return plusDays(time, -days);
}

//TODO: should there be a string equivalent?
// TODO: should there be a string equivalent?
/**
* Adds a specified number of days to the current date. Adding negative days is equivalent to subtracting days.
*
Expand All @@ -409,7 +409,7 @@ public LocalDate futureDate(final int days) {
return plusDays(calendarDate(), days);
}

//TODO: should there be a string equivalent?
// TODO: should there be a string equivalent?
/**
* Subtracts a specified number of days from the current date. Subtracting negative days is equivalent to adding
* days.
Expand Down Expand Up @@ -470,8 +470,9 @@ public String[] calendarDates(final String start, final String end, final boolea
return null;
}

final LocalDate[] dates = calendarDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive,
endInclusive);
final LocalDate[] dates =
calendarDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive,
endInclusive);
return dates == null ? null : Arrays.stream(dates).map(DateTimeUtils::formatDate).toArray(String[]::new);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,14 +644,17 @@ public void testBusinessDates() {
};

assertEquals(bus, bCalendar.businessDates(start, end));
assertEquals(Arrays.stream(bus).map(DateTimeUtils::formatDate).toArray(String[]::new), bCalendar.businessDates(start.toString(), end.toString()));
assertEquals(Arrays.stream(bus).map(DateTimeUtils::formatDate).toArray(String[]::new),
bCalendar.businessDates(start.toString(), end.toString()));
assertEquals(bus,
bCalendar.businessDates(start.atTime(1, 24).atZone(timeZone), end.atTime(1, 24).atZone(timeZone)));
assertEquals(bus, bCalendar.businessDates(start.atTime(1, 24).atZone(timeZone).toInstant(),
end.atTime(1, 24).atZone(timeZone).toInstant()));

assertEquals(Arrays.copyOfRange(bus, 0, bus.length - 1), bCalendar.businessDates(start, end, true, false));
assertEquals(Arrays.stream(Arrays.copyOfRange(bus, 0, bus.length - 1)).map(DateTimeUtils::formatDate).toArray(String[]::new),
assertEquals(
Arrays.stream(Arrays.copyOfRange(bus, 0, bus.length - 1)).map(DateTimeUtils::formatDate)
.toArray(String[]::new),
bCalendar.businessDates(start.toString(), end.toString(), true, false));
assertEquals(Arrays.copyOfRange(bus, 0, bus.length - 1), bCalendar
.businessDates(start.atTime(1, 24).atZone(timeZone), end.atTime(1, 24).atZone(timeZone), true, false));
Expand All @@ -660,7 +663,9 @@ public void testBusinessDates() {
end.atTime(1, 24).atZone(timeZone).toInstant(), true, false));

assertEquals(Arrays.copyOfRange(bus, 1, bus.length), bCalendar.businessDates(start, end, false, true));
assertEquals(Arrays.stream(Arrays.copyOfRange(bus, 1, bus.length)).map(DateTimeUtils::formatDate).toArray(String[]::new),
assertEquals(
Arrays.stream(Arrays.copyOfRange(bus, 1, bus.length)).map(DateTimeUtils::formatDate)
.toArray(String[]::new),
bCalendar.businessDates(start.toString(), end.toString(), false, true));
assertEquals(Arrays.copyOfRange(bus, 1, bus.length), bCalendar
.businessDates(start.atTime(1, 24).atZone(timeZone), end.atTime(1, 24).atZone(timeZone), false, true));
Expand All @@ -669,7 +674,9 @@ public void testBusinessDates() {
end.atTime(1, 24).atZone(timeZone).toInstant(), false, true));

assertEquals(Arrays.copyOfRange(bus, 1, bus.length - 1), bCalendar.businessDates(start, end, false, false));
assertEquals(Arrays.stream(Arrays.copyOfRange(bus, 1, bus.length - 1)).map(DateTimeUtils::formatDate).toArray(String[]::new),
assertEquals(
Arrays.stream(Arrays.copyOfRange(bus, 1, bus.length - 1)).map(DateTimeUtils::formatDate)
.toArray(String[]::new),
bCalendar.businessDates(start.toString(), end.toString(), false, false));
assertEquals(Arrays.copyOfRange(bus, 1, bus.length - 1), bCalendar
.businessDates(start.atTime(1, 24).atZone(timeZone), end.atTime(1, 24).atZone(timeZone), false, false));
Expand Down Expand Up @@ -779,15 +786,18 @@ public void testNonBusinessDates() {
// };

assertEquals(nonBus, bCalendar.nonBusinessDates(start, end));
assertEquals(Arrays.stream(nonBus).map(DateTimeUtils::formatDate).toArray(String[]::new), bCalendar.nonBusinessDates(start.toString(), end.toString()));
assertEquals(Arrays.stream(nonBus).map(DateTimeUtils::formatDate).toArray(String[]::new),
bCalendar.nonBusinessDates(start.toString(), end.toString()));
assertEquals(nonBus,
bCalendar.nonBusinessDates(start.atTime(1, 24).atZone(timeZone), end.atTime(1, 24).atZone(timeZone)));
assertEquals(nonBus, bCalendar.nonBusinessDates(start.atTime(1, 24).atZone(timeZone).toInstant(),
end.atTime(1, 24).atZone(timeZone).toInstant()));

assertEquals(Arrays.copyOfRange(nonBus, 0, nonBus.length - 1),
bCalendar.nonBusinessDates(nonBus[0], nonBus[nonBus.length - 1], true, false));
assertEquals(Arrays.stream(Arrays.copyOfRange(nonBus, 0, nonBus.length - 1)).map(DateTimeUtils::formatDate).toArray(String[]::new),
assertEquals(
Arrays.stream(Arrays.copyOfRange(nonBus, 0, nonBus.length - 1)).map(DateTimeUtils::formatDate)
.toArray(String[]::new),
bCalendar.nonBusinessDates(nonBus[0].toString(), nonBus[nonBus.length - 1].toString(), true, false));
assertEquals(Arrays.copyOfRange(nonBus, 0, nonBus.length - 1),
bCalendar.nonBusinessDates(nonBus[0].atTime(1, 24).atZone(timeZone),
Expand All @@ -798,7 +808,9 @@ public void testNonBusinessDates() {

assertEquals(Arrays.copyOfRange(nonBus, 1, nonBus.length),
bCalendar.nonBusinessDates(nonBus[0], nonBus[nonBus.length - 1], false, true));
assertEquals(Arrays.stream(Arrays.copyOfRange(nonBus, 1, nonBus.length)).map(DateTimeUtils::formatDate).toArray(String[]::new),
assertEquals(
Arrays.stream(Arrays.copyOfRange(nonBus, 1, nonBus.length)).map(DateTimeUtils::formatDate)
.toArray(String[]::new),
bCalendar.nonBusinessDates(nonBus[0].toString(), nonBus[nonBus.length - 1].toString(), false, true));
assertEquals(Arrays.copyOfRange(nonBus, 1, nonBus.length),
bCalendar.nonBusinessDates(nonBus[0].atTime(1, 24).atZone(timeZone),
Expand All @@ -809,7 +821,9 @@ public void testNonBusinessDates() {

assertEquals(Arrays.copyOfRange(nonBus, 1, nonBus.length - 1),
bCalendar.nonBusinessDates(nonBus[0], nonBus[nonBus.length - 1], false, false));
assertEquals(Arrays.stream(Arrays.copyOfRange(nonBus, 1, nonBus.length - 1)).map(DateTimeUtils::formatDate).toArray(String[]::new),
assertEquals(
Arrays.stream(Arrays.copyOfRange(nonBus, 1, nonBus.length - 1)).map(DateTimeUtils::formatDate)
.toArray(String[]::new),
bCalendar.nonBusinessDates(nonBus[0].toString(), nonBus[nonBus.length - 1].toString(), false, false));
assertEquals(Arrays.copyOfRange(nonBus, 1, nonBus.length - 1),
bCalendar.nonBusinessDates(nonBus[0].atTime(1, 24).atZone(timeZone),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ public void testCalendarDates() {
final LocalDate end = LocalDate.of(2023, 2, 5);

assertEquals(new LocalDate[] {start, middle, end}, calendar.calendarDates(start, end));
assertEquals(new String[] {start.toString(), middle.toString(), end.toString()}, calendar.calendarDates(start.toString(), end.toString()));
assertEquals(new String[] {start.toString(), middle.toString(), end.toString()},
calendar.calendarDates(start.toString(), end.toString()));
assertEquals(new LocalDate[] {start, middle, end},
calendar.calendarDates(start.atTime(1, 24).atZone(timeZone), end.atTime(1, 24).atZone(timeZone)));
assertEquals(new LocalDate[] {start, middle, end}, calendar.calendarDates(
Expand All @@ -205,7 +206,8 @@ public void testCalendarDates() {
end.atTime(1, 24).atZone(timeZone).toInstant(), false, true));

assertEquals(new LocalDate[] {middle}, calendar.calendarDates(start, end, false, false));
assertEquals(new String[] {middle.toString()}, calendar.calendarDates(start.toString(), end.toString(), false, false));
assertEquals(new String[] {middle.toString()},
calendar.calendarDates(start.toString(), end.toString(), false, false));
assertEquals(new LocalDate[] {middle}, calendar.calendarDates(start.atTime(1, 24).atZone(timeZone),
end.atTime(1, 24).atZone(timeZone), false, false));
assertEquals(new LocalDate[] {middle}, calendar.calendarDates(start.atTime(1, 24).atZone(timeZone).toInstant(),
Expand Down

0 comments on commit 847acd6

Please sign in to comment.