From ec5f461551b6597c2709199ccb1e4db860e7fd14 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 27 Jun 2023 10:29:00 -0600 Subject: [PATCH 001/150] First refactoring. --- .../calendar/AbstractBusinessCalendar.java | 596 ------------------ .../time/calendar/AbstractCalendar.java | 181 ------ .../time/calendar/BusinessSchedule.java | 21 + .../io/deephaven/time/calendar/Calendar.java | 528 +++++++++++++--- .../calendar/DefaultBusinessCalendar.java | 152 +---- .../DefaultNoHolidayBusinessCalendar.java | 18 - 6 files changed, 450 insertions(+), 1046 deletions(-) delete mode 100644 engine/time/src/main/java/io/deephaven/time/calendar/AbstractBusinessCalendar.java delete mode 100644 engine/time/src/main/java/io/deephaven/time/calendar/AbstractCalendar.java diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/AbstractBusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/AbstractBusinessCalendar.java deleted file mode 100644 index 0c4b14d9281..00000000000 --- a/engine/time/src/main/java/io/deephaven/time/calendar/AbstractBusinessCalendar.java +++ /dev/null @@ -1,596 +0,0 @@ -/** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending - */ -package io.deephaven.time.calendar; - -import io.deephaven.time.DateTimeUtils; -import io.deephaven.util.QueryConstants; - -import java.time.Instant; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.List; - -public abstract class AbstractBusinessCalendar extends AbstractCalendar implements BusinessCalendar { - - public boolean isBusinessDay(final Instant time) { - return fractionOfStandardBusinessDay(time) > 0.0; - } - - public boolean isBusinessDay(final String date) { - return date != null && getBusinessSchedule(date).isBusinessDay(); - } - - public boolean isBusinessDay(final LocalDate date) { - return date != null && getBusinessSchedule(date).isBusinessDay(); - } - - public boolean isBusinessTime(final Instant time) { - return time != null && getBusinessSchedule(time).isBusinessTime(time); - } - - public String previousBusinessDay(final Instant time) { - if (time == null) { - return null; - } - - LocalDate t = DateTimeUtils.toZonedDateTime(time, timeZone()).toLocalDate().minusDays(1); - while (!isBusinessDay(t)) { - t = t.minusDays(1); - } - - return DateStringUtils.format(t); - } - - public String previousBusinessDay(final Instant time, int days) { - if (time == null) { - return null; - } - - if (days < 0) { - return nextBusinessDay(time, -days); - } else if (days == 0 && !isBusinessDay(time)) { - return null; - } else if (days == 0) { - return DateTimeUtils.formatDate(time, timeZone()); - } - - String date = null; - while (days > 0) { - if (date == null) { - date = previousBusinessDay(time); - } else { - date = previousBusinessDay(date); - } - days--; - } - - return date; - } - - public String previousBusinessDay(String date) { - if (date == null) { - return null; - } - - date = DateStringUtils.minusDays(date, 1); - while (!isBusinessDay(date)) { - // first minusDays ensures the date strings will be of the correct format - date = DateStringUtils.minusDaysQuiet(date, 1); - } - - return date; - } - - public String previousBusinessDay(String date, int days) { - if (date == null) { - return null; - } - - if (days < 0) { - return nextBusinessDay(date, -days); - } else if (days == 0 && !isBusinessDay(date)) { - return null; - } else if (days == 0) { - return date; - } - - while (days > 0) { - date = previousBusinessDay(date); - days--; - } - - return date; - } - - public BusinessSchedule previousBusinessSchedule(final Instant time) { - return getBusinessSchedule(previousDay(time)); - } - - public BusinessSchedule previousBusinessSchedule(final Instant time, int days) { - return getBusinessSchedule(previousDay(time, days)); - } - - public BusinessSchedule previousBusinessSchedule(String date) { - return getBusinessSchedule(previousDay(date)); - } - - public BusinessSchedule previousBusinessSchedule(String date, int days) { - return getBusinessSchedule(previousDay(date, days)); - } - - public String previousNonBusinessDay(final Instant time) { - if (time == null) { - return null; - } - - LocalDate t = DateTimeUtils.toZonedDateTime(time, timeZone()).toLocalDate().minusDays(1); - while (isBusinessDay(t)) { - t = t.minusDays(1); - } - - return DateStringUtils.format(t); - } - - public String previousNonBusinessDay(final Instant time, int days) { - if (time == null) { - return null; - } - - if (days < 0) { - return nextNonBusinessDay(time, -days); - } else if (days == 0 && isBusinessDay(time)) { - return null; - } else if (days == 0) { - return DateTimeUtils.formatDate(time, timeZone()); - } - - String date = null; - while (days > 0) { - if (date == null) { - date = previousNonBusinessDay(time); - } else { - date = previousNonBusinessDay(date); - } - days--; - } - - return date; - } - - public String previousNonBusinessDay(String date) { - if (date == null) { - return null; - } - - date = DateStringUtils.minusDays(date, 1); - while (isBusinessDay(date)) { - // first minusDays ensures the date strings will be of the correct format - date = DateStringUtils.minusDaysQuiet(date, 1); - } - - return date; - } - - public String previousNonBusinessDay(String date, int days) { - if (date == null) { - return null; - } - - if (days < 0) { - return nextNonBusinessDay(date, -days); - } else if (days == 0 && isBusinessDay(date)) { - return null; - } else if (days == 0) { - return date; - } - - while (days > 0) { - date = previousNonBusinessDay(date); - days--; - } - - return date; - } - - public String nextBusinessDay(final Instant time) { - if (time == null) { - return null; - } - - LocalDate t = DateTimeUtils.toZonedDateTime(time, timeZone()).toLocalDate().plusDays(1); - while (!isBusinessDay(t)) { - t = t.plusDays(1); - } - - return DateStringUtils.format(t); - } - - public String nextBusinessDay(final Instant time, int days) { - if (time == null) { - return null; - } - - if (days < 0) { - return previousBusinessDay(time, -days); - } else if (days == 0 && !isBusinessDay(time)) { - return null; - } else if (days == 0) { - return DateTimeUtils.formatDate(time, timeZone()); - } - - String date = null; - while (days > 0) { - if (date == null) { - date = nextBusinessDay(time); - } else { - date = nextBusinessDay(date); - } - days--; - } - - return date; - } - - public String nextBusinessDay(String date) { - if (date == null) { - return null; - } - - date = DateStringUtils.plusDays(date, 1); - while (!isBusinessDay(date)) { - // first plusDays ensures the date strings will be of the correct format - date = DateStringUtils.plusDaysQuiet(date, 1); - } - - return date; - } - - public String nextBusinessDay(String date, int days) { - if (date == null) { - return null; - } - - if (days < 0) { - return previousBusinessDay(date, -days); - } else if (days == 0 && !isBusinessDay(date)) { - return null; - } else if (days == 0) { - return date; - } - - while (days > 0) { - date = nextBusinessDay(date); - days--; - } - - return date; - } - - - public BusinessSchedule nextBusinessSchedule(final Instant time) { - return getBusinessSchedule(nextDay(time)); - } - - public BusinessSchedule nextBusinessSchedule(final Instant time, int days) { - return getBusinessSchedule(nextDay(time, days)); - } - - public BusinessSchedule nextBusinessSchedule(String date) { - return getBusinessSchedule(nextDay(date)); - } - - public BusinessSchedule nextBusinessSchedule(String date, int days) { - return getBusinessSchedule(nextDay(date, days)); - } - - public String nextNonBusinessDay(final Instant time) { - if (time == null) { - return null; - } - - LocalDate t = DateTimeUtils.toZonedDateTime(time, timeZone()).toLocalDate().plusDays(1); - while (isBusinessDay(t)) { - t = t.plusDays(1); - } - - return DateStringUtils.format(t); - } - - public String nextNonBusinessDay(final Instant time, int days) { - if (time == null) { - return null; - } - - if (days < 0) { - return previousNonBusinessDay(time, -days); - } else if (days == 0 && isBusinessDay(time)) { - return null; - } else if (days == 0) { - return DateTimeUtils.formatDate(time, timeZone()); - } - - String date = null; - while (days > 0) { - if (date == null) { - date = nextNonBusinessDay(time); - } else { - date = nextNonBusinessDay(date); - } - days--; - } - - return date; - } - - public String nextNonBusinessDay(String date) { - if (date == null) { - return null; - } - - date = DateStringUtils.plusDays(date, 1); - while (isBusinessDay(date)) { - // first plusDays ensures the date strings will be of the correct format - date = DateStringUtils.plusDaysQuiet(date, 1); - } - - return date; - } - - public String nextNonBusinessDay(String date, int days) { - if (date == null) { - return null; - } - - if (days < 0) { - return previousNonBusinessDay(date, -days); - } else if (days == 0 && isBusinessDay(date)) { - return null; - } else if (days == 0) { - return date; - } - - while (days > 0) { - date = nextNonBusinessDay(date); - days--; - } - - return date; - } - - public String[] businessDaysInRange(final Instant start, final Instant end) { - if (start == null || end == null) { - return new String[0]; - } - LocalDate day = DateTimeUtils.toZonedDateTime(start, timeZone()).toLocalDate(); - LocalDate day2 = DateTimeUtils.toZonedDateTime(end, timeZone()).toLocalDate(); - - List dateList = new ArrayList<>(); - while (!day.isAfter(day2)) { - if (isBusinessDay(day)) { - dateList.add(DateStringUtils.format(day)); - } - day = day.plusDays(1); - } - - return dateList.toArray(new String[dateList.size()]); - } - - public String[] businessDaysInRange(String start, String end) { - if (start == null || end == null) { - return new String[0]; - } - - List dateList = new ArrayList<>(); - if (!DateStringUtils.isAfter(start, end)) { - if (isBusinessDay(start)) { - dateList.add(start); - } - start = nextBusinessDay(start); - } else { - return new String[0]; - } - - // first isAfter ensures the date strings will be of the correct format - while (!DateStringUtils.isAfterQuiet(start, end)) { - if (isBusinessDay(start)) { - dateList.add(start); - } - start = DateStringUtils.plusDaysQuiet(start, 1); - } - - return dateList.toArray(new String[dateList.size()]); - } - - public String[] nonBusinessDaysInRange(final Instant start, final Instant end) { - if (start == null || end == null) { - return new String[0]; - } - LocalDate day = DateTimeUtils.toZonedDateTime(start, timeZone()).toLocalDate(); - LocalDate day2 = DateTimeUtils.toZonedDateTime(end, timeZone()).toLocalDate(); - - List dateList = new ArrayList<>(); - while (!day.isAfter(day2)) { - if (!isBusinessDay(day)) { - dateList.add(DateStringUtils.format(day)); - } - day = day.plusDays(1); - } - - return dateList.toArray(new String[dateList.size()]); - } - - public String[] nonBusinessDaysInRange(String start, String end) { - if (start == null || end == null) { - return new String[0]; - } - - List dateList = new ArrayList<>(); - if (!DateStringUtils.isAfter(start, end)) { - if (!isBusinessDay(start)) { - dateList.add(start); - } - start = nextNonBusinessDay(start); - } else { - return new String[0]; - } - - // first isAfter ensures the date strings will be of the correct format - while (!DateStringUtils.isAfterQuiet(start, end)) { - dateList.add(start); - start = nextNonBusinessDay(start); - } - - return dateList.toArray(new String[dateList.size()]); - } - - public long diffNonBusinessNanos(final Instant start, final Instant end) { - if (start == null || end == null) { - return QueryConstants.NULL_LONG; - } - - if (DateTimeUtils.isAfter(start, end)) { - return -diffNonBusinessNanos(end, start); - } - - return DateTimeUtils.minus(end, start) - diffBusinessNanos(start, end); - } - - public double diffBusinessDay(final Instant start, final Instant end) { - if (start == null || end == null) { - return QueryConstants.NULL_DOUBLE; - } - - return (double) diffBusinessNanos(start, end) / (double) standardBusinessDayLengthNanos(); - } - - public double diffNonBusinessDay(final Instant start, final Instant end) { - if (start == null || end == null) { - return QueryConstants.NULL_DOUBLE; - } - - return (double) diffNonBusinessNanos(start, end) / (double) standardBusinessDayLengthNanos(); - } - - public int numberOfBusinessDays(Instant start, Instant end) { - return numberOfBusinessDays(start, end, false); - } - - public int numberOfBusinessDays(Instant start, Instant end, final boolean endInclusive) { - return numberOfBusinessDays( - start == null ? null : DateTimeUtils.formatDate(start, timeZone()), - end == null ? null : DateTimeUtils.formatDate(end, timeZone()), - endInclusive); - } - - public int numberOfBusinessDays(String start, String end) { - return numberOfBusinessDays(start, end, false); - } - - public int numberOfBusinessDays(String start, String end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } - - int days = 0; - if (DateStringUtils.isBefore(start, end)) { - if (isBusinessDay(start)) { - days++; - } - start = nextBusinessDay(start); - } else if (DateStringUtils.isAfter(start, end)) { - return -numberOfBusinessDays(end, start, endInclusive); - } - - while (DateStringUtils.isBeforeQuiet(start, end)) { - days++; - start = nextBusinessDay(start); - } - - return days + (endInclusive && isBusinessDay(end) ? 1 : 0); - } - - public int numberOfNonBusinessDays(Instant start, Instant end) { - return numberOfNonBusinessDays(start, end, false); - } - - public int numberOfNonBusinessDays(Instant start, Instant end, final boolean endInclusive) { - return numberOfNonBusinessDays( - start == null ? null : DateTimeUtils.formatDate(start, timeZone()), - end == null ? null : DateTimeUtils.formatDate(end, timeZone()), - endInclusive); - } - - public int numberOfNonBusinessDays(final String start, final String end) { - return numberOfNonBusinessDays(start, end, false); - } - - public int numberOfNonBusinessDays(final String start, final String end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } - - return numberOfDays(start, end, endInclusive) - numberOfBusinessDays(start, end, endInclusive); - } - - public double fractionOfStandardBusinessDay(final Instant time) { - final BusinessSchedule businessDate = getBusinessSchedule(time); - return businessDate == null ? 0.0 : (double) businessDate.getLOBD() / (double) standardBusinessDayLengthNanos(); - } - - public double fractionOfStandardBusinessDay(final String date) { - final BusinessSchedule businessDate = getBusinessSchedule(date); - return businessDate == null ? 0.0 : (double) businessDate.getLOBD() / (double) standardBusinessDayLengthNanos(); - } - - public double fractionOfBusinessDayRemaining(final Instant time) { - final BusinessSchedule businessDate = getBusinessSchedule(time); - if (businessDate == null) { - return QueryConstants.NULL_DOUBLE; - } - - if (businessDate.getLOBD() == 0) { - return 0; - } - - long businessDaySoFar = businessDate.businessTimeElapsed(time); - return (double) (businessDate.getLOBD() - businessDaySoFar) / (double) businessDate.getLOBD(); - } - - public double fractionOfBusinessDayComplete(final Instant time) { - if (time == null) { - return QueryConstants.NULL_DOUBLE; - } - - return 1.0 - fractionOfBusinessDayRemaining(time); - } - - public boolean isLastBusinessDayOfMonth(final Instant time) { - return isBusinessDay(time) && isLastBusinessDayOfMonth(DateTimeUtils.formatDate(time, timeZone())); - } - - public boolean isLastBusinessDayOfMonth(final String date) { - if (!isBusinessDay(date)) { - return false; - } - - String nextBusAfterDate = nextBusinessDay(date); - - // covers case December to January - return (DateStringUtils.monthOfYear(date) - DateStringUtils.monthOfYear(nextBusAfterDate)) != 0; - } - - public boolean isLastBusinessDayOfWeek(final Instant time) { - return isBusinessDay(time) && isLastBusinessDayOfWeek(DateTimeUtils.formatDate(time, timeZone())); - } - - public boolean isLastBusinessDayOfWeek(final String date) { - if (!isBusinessDay(date)) { - return false; - } - - String nextBusinessDay = nextBusinessDay(date); - return dayOfWeek(date).compareTo(dayOfWeek(nextBusinessDay)) > 0 || numberOfDays(date, nextBusinessDay) > 6; - } - -} diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/AbstractCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/AbstractCalendar.java deleted file mode 100644 index 47ff7915cdc..00000000000 --- a/engine/time/src/main/java/io/deephaven/time/calendar/AbstractCalendar.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending - */ -package io.deephaven.time.calendar; - -import io.deephaven.time.DateTimeUtils; -import io.deephaven.util.QueryConstants; - -import java.time.DayOfWeek; -import java.time.Instant; -import java.time.LocalDate; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList; -import java.util.List; - -public abstract class AbstractCalendar implements Calendar { - - public String previousDay(final Instant time) { - return previousDay(time, 1); - } - - public String previousDay(final Instant time, final int days) { - if (time == null) { - return null; - } - - final LocalDate t = DateTimeUtils.toZonedDateTime(time, timeZone()).toLocalDate().minusDays(days); - - return DateStringUtils.format(t); - } - - public String previousDay(final String date) { - return previousDay(date, 1); - } - - public String previousDay(final String date, final int days) { - if (date == null) { - return null; - } - - final LocalDate t = DateStringUtils.parseLocalDate(date).minusDays(days); - return DateStringUtils.format(t); - } - - public String nextDay(final Instant time) { - return nextDay(time, 1); - } - - public String nextDay(final Instant time, final int days) { - if (time == null) { - return null; - } - - final LocalDate t = DateTimeUtils.toZonedDateTime(time, timeZone()).toLocalDate().plusDays(days); - - return DateStringUtils.format(t); - } - - public String nextDay(final String date) { - return nextDay(date, 1); - } - - public String nextDay(final String date, final int days) { - if (date == null) { - return null; - } - - final LocalDate t = DateStringUtils.parseLocalDate(date).plusDays(days); - return DateStringUtils.format(t); - } - - public String[] daysInRange(Instant start, Instant end) { - if (start == null || end == null) { - return new String[0]; - } - LocalDate day = DateTimeUtils.toZonedDateTime(start, timeZone()).toLocalDate(); - final LocalDate day2 = DateTimeUtils.toZonedDateTime(end, timeZone()).toLocalDate(); - - List dateList = new ArrayList<>(); - while (!day.isAfter(day2)) { - dateList.add(DateStringUtils.format(day)); - day = day.plusDays(1); - } - - return dateList.toArray(new String[dateList.size()]); - } - - public String[] daysInRange(final String start, final String end) { - try { - DateStringUtils.parseLocalDate(start); - DateStringUtils.parseLocalDate(end); - } catch (IllegalArgumentException e) { - return new String[0]; - } - - List dateList = new ArrayList<>(); - String date = start; - while (!DateStringUtils.isAfterQuiet(date, end)) { - dateList.add(date); - date = DateStringUtils.plusDaysQuiet(date, 1); - } - - return dateList.toArray(new String[dateList.size()]); - } - - public int numberOfDays(final Instant start, final Instant end) { - return numberOfDays(start, end, false); - } - - public int numberOfDays(final Instant start, final Instant end, final boolean endInclusive) { - return numberOfDays( - start == null ? null : DateTimeUtils.formatDate(start, timeZone()), - end == null ? null : DateTimeUtils.formatDate(end, timeZone()), - endInclusive); - } - - public int numberOfDays(final String start, final String end) { - return numberOfDays(start, end, false); - } - - public int numberOfDays(final String start, final String end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } - - LocalDate startDay = DateStringUtils.parseLocalDate(start); - LocalDate endDay = DateStringUtils.parseLocalDate(end); - - int days = (int) ChronoUnit.DAYS.between(startDay, endDay); - if (days < 0) { - days = days - (endInclusive ? 1 : 0); - } else { - days = days + (endInclusive ? 1 : 0); - } - return days; - } - - public long diffNanos(final Instant start, final Instant end) { - return DateTimeUtils.minus(end, start); - } - - public double diffDay(final Instant start, final Instant end) { - if (start == null || end == null) { - return QueryConstants.NULL_DOUBLE; - } - - return (double) diffNanos(start, end) / (double) DateTimeUtils.DAY; - } - - public double diffYear365(Instant start, Instant end) { - if (start == null || end == null) { - return QueryConstants.NULL_DOUBLE; - } - - return (double) diffNanos(start, end) / (double) DateTimeUtils.YEAR_365; - } - - public double diffYearAvg(Instant start, Instant end) { - if (start == null || end == null) { - return QueryConstants.NULL_DOUBLE; - } - - return (double) diffNanos(start, end) / (double) DateTimeUtils.YEAR_AVG; - } - - public DayOfWeek dayOfWeek(final Instant time) { - if (time == null) { - return null; - } - return DayOfWeek.of(DateTimeUtils.dayOfWeek(time, timeZone())); - } - - public DayOfWeek dayOfWeek(final String date) { - if (date == null) { - return null; - } - LocalDate localDate = LocalDate.parse(date); - return localDate.getDayOfWeek(); - } - -} diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java index abe3460c598..b0aa38a8fbb 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java @@ -8,6 +8,7 @@ import java.io.Serializable; import java.time.Instant; +import java.time.ZonedDateTime; import java.util.Arrays; /** @@ -165,6 +166,16 @@ public boolean isBusinessTime(final Instant time) { return false; } + /** + * Determines if the specified time is a business time for the day. + * + * @param time time. + * @return true if the time is a business time for the day; otherwise, false. + */ + public boolean isBusinessTime(final ZonedDateTime time) { + return isBusinessTime(time.toInstant()); + } + /** * Returns the amount of business time in nanoseconds that has elapsed on the given day by the specified time. * @@ -187,4 +198,14 @@ public long businessTimeElapsed(final Instant time) { return elapsed; } + + /** + * Returns the amount of business time in nanoseconds that has elapsed on the given day by the specified time. + * + * @param time time + * @return business time in nanoseconds that has elapsed on the given day by the specified time + */ + public long businessTimeElapsed(final ZonedDateTime time) { + return businessTimeElapsed(time.toInstant()); + } } diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java index e9e3edfc0af..6fb8738c829 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java @@ -4,65 +4,121 @@ package io.deephaven.time.calendar; import io.deephaven.time.DateTimeUtils; +import io.deephaven.util.QueryConstants; -import java.time.DayOfWeek; -import java.time.Instant; -import java.time.ZoneId; +import java.time.*; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; + +//TODO: review all docs + +//TODO: future_day / past_day +//TODO: add regions /** * A calendar. * + * A calendar is associated with a specific time zone. * - * To comply with the ISO-8601 standard for Dates, Strings should be of the form "yyyy-MM-dd", - * - * - * Methods on Instant may not be precisely defined enough to return an Instant, e.g nextDay(). In these cases, the - * method will return a String as discussed above. - * - * - * To maintain consistency, each calendar has two fields: a name, and a time zone. A calendar with the same schedule but - * a different time zone is considered a different calendar. - * - * - * Frequently, the default implementation for methods on Instants is to call the corresponding method on a String with - * {@code DateTimeUtils.formatDate}. This can be slower than methods written explicitly for DateTimes. If performance is - * an issue, consider overriding these methods with other behavior. + * Date strings must be in a format that can be parsed by {@code DateTimeUtils#parseDate}. Methods that accept + * strings can be slower than methods written explicitly for {@code Instant}, {@code ZonedDateTime}, or {@code LocalDate}. */ -public interface Calendar { +public class Calendar { + + private final String name; + private final String description; + private final ZoneId timeZone; + + /** + * Creates a new calendar. + * + * @param name calendar name. + * @param description calendar description. + * @param timeZone calendar time zone. + */ + public Calendar(String name, String description, ZoneId timeZone) { + this.name = name; + this.description = description; + this.timeZone = timeZone; + } /** * Gets the name of the calendar. * * @return the name of the calendar */ - String name(); + public String name() { + return name; + } + + /** + * Gets the description of the calendar. + * + * @return the description of the calendar + */ + public String description() { + return description; + } + + /** + * Gets the timezone of the calendar. + * + * @return the time zone of the calendar + */ + public ZoneId timeZone() { + return timeZone; + } /** * Gets the current date. * * @return the current day */ - default String currentDay() { + public LocalDate currentDay() { return DateTimeUtils.today(timeZone()); } + ***today /tomorrow /yesterday + /** - * Gets yesterday's date. + * Gets the date the specified number of days prior to the input date. * - * @return the date before the current day + * @param date date; if null, return null + * @param days number of days; + * @return the date {@code days} before {@code date} */ - default String previousDay() { - return previousDay(currentDay()); + public LocalDate previousDay(final LocalDate date, final int days) { + if (date == null) { + return null; + } + + return date.minusDays(days); } /** - * Gets the date the specified number of days prior to the current day. + * Gets the previous date. + * + * @param date date; if null, return null + * @return the day before {@code date} + */ + public LocalDate previousDay(final LocalDate date) { + return previousDay(date, 1); + } + + /** + * Gets the date the specified number of days prior to the input date. * + * @param time time; if null, return null * @param days number of days; - * @return the date {@code days} before the current day + * @return the date {@code days} before {@code date} */ - default String previousDay(final int days) { - return previousDay(currentDay(), days); + public LocalDate previousDay(final ZonedDateTime time, final int days) { + if (time == null) { + return null; + } + + return previousDay(time.withZoneSameInstant(timeZone()), days); } /** @@ -71,7 +127,9 @@ default String previousDay(final int days) { * @param time time; if null, return null * @return the day before {@code time} */ - String previousDay(final Instant time); + public LocalDate previousDay(final ZonedDateTime time) { + return previousDay(time, 1); + } /** * Gets the date the specified number of days prior to the input date. @@ -80,15 +138,23 @@ default String previousDay(final int days) { * @param days number of days; * @return the date {@code days} before {@code date} */ - String previousDay(final Instant time, final int days); + public LocalDate previousDay(final Instant time, final int days) { + if (time == null) { + return null; + } + + return previousDay(DateTimeUtils.toZonedDateTime(time, timeZone()), days); + } /** * Gets the previous date. * - * @param date date; if null, return null - * @return the date before {@code date} + * @param time time; if null, return null + * @return the day before {@code time} */ - String previousDay(final String date); + public LocalDate previousDay(final Instant time) { + return previousDay(time, 1); + } /** * Gets the date the specified number of days prior to the input date. @@ -97,25 +163,56 @@ default String previousDay(final int days) { * @param days number of days; * @return the date {@code days} before {@code date} */ - String previousDay(final String date, final int days); + public LocalDate previousDay(final String date, final int days) { + if (date == null) { + return null; + } + + return previousDay(DateStringUtils.parseLocalDate(date), days); + } /** - * Gets tomorrow's date. + * Gets the previous date. * - * @return the date after the current day + * @param date date; if null, return null + * @return the date before {@code date} */ - default String nextDay() { - return nextDay(currentDay()); + public LocalDate previousDay(final String date) { + return previousDay(date, 1); } /** - * Gets the date {@code days} after the current day. + * Gets the date the specified number of days prior to the current day. * * @param days number of days; - * @return the day after the current day + * @return the date {@code days} before the current day */ - default String nextDay(final int days) { - return nextDay(currentDay(), days); + public LocalDate previousDay(final int days) { + return previousDay(currentDay(), days); + } + + /** + * Gets yesterday's date. + * + * @return the date before the current day + */ + public LocalDate previousDay() { + return previousDay(1); + } + + /** + * Gets the date {@code days} after the input {@code time}. + * + * @param date date; if null, return null + * @param days number of days; + * @return the day after {@code date} + */ + public LocalDate nextDay(final LocalDate date, final int days) { + if (date == null) { + return null; + } + + return date.plusDays(days); } /** @@ -124,7 +221,9 @@ default String nextDay(final int days) { * @param time time; if null, return null * @return the day after {@code time} */ - String nextDay(final Instant time); + public LocalDate nextDay(final LocalDate time) { + return nextDay(time, 1); + } /** * Gets the date {@code days} after the input {@code time}. @@ -133,15 +232,48 @@ default String nextDay(final int days) { * @param days number of days; * @return the day after {@code time} */ - String nextDay(final Instant time, final int days); + public LocalDate nextDay(final ZonedDateTime time, final int days) { + if (time == null) { + return null; + } + + return nextDay(time.withZoneSameInstant(timeZone()).toLocalDate(), days); + } /** * Gets the next date. * - * @param date date; if null, return null - * @return the date after {@code time} + * @param time time; if null, return null + * @return the day after {@code time} + */ + public LocalDate nextDay(final ZonedDateTime time) { + return nextDay(time, 1); + } + + /** + * Gets the date {@code days} after the input {@code time}. + * + * @param time time; if null, return null + * @param days number of days; + * @return the day after {@code time} + */ + public LocalDate nextDay(final Instant time, final int days) { + if (time == null) { + return null; + } + + return nextDay(DateTimeUtils.toZonedDateTime(time, timeZone()).toLocalDate(), days); + } + + /** + * Gets the next date. + * + * @param time time; if null, return null + * @return the day after {@code time} */ - String nextDay(final String date); + public LocalDate nextDay(final Instant time) { + return nextDay(time, 1); + } /** * Gets the date {@code days} after the input {@code date}. @@ -150,118 +282,305 @@ default String nextDay(final int days) { * @param days number of days; * @return the day after {@code time} */ - String nextDay(final String date, final int days); + public LocalDate nextDay(final String date, final int days) { + if (date == null) { + return null; + } + + return nextDay(DateStringUtils.parseLocalDate(date), days); + } + + /** + * Gets the next date. + * + * @param date date; if null, return null + * @return the date after {@code time} + */ + public LocalDate nextDay(final String date) { + return nextDay(date, 1); + } + + /** + * Gets the date {@code days} after the current day. + * + * @param days number of days; + * @return the day after the current day + */ + public LocalDate nextDay(final int days) { + return nextDay(currentDay(), days); + } + + /** + * Gets tomorrow's date. + * + * @return the date after the current day + */ + public LocalDate nextDay() { + return nextDay(currentDay()); + } + + /** + * Gets the days in a given range. + * + * @param start start of a time range; if null, return empty array + * @param end end of a time range; if null, return empty array + * @return the inclusive days between {@code start} and {@code end} + */ + public LocalDate[] daysInRange(final LocalDate start, final LocalDate end) { + if (start == null || end == null) { + return new LocalDate[0]; + } + + LocalDate day = start; + List dateList = new ArrayList<>(); + + while (!day.isAfter(end)) { + dateList.add(day); + day = day.plusDays(1); + } + + return dateList.toArray(new LocalDate[0]); + } /** * Gets the days in a given range. * * @param start start of a time range; if null, return empty array - * @param end end of a time range; if null, return empty array + * @param end end of a time range; if null, return empty array * @return the inclusive days between {@code start} and {@code end} */ - String[] daysInRange(Instant start, Instant end); + public LocalDate[] daysInRange(final ZonedDateTime start, final ZonedDateTime end) { + if (start == null || end == null) { + return new LocalDate[0]; + } + + return daysInRange(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate()); + } /** * Gets the days in a given range. * * @param start start of a time range; if null, return empty array - * @param end end of a time range; if null, return empty array + * @param end end of a time range; if null, return empty array * @return the inclusive days between {@code start} and {@code end} */ - String[] daysInRange(final String start, final String end); + public LocalDate[] daysInRange(final Instant start, final Instant end) { + if (start == null || end == null) { + return new LocalDate[0]; + } + + return daysInRange(DateTimeUtils.toZonedDateTime(start, timeZone()).toLocalDate(), DateTimeUtils.toZonedDateTime(end, timeZone()).toLocalDate()); + } /** - * Gets the number of days in a given range, end date exclusive. + * Gets the days in a given range. * - * @param start start of a time range; if null, return {@code NULL_INT} - * @param end end of a time range; if null, return {@code NULL_INT} - * @return the number days between {@code start} and {@code end}, inclusive and exclusive respectively. + * @param start start of a time range; if null, return empty array + * @param end end of a time range; if null, return empty array + * @return the inclusive days between {@code start} and {@code end} */ - int numberOfDays(final Instant start, final Instant end); + public LocalDate[] daysInRange(final String start, final String end) { + if (start == null || end == null) { + return new LocalDate[0]; + } + + return daysInRange(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end)); + } /** * Gets the number of days in a given range. * - * @param start start of a time range; if null, return {@code NULL_INT} - * @param end end of a time range; if null, return {@code NULL_INT} + * @param start start of a time range + * @param end end of a time range * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return the number of days between {@code start} and {@code end}, inclusive and {@code endInclusive} - * respectively. + * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - int numberOfDays(final Instant start, final Instant end, final boolean endInclusive); + public int numberOfDays(final LocalDate start, final LocalDate end, final boolean endInclusive) { + if (start == null || end == null) { + return QueryConstants.NULL_INT; + } + + int days = (int) ChronoUnit.DAYS.between(start, end); + if (days < 0) { + days = days - (endInclusive ? 1 : 0); + } else { + days = days + (endInclusive ? 1 : 0); + } + return days; + } /** * Gets the number of days in a given range, end date exclusive. * - * @param start start of a time range; if null, return {@code NULL_INT} - * @param end end of a time range; if null, return {@code NULL_INT} - * @return the number of days between {@code start} and {@code end}, inclusive and exclusive respectively. + * @param start start of a time range + * @param end end of a time range + * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - int numberOfDays(final String start, final String end); + public int numberOfDays(final LocalDate start, final LocalDate end) { + return numberOfDays(start, end, false); + } /** * Gets the number of days in a given range. * - * @param start start of a time range; if null, return {@code NULL_INT} - * @param end end of a time range; if null, return {@code NULL_INT} + * @param start start of a time range + * @param end end of a time range * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return the number of days between {@code start} and {@code end}, inclusive and {@code endInclusive} - * respectively. + * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - int numberOfDays(final String start, final String end, final boolean endInclusive); + public int numberOfDays(final ZonedDateTime start, final ZonedDateTime end, final boolean endInclusive) { + if (start == null || end == null) { + return QueryConstants.NULL_INT; + } + + return numberOfDays(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate(), endInclusive); + } /** - * Returns the amount of time in nanoseconds between {@code start} and {@code end}. + * Gets the number of days in a given range, end date exclusive. * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @return the amount of time in nanoseconds between the {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - long diffNanos(final Instant start, final Instant end); + public int numberOfDays(final ZonedDateTime start, final ZonedDateTime end) { + return numberOfDays(start, end, false); + } /** - * Returns the amount of time in days between {@code start} and {@code end}. + * Gets the number of days in a given range. * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @return the amount of time in days between the {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @param endInclusive whether to treat the {@code end} inclusive or exclusively + * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - double diffDay(final Instant start, final Instant end); + public int numberOfDays(final Instant start, final Instant end, final boolean endInclusive) { + if (start == null || end == null) { + return QueryConstants.NULL_INT; + } + + return numberOfDays(DateTimeUtils.toZonedDateTime(start, timeZone()).toLocalDate(), DateTimeUtils.toZonedDateTime(end, timeZone()).toLocalDate(), endInclusive); + } /** - * Returns the number of 365 day years between {@code start} and {@code end}. + * Gets the number of days in a given range, end date exclusive. * - * @param start start; if null, return null - * @param end end; if null, return null - * @return the amount of time in years between the {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - double diffYear365(Instant start, Instant end); + public int numberOfDays(final Instant start, final Instant end) { + return numberOfDays(start, end, false); + } /** - * Returns the number of average (365.2425 day) years between {@code start} and {@code end}. + * Gets the number of days in a given range. * - * @param start start; if null, return null - * @param end end; if null, return null - * @return the amount of time in years between the {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @param endInclusive whether to treat the {@code end} inclusive or exclusively + * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - double diffYearAvg(Instant start, Instant end); + public int numberOfDays(final String start, final String end, final boolean endInclusive) { + if (start == null || end == null) { + return QueryConstants.NULL_INT; + } + + return numberOfDays(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), endInclusive); + } /** - * Gets the day of the week for the current day. + * Gets the number of days in a given range, end date exclusive. * - * @return the day of the week of the current day + * @param start start of a time range + * @param end end of a time range + * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - default DayOfWeek dayOfWeek() { - return dayOfWeek(currentDay()); + public int numberOfDays(final String start, final String end) { + return numberOfDays(start, end, false); + } + + //TODO: remove +// /** +// * Returns the amount of time in nanoseconds between {@code start} and {@code end}. +// * +// * @param start start time; if null, return NULL_LONG +// * @param end end time; if null, return NULL_LONG +// * @return the amount of time in nanoseconds between the {@code start} and {@code end} +// */ +// long diffNanos(final Instant start, final Instant end); +// +// /** +// * Returns the amount of time in days between {@code start} and {@code end}. +// * +// * @param start start time; if null, return NULL_LONG +// * @param end end time; if null, return NULL_LONG +// * @return the amount of time in days between the {@code start} and {@code end} +// */ +// double diffDay(final Instant start, final Instant end); +// +// /** +// * Returns the number of 365 day years between {@code start} and {@code end}. +// * +// * @param start start; if null, return null +// * @param end end; if null, return null +// * @return the amount of time in years between the {@code start} and {@code end} +// */ +// double diffYear365(final Instant start, final Instant end); +// +// /** +// * Returns the number of average (365.2425 day) years between {@code start} and {@code end}. +// * +// * @param start start; if null, return null +// * @param end end; if null, return null +// * @return the amount of time in years between the {@code start} and {@code end} +// */ +// double diffYearAvg(final Instant start, final Instant end); + + //TODO: leave these dayOfWeek methods or remove them and just use DateTimeUtils?! + + /** + * Gets the day of the week for a time. + * + * @param date date; if null, return null + * @return the day of the week of {@code date} + */ + public DayOfWeek dayOfWeek(final LocalDate date) { + if (date == null) { + return null; + } + + return DayOfWeek.of(DateTimeUtils.dayOfWeek(date, timeZone())); } + + /** + * Gets the day of the week for a time. + * + * @param time time; if null, return null + * @return the day of the week of {@code time} + */ + public DayOfWeek dayOfWeek(final ZonedDateTime time) { + if (time == null) { + return null; + } + return dayOfWeek(time.withZoneSameInstant(timeZone())); + } + /** * Gets the day of the week for a time. * * @param time time; if null, return null * @return the day of the week of {@code time} */ - DayOfWeek dayOfWeek(final Instant time); + public DayOfWeek dayOfWeek(final Instant time) { + if (time == null) { + return null; + } + + return dayOfWeek(DateTimeUtils.toLocalDate(time, timeZone())); + } /** * Gets the day of the week for a time. @@ -269,12 +588,21 @@ default DayOfWeek dayOfWeek() { * @param date date; if null, return null * @return the day of the week of {@code date} */ - DayOfWeek dayOfWeek(final String date); + public DayOfWeek dayOfWeek(final String date) { + if (date == null) { + return null; + } + + return dayOfWeek(DateTimeUtils.parseLocalDate(date)); + } /** - * Gets the timezone of the calendar. + * Gets the day of the week for the current day. * - * @return the time zone of the calendar + * @return the day of the week of the current day */ - ZoneId timeZone(); + public DayOfWeek dayOfWeek() { + return dayOfWeek(currentDay()); + } + } diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/DefaultBusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/DefaultBusinessCalendar.java index 02080e1c06e..c1c70dd9f1d 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/DefaultBusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/DefaultBusinessCalendar.java @@ -6,7 +6,6 @@ import io.deephaven.base.Pair; import io.deephaven.time.DateTimeUtils; import io.deephaven.time.TimeZoneAliases; -import io.deephaven.util.QueryConstants; import io.deephaven.util.annotations.VisibleForTesting; import org.jdom2.Document; import org.jdom2.Element; @@ -33,7 +32,7 @@ * Overrides many default {@link Calendar} and BusinessCalendar methods for improved performance. See the documentation * of Calendar for details. */ -public class DefaultBusinessCalendar extends AbstractBusinessCalendar implements Serializable { +public class DefaultBusinessCalendar extends BusinessCalendar implements Serializable { private static final long serialVersionUID = -5887343387358189382L; @@ -324,85 +323,7 @@ public List getDefaultBusinessPeriods() { return Collections.unmodifiableList(defaultBusinessPeriodStrings); } - @Override - public Map getHolidays() { - return Collections.unmodifiableMap(holidays); - } - - @Override - public boolean isBusinessDay(DayOfWeek day) { - return !weekendDays.contains(day); - } - - @Override - public String name() { - return calendarName; - } - - @Override - public ZoneId timeZone() { - return timeZone; - } - - @Override - public long standardBusinessDayLengthNanos() { - return lengthOfDefaultDayNanos; - } - - @Override - @Deprecated - public BusinessSchedule getBusinessDay(final Instant time) { - if (time == null) { - return null; - } - - final LocalDate localDate = LocalDate.ofYearDay(DateTimeUtils.year(time, timeZone()), - DateTimeUtils.dayOfYear(time, timeZone())); - - return getBusinessSchedule(localDate); - } - - @Override - @Deprecated - public BusinessSchedule getBusinessDay(final String date) { - if (date == null) { - return null; - } - - return getBusinessSchedule(DateStringUtils.parseLocalDate(date)); - } - - @Override - @Deprecated - public BusinessSchedule getBusinessDay(final LocalDate date) { - return dates.computeIfAbsent(date, this::newBusinessDay); - } - - @Override - public BusinessSchedule getBusinessSchedule(final Instant time) { - if (time == null) { - return null; - } - final LocalDate localDate = LocalDate.ofYearDay(DateTimeUtils.year(time, timeZone()), - DateTimeUtils.dayOfYear(time, timeZone())); - - return getBusinessSchedule(localDate); - } - - @Override - public BusinessSchedule getBusinessSchedule(final String date) { - if (date == null) { - return null; - } - - return getBusinessSchedule(DateStringUtils.parseLocalDate(date)); - } - - @Override - public BusinessSchedule getBusinessSchedule(final LocalDate date) { - return dates.computeIfAbsent(date, this::newBusinessDay); - } private static String getText(Element element) { return element == null ? null : element.getTextTrim(); @@ -426,77 +347,6 @@ private static BusinessSchedule newBusinessDay(final LocalDate date, final Set Date: Tue, 27 Jun 2023 10:30:51 -0600 Subject: [PATCH 002/150] First refactoring. --- .../time/calendar/BusinessCalendar.java | 1293 ++++++++++++----- 1 file changed, 911 insertions(+), 382 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index 7bbcf5a61e9..e2597b562db 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -3,76 +3,123 @@ */ package io.deephaven.time.calendar; +import io.deephaven.base.verify.Require; +import io.deephaven.time.DateTimeUtils; +import io.deephaven.util.QueryConstants; + import java.time.DayOfWeek; import java.time.Instant; import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; +//TODO: review all docs + /** * A business calendar. Calendar is extended with the concept of business and non-business time. * * To comply with the ISO-8601 standard for dates, Strings should be of the form "yyyy-MM-dd", */ +//TODO: fail on out of range +//TODO: interface, abstract class, or class? +//TODO should the methods be DB null tolerant public interface BusinessCalendar extends Calendar { - /** - * Gets the business periods for the default days. - * - * @return a list of strings with a comma separating open and close times - */ - List getDefaultBusinessPeriods(); + // region Business Schedule + //TODO: rename /** * Gets business schedules for dates that are different from the defaults. This returns all dates that are defined * as a holiday for the calendar. * * @return a map of dates and to their business periods */ - Map getHolidays(); + default Map getHolidays() { + return Collections.unmodifiableMap(holidays); + } + //TODO: rename schedule or businessSchedule /** - * Gets today's business schedule. + * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. * - * @return today's business schedule + * @param date date + * @return the corresponding BusinessSchedule of {@code date} */ - default BusinessSchedule currentBusinessSchedule() { - return getBusinessSchedule(currentDay()); + default BusinessSchedule getBusinessSchedule(final LocalDate date) { + return dates.computeIfAbsent(date, this::newBusinessDay); } + //TODO: rename schedule /** - * Is the current day a business day? + * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. * - * @return true if the current day is a business day; false otherwise. + * @param time time + * @return the corresponding BusinessSchedule of {@code time}; null if time is null */ - default boolean isBusinessDay() { - return isBusinessDay(currentDay()); + default BusinessSchedule getBusinessSchedule(final ZonedDateTime time) { + if (time == null) { + return null; + } + + return getBusinessSchedule(time.withZoneSameInstant(timeZone())); } + //TODO: rename schedule /** - * Is the day of the week a business day? A business day is a day that has a business schedule with one or more - * business periods defined. + * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. * - * @param day a day of the week - * @return true if the day is a business day; false otherwise. + * @param time time + * @return the corresponding BusinessSchedule of {@code time}; null if time is null + */ + default BusinessSchedule getBusinessSchedule(final Instant time) { + if (time == null) { + return null; + } + + return getBusinessSchedule(time.atZone(timeZone())); + } + + //TODO: rename schedule + /** + * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. + * + * @param date date + * @return the corresponding BusinessSchedule of {@code date} */ - boolean isBusinessDay(DayOfWeek day); + default BusinessSchedule getBusinessSchedule(String date) { + if (date == null) { + return null; + } + + return getBusinessSchedule(DateTimeUtils.parseLocalDate(date)); + } + //TODO: rename current schedule? /** - * Does time occur on a business day? + * Gets today's business schedule. * - * @param time time - * @return true if the date is a business day; false otherwise. + * @return today's business schedule */ - boolean isBusinessDay(final Instant time); + default BusinessSchedule currentBusinessSchedule() { + return getBusinessSchedule(currentDay()); + } + + // endregion + + // region Business Day /** - * Is the date a business day? + * Does time occur on a business day? * * @param date date * @return true if the date is a business day; false otherwise. */ - boolean isBusinessDay(final String date); + default boolean isBusinessDay(final LocalDate date) { + return date != null && getBusinessSchedule(date).isBusinessDay(); + } /** * Is the date a business day? @@ -80,364 +127,557 @@ default boolean isBusinessDay() { * @param date date * @return true if the date is a business day; false otherwise. */ - boolean isBusinessDay(final LocalDate date); + default boolean isBusinessDay(final String date) { + if (date == null) { + return false; + } + + return isBusinessDay(DateTimeUtils.parseLocalDate(date)); + } + //TODO: review func /** - * Determines if the specified time is a business time. If the time falls between business periods, false will be - * returned. + * Does time occur on a business day? * * @param time time - * @return true if the specified time is a business time; otherwise, false. + * @return true if the date is a business day; false otherwise. */ - boolean isBusinessTime(final Instant time); + default boolean isBusinessDay(final ZonedDateTime time){ + return fractionOfStandardBusinessDay(time) > 0.0; + } + //TODO: review func /** - * Gets the previous business day. + * Does time occur on a business day? * - * @return previous business day + * @param time time + * @return true if the date is a business day; false otherwise. */ - default String previousBusinessDay() { - return previousBusinessDay(currentDay()); + default boolean isBusinessDay(final Instant time){ + return fractionOfStandardBusinessDay(time) > 0.0; } + //TODO: rename? /** - * Gets the business date {@code days} business days before the current day. If {@code days} is zero and today is - * not a business day, null is returned. + * Is the day of the week a business day? A business day is a day that has a business schedule with one or more + * business periods defined. * - * @param days number of days - * @return the business date {@code days} business days before the current day + * @param day a day of the week + * @return true if the day is a business day; false otherwise. */ - default String previousBusinessDay(int days) { - return previousBusinessDay(currentDay(), days); + default boolean isBusinessDay(DayOfWeek day){ + return !weekendDays.contains(day); } + //TODO: base on the current day or time? /** - * Gets the previous business day. + * Is the current day a business day? * - * @param time time; if null, return null - * @return the most recent business day before {@code time} + * @return true if the current day is a business day; false otherwise. */ - String previousBusinessDay(final Instant time); + default boolean isBusinessDay() { + return isBusinessDay(currentDay()); + } /** - * Gets the business date {@code days} business days before input {@code time}. If {@code days} is zero and the day - * is not a business day, null is returned. + * Is the time on the last business day of the month with business time remaining? * - * @param time time; if null, return null - * @param days number of days - * @return the business date {@code days} business days before input {@code time} + * @param date date + * @return true if {@code date} is on the last business day of the month with business time remaining; false + * otherwise. */ - String previousBusinessDay(final Instant time, int days); + boolean isLastBusinessDayOfMonth(final LocalDate date) { + if (!isBusinessDay(date)) { + return false; + } - /** - * Gets the previous business day. - * - * @param date date; if null, return null - * @return the most recent business day before {@code date} - */ - String previousBusinessDay(String date); + final LocalDate nextBusAfterDate = nextBusinessDay(date); - /** - * Gets the business date {@code days} business days before input {@code date}. If {@code days} is zero and the day - * is not a business day, null is returned. - * - * @param date date; if null, return null - * @param days number of days - * @return the business date {@code days} business days before input {@code date} - */ - String previousBusinessDay(String date, int days); + if(nextBusAfterDate == null){ + ** raise an error; + return false; + } + return date.getMonth() != nextBusAfterDate.getMonth(); + } /** - * Gets the previous business schedule. + * Is the time on the last business day of the month with business time remaining? * - * @return previous business schedule + * @param time time + * @return true if {@code time} is on the last business day of the month with business time remaining; false + * otherwise. */ - default BusinessSchedule previousBusinessSchedule() { - return previousBusinessSchedule(currentDay()); + default boolean isLastBusinessDayOfMonth(final ZonedDateTime time) { + if(time == null){ + ** raise an error; + return false; + } + + return isLastBusinessDayOfMonth(DateTimeUtils.toLocalDate(time.withZoneSameInstant(timeZone()))); } /** - * Gets the business schedule {@code days} days before the current day. - * - * Assumes implementation of getBusinessSchedule(null) returns null. + * Is the time on the last business day of the month with business time remaining? * - * @param days number of days - * @return the business schedule {@code days} days before the current day + * @param time time + * @return true if {@code time} is on the last business day of the month with business time remaining; false + * otherwise. */ - default BusinessSchedule previousBusinessSchedule(int days) { - return previousBusinessSchedule(currentDay(), days); + default boolean isLastBusinessDayOfMonth(final Instant time) { + if(time == null){ + ** raise an error; + return false; + } + + return isLastBusinessDayOfMonth(DateTimeUtils.toLocalDate(time, timeZone())); } /** - * Gets the previous business schedule before input {@code time}. - * - * Assumes implementation of getBusinessSchedule(null) returns null. + * Is the date the last business day of the month? * - * @param time time; if null, return null - * @return the most recent business schedule before {@code time} + * @param date date + * @return true if {@code date} is on the last business day of the month; false otherwise. */ - BusinessSchedule previousBusinessSchedule(final Instant time); + boolean isLastBusinessDayOfMonth(final String date) { + if(date == null){ + ** raise an error; + return false; + } - /** - * Gets the business schedule {@code days} days before input {@code time}. - * - * Assumes implementation of getBusinessSchedule(null) returns null. - * - * @param time time; if null, return null - * @param days number of days - */ - BusinessSchedule previousBusinessSchedule(final Instant time, int days); + return isLastBusinessDayOfMonth(DateTimeUtils.parseLocalDate(date)); + } /** - * Gets the business schedule before input {@code date}. - * - * Assumes implementation of getBusinessSchedule(null) returns null. + * Is the current day the last business day of the month? * - * @param date date; if null, return null - * @return the most recent business schedule before {@code date} + * @return true if {@code date} is on the last business day of the month; false otherwise. */ - BusinessSchedule previousBusinessSchedule(String date); + default boolean isLastBusinessDayOfMonth() { + return isLastBusinessDayOfMonth(currentDay()); + } /** - * Gets the business schedule {@code days} days before input {@code date}. - * - * Assumes implementation of getBusinessSchedule(null) returns null. + * Is the date the last business day of the week? * - * @param date date; if null, return null - * @param days number of days - * @return the business schedule {@code days} days before input {@code date} + * @param date date + * @return true if {@code date} is on the last business day of the week; false otherwise. */ - BusinessSchedule previousBusinessSchedule(String date, int days); + default boolean isLastBusinessDayOfWeek(final LocalDate date){ + if(date == null){ + *** error *** + return false; + } + + if (!isBusinessDay(date)) { + return false; + } + + final LocalDate nextBusinessDay = nextBusinessDay(date); + return dayOfWeek(date).compareTo(dayOfWeek(nextBusinessDay)) > 0 || numberOfDays(date, nextBusinessDay) > 6; + } /** - * Gets the previous non-business day. + * Is the time on the last business day of the week with business time remaining? * - * @return the most recent non-business day before the current day + * @param time time + * @return true if {@code time} is on the last business day of the week with business time remaining; false + * otherwise. */ - default String previousNonBusinessDay() { - return previousNonBusinessDay(currentDay()); + default boolean isLastBusinessDayOfWeek(final ZonedDateTime time) { + if(time == null){ + *** error ***; + return false; + } + + return isLastBusinessDayOfWeek(DateTimeUtils.toLocalDate(time, timeZone())); } /** - * Gets the non-business date {@code days} non-business days before the current day. If {@code days} is zero and the - * day is a business day, null is returned. + * Is the time on the last business day of the week with business time remaining? * - * @param days number of days - * @return the non-business date {@code days} non-business days before the current day + * @param time time + * @return true if {@code time} is on the last business day of the week with business time remaining; false + * otherwise. */ - default String previousNonBusinessDay(int days) { - return previousNonBusinessDay(currentDay(), days); + default boolean isLastBusinessDayOfWeek(final Instant time) { + if(time == null){ + *** error ***; + return false; + } + + return isLastBusinessDayOfWeek(DateTimeUtils.toLocalDate(time, timeZone())); } /** - * Gets the previous non-business day. + * Is the date the last business day of the week? * - * @param time time; if null, return null - * @return the most recent non-business day before {@code time} + * @param date date + * @return true if {@code date} is on the last business day of the week; false otherwise. */ - String previousNonBusinessDay(final Instant time); + default boolean isLastBusinessDayOfWeek(final String date){ + if(date == null){ + *** error ***; + return false; + } + + return isLastBusinessDayOfWeek(DateTimeUtils.parseLocalDate(date)); + } /** - * Gets the non-business date {@code days} non-business days before input {@code time}. If {@code days} is zero and - * the day is a business day, null is returned. + * Is the current day the last business day of the week? * - * @param time time; if null, return null - * @param days number of days - * @return the non-business date {@code days} non-business days before input {@code time} + * @return true if {@code date} is on the last business day of the week; false otherwise. */ - String previousNonBusinessDay(final Instant time, int days); + default boolean isLastBusinessDayOfWeek() { + return isLastBusinessDayOfWeek(currentDay()); + } + + // endregion + + // region Business Time /** - * Gets the previous non-business day. + * Determines if the specified time is a business time. If the time falls between business periods, false will be + * returned. * - * @param date date; if null, return null - * @return the most recent non-business day before {@code date} + * @param time time + * @return true if the specified time is a business time; otherwise, false. */ - String previousNonBusinessDay(String date); + default boolean isBusinessTime(final ZonedDateTime time) { + return time != null && getBusinessSchedule(time).isBusinessTime(time); + } /** - * Gets the non-business date {@code days} non-business days before input {@code date}. If {@code days} is zero and - * the day is a business day, null is returned. + * Determines if the specified time is a business time. If the time falls between business periods, false will be + * returned. * - * @param date date; if null, return null - * @param days number of days - * @return the non-business date {@code days} non-business days before input {@code date} + * @param time time + * @return true if the specified time is a business time; otherwise, false. */ - String previousNonBusinessDay(String date, int days); + default boolean isBusinessTime(final Instant time) { + return time != null && getBusinessSchedule(time).isBusinessTime(time); + } /** - * Gets the next business day. + * Returns the length of a standard business day in nanoseconds. * - * @return next business day + * @return length of a standard business day in nanoseconds. */ - default String nextBusinessDay() { - return nextBusinessDay(currentDay()); + default long standardBusinessDayLengthNanos() { + return lengthOfDefaultDayNanos; } /** - * Gets the business date {@code days} business days after the current day. If {@code days} is zero and today is not - * a business day, null is returned. + * For the given date, returns the ratio of the business day length and the standard business day length. For + * example, a holiday has zero business time and will therefore return 0.0. A normal business day will be of the + * standard length and will therefore return 1.0. A half day holiday will return 0.5. * - * @param days number of days - * @return the business date {@code days} business days after the current day + * @see BusinessCalendar#fractionOfBusinessDayRemaining(Instant) + * @param date date; if null, return 0 + * @return ratio of the business day length and the standard business day length for the date */ - default String nextBusinessDay(int days) { - return nextBusinessDay(currentDay(), days); + default double fractionOfStandardBusinessDay(final LocalDate date){ + final BusinessSchedule schedule = getBusinessSchedule(date); + return schedule == null ? 0.0 : (double) schedule.getLOBD() / (double) standardBusinessDayLengthNanos(); } /** - * Gets the next business day. + * For the given date, returns the ratio of the business day length and the standard business day length. For + * example, a holiday has zero business time and will therefore return 0.0. A normal business day will be of the + * standard length and will therefore return 1.0. A half day holiday will return 0.5. * - * @param time time; if null, return null - * @return the next business day after {@code time} + * @see BusinessCalendar#fractionOfBusinessDayRemaining(Instant) + * @param time time; if null, return 0 + * @return ratio of the business day length and the standard business day length for the date */ - String nextBusinessDay(final Instant time); + default double fractionOfStandardBusinessDay(final Instant time){ + return time == null ? 0.0 : fractionOfStandardBusinessDay(DateTimeUtils.toLocalDate(time, timeZone())); + } /** - * Gets the business date {@code days} business days after input {@code time}. If {@code days} is zero and the day - * is not a business day, null is returned. + * For the given date, returns the ratio of the business day length and the standard business day length. For + * example, a holiday has zero business time and will therefore return 0.0. A normal business day will be of the + * standard length and will therefore return 1.0. A half day holiday will return 0.5. * - * @param time time; if null, return null - * @param days number of days - * @return the next business day after {@code time} + * @see BusinessCalendar#fractionOfBusinessDayRemaining(Instant) + * @param time time; if null, return 0 + * @return ratio of the business day length and the standard business day length for the date */ - String nextBusinessDay(final Instant time, int days); + default double fractionOfStandardBusinessDay(final ZonedDateTime time){ + return time == null ? 0.0 : fractionOfStandardBusinessDay(DateTimeUtils.toLocalDate(time.toInstant(), timeZone())); + } /** - * Gets the next business day. + * Returns the ratio of the current day's business day length and the standard business day length. For example, a + * holiday has zero business time and will therefore return 0.0. A normal business day will be of the standard + * length and will therefore return 1.0. A half day holiday will return 0.5. * - * @param date date; if null, return null - * @return the next business day after {@code date} + * @see BusinessCalendar#fractionOfBusinessDayRemaining(Instant) + * @return ratio of the business day length and the standard business day length for the current day */ - String nextBusinessDay(String date); + default double fractionOfStandardBusinessDay() { + return fractionOfStandardBusinessDay(currentDay()); + } /** - * Gets the business date {@code days} business days after input {@code date}. If {@code days} is zero and the day - * is not a business day, null is returned. + * Returns the fraction of the business day remaining after the given time. * - * @param date date; if null, return null - * @param days number of days - * @return the business date {@code days} business days after input {@code date} + * @param time time + * @return the fraction of the day left after {@code time}; NULL_DOUBLE if time is null */ - String nextBusinessDay(String date, int days); + default double fractionOfBusinessDayRemaining(final Instant time){ + final BusinessSchedule businessDate = getBusinessSchedule(time); + if (businessDate == null) { + return QueryConstants.NULL_DOUBLE; + } + + if (businessDate.getLOBD() == 0) { + return 0; + } + + final long businessDaySoFar = businessDate.businessTimeElapsed(time); + return (double) (businessDate.getLOBD() - businessDaySoFar) / (double) businessDate.getLOBD(); + } /** - * Gets the next business schedule. + * Returns the fraction of the business day remaining after the given time. * - * @return next business schedule + * @param time time + * @return the fraction of the day left after {@code time}; NULL_DOUBLE if time is null */ - default BusinessSchedule nextBusinessSchedule() { - return nextBusinessSchedule(currentDay()); + default double fractionOfBusinessDayRemaining(final ZonedDateTime time){ + if(time == null) { + return QueryConstants.NULL_DOUBLE; + } + + return fractionOfBusinessDayRemaining(time.toInstant()); } /** - * Gets the business schedule {@code days} days after the current day. - * - * If the current day is null, assumes the implementation of getBusinessSchedule(null) returns null. + * Returns the fraction of the business day complete by the given time. * - * @param days number of days - * @return the next closest business schedule after the current day + * @param time time + * @return the fraction of the day complete by {@code time}; NULL_DOUBLE if time is null */ - default BusinessSchedule nextBusinessSchedule(int days) { - return nextBusinessSchedule(currentDay(), days); + default double fractionOfBusinessDayComplete(final Instant time) { + if (time == null) { + return QueryConstants.NULL_DOUBLE; + } + + return 1.0 - fractionOfBusinessDayRemaining(time); } /** - * Gets the next business schedule. + * Returns the fraction of the business day complete by the given time. * - * @param time time; if null, return null - * @return the next closest business schedule after {@code time} + * @param time time + * @return the fraction of the day complete by {@code time}; NULL_DOUBLE if time is null */ - BusinessSchedule nextBusinessSchedule(final Instant time); + default double fractionOfBusinessDayComplete(final ZonedDateTime time) { + if (time == null) { + return QueryConstants.NULL_DOUBLE; + } + + return fractionOfBusinessDayComplete(time.toInstant()); + } + // endregion + + // region Ranges + + //TODO: consistently handle inclusive / exclusive in these ranges + + //TODO: add InRange to name /** - * Gets the business schedule {@code days} days after input {@code time}. - * - * If {@code date} is null, assumes the implementation of getBusinessSchedule(null) returns null. + * Returns the number of business days between {@code start} and {@code end}. * - * @param time time; if null, return null - * @param days number of days - * @return the business schedule {@code days} after {@code time} + * @param start start time; if null, return NULL_INT + * @param end end time; if null, return NULL_INT + * @param endInclusive whether to treat the {@code end} inclusive or exclusively + * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} + * respectively. */ - BusinessSchedule nextBusinessSchedule(final Instant time, int days); + default int numberOfBusinessDays(final LocalDate start, final LocalDate end, final boolean endInclusive) { + if (start == null || end == null) { + return QueryConstants.NULL_INT; + } + + int days = 0; + if (start.isBefore(end)) { + if (isBusinessDay(start)) { + days++; + } + start = nextBusinessDay(start); + } else if (start.isAfter(end)) { + //TODO: is this working right? + return -numberOfBusinessDays(end, start, endInclusive); + } + + LocalDate day = start; + + while (day.isBefore(end)) { + days++; + day = nextBusinessDay(day); + } + + return days + (endInclusive && isBusinessDay(end) ? 1 : 0); + } + //TODO: add InRange to name + //TODO: add endInclusive on all methods /** - * Gets the next business schedule after input {@code date}. - * - * Assumes implementation of getBusinessSchedule(null) returns null. + * Returns the number of business days between {@code start} and {@code end}. * - * @param date date; if null, return null - * @return the next closest business schedule after {@code date} + * @param start start time; if null, return NULL_LONG + * @param end end time; if null, return NULL_LONG + * @param endInclusive whether to treat the {@code end} inclusive or exclusively + * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} + * respectively. */ - BusinessSchedule nextBusinessSchedule(String date); + default int numberOfBusinessDays(Instant start, Instant end, final boolean endInclusive) { + if (start == null || end == null) { + return QueryConstants.NULL_INT; + } + + return numberOfBusinessDays(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), endInclusive); + } + //TODO: add InRange to name /** - * Gets the business schedule {@code days} days after input {@code date}. - * - * If {@code date} is null, assumes the implementation of getBusinessSchedule(null) returns null. + * Returns the number of business days between {@code start} and {@code end}. * - * @param date date; if null, return null - * @param days number of days - * @return the business schedule {@code days} after {@code date} + * @param start start time; if null, return NULL_LONG + * @param end end time; if null, return NULL_LONG + * @param endInclusive whether to treat the {@code end} inclusive or exclusively + * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} + * respectively. */ - BusinessSchedule nextBusinessSchedule(String date, int days); + default int numberOfBusinessDays(ZonedDateTime start, ZonedDateTime end, final boolean endInclusive) { + if (start == null || end == null) { + return QueryConstants.NULL_INT; + } + + return numberOfBusinessDays(DateTimeUtils.toLocalDate(start.toInstant(), timeZone()), DateTimeUtils.toLocalDate(end.toInstant(), timeZone()), endInclusive); + } + //TODO: add InRange to name /** - * Gets the next non-business day. + * Returns the number of business days between {@code start} and {@code end}. * - * @return the next non-business day after the current day + * @param start start time; if null, return NULL_INT + * @param end end time; if null, return NULL_INT + * @param endInclusive whether to treat the {@code end} inclusive or exclusively + * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} + * respectively. */ - default String nextNonBusinessDay() { - return nextNonBusinessDay(currentDay()); + default int numberOfBusinessDays(String start, String end, final boolean endInclusive) { + if (start == null || end == null) { + return QueryConstants.NULL_INT; + } + + return numberOfBusinessDays(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), endInclusive); } + //TODO: add InRange to name /** - * Gets the non-business date {@code days} non-business days after the current day. If {@code days} is zero and the - * day is a business day, null is returned. + * Returns the number of non-business days between {@code start} and {@code end}. * - * @param days number of days - * @return the non-business date {@code days} non-business days after the current day + * @param start start time; if null, return NULL_INT + * @param end end time; if null, return NULL_INT + * @param endInclusive whether to treat the {@code end} inclusive or exclusively + * @return number of non-business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} + * respectively. */ - default String nextNonBusinessDay(int days) { - return nextNonBusinessDay(currentDay(), days); + default int numberOfNonBusinessDays(final LocalDate start, final LocalDate end, final boolean endInclusive) { + if (start == null || end == null) { + return QueryConstants.NULL_INT; + } + + return numberOfDays(start, end, endInclusive) - numberOfBusinessDays(start, end, endInclusive); } + //TODO: add InRange to name /** - * Gets the next non-business day. + * Returns the number of non-business days between {@code start} and {@code end}. * - * @param time time; if null, return null - * @return the next non-business day after {@code time} + * @param start start time; if null, return NULL_LONG + * @param end end time; if null, return NULL_LONG + * @param endInclusive whether to treat the {@code end} inclusive or exclusively + * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} + * respectively. */ - String nextNonBusinessDay(final Instant time); + default int numberOfNonBusinessDays(Instant start, Instant end, final boolean endInclusive) { + if (start == null || end == null) { + return QueryConstants.NULL_INT; + } + + return numberOfNonBusinessDays(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), endInclusive); + } + //TODO: add InRange to name /** - * Gets the non-business date {@code days} non-business days after input {@code time}. If {@code days} is zero and - * the day is a business day, null is returned. + * Returns the number of non-business days between {@code start} and {@code end}. * - * @param time time; if null, return null - * @param days number of days - * @return the non-business date {@code days} non-business days after input {@code time} + * @param start start time; if null, return NULL_INT + * @param end end time; if null, return NULL_INT + * @param endInclusive whether to treat the {@code end} inclusive or exclusively + * @return number of non-business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} + * respectively. */ - String nextNonBusinessDay(final Instant time, int days); + default int numberOfNonBusinessDays(final String start, final String end, final boolean endInclusive) { + if (start == null || end == null) { + return QueryConstants.NULL_INT; + } + + return numberOfNonBusinessDays(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), endInclusive); + } /** - * Gets the next non-business day. + * Returns the business days between {@code start} and {@code end}, inclusive. + * + * Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for {@code start} + * and {@code end} will be included if they are business days. * - * @param date date; if null, return null - * @return the next non-business day after {@code date} + * @param start start time; if null, return empty array + * @param end end time; if null, return empty array + * @return inclusive business days between {@code start} and {@code end} */ - String nextNonBusinessDay(String date); + default LocalDate[] businessDaysInRange(final LocalDate start, final LocalDate end) { + if (start == null || end == null) { + return new LocalDate[0]; + } + + LocalDate day = start; + final List dateList = new ArrayList<>(); + + while (!day.isAfter(end)) { + if (isBusinessDay(day)) { + dateList.add(day); + } + day = day.plusDays(1); + } + + return dateList.toArray(new LocalDate[0]); + } /** - * Gets the non-business date {@code days} non-business days after input {@code date}. If {@code days} is zero and - * the day is a business day, null is returned. + * Returns the business days between {@code start} and {@code end}, inclusive. * - * @param date date; if null, return null - * @param days number of days - * @return the most recent business day before {@code time} + * Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for {@code start} + * and {@code end} will be included if they are business days. + * + * @param start start time; if null, return empty array + * @param end end time; if null, return empty array + * @return inclusive business days between {@code start} and {@code end} */ - String nextNonBusinessDay(String date, int days); + default LocalDate[] businessDaysInRange(final Instant start, final Instant end) { + if (start == null || end == null) { + return new LocalDate[0]; + } + + return businessDaysInRange(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone())); + } /** * Returns the business days between {@code start} and {@code end}, inclusive. @@ -449,7 +689,13 @@ default String nextNonBusinessDay(int days) { * @param end end time; if null, return empty array * @return inclusive business days between {@code start} and {@code end} */ - String[] businessDaysInRange(final Instant start, final Instant end); + default LocalDate[] businessDaysInRange(final ZonedDateTime start, final ZonedDateTime end) { + if (start == null || end == null) { + return new LocalDate[0]; + } + + return businessDaysInRange(DateTimeUtils.toLocalDate(start.toInstant(), timeZone()), DateTimeUtils.toLocalDate(end.toInstant(), timeZone())); + } /** * Returns the business days between {@code start} and {@code end}, inclusive. @@ -461,7 +707,41 @@ default String nextNonBusinessDay(int days) { * @param end end time; if null, return empty array * @return inclusive business days between {@code start} and {@code end} */ - String[] businessDaysInRange(String start, String end); + default LocalDate[] businessDaysInRange(String start, String end){ + if (start == null || end == null) { + return new LocalDate[0]; + } + + return businessDaysInRange(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end)); + } + + /** + * Returns the non-business days between {@code start} and {@code end}, inclusive. + * + * Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for {@code start} + * and {@code end} will be included if they are non-business days. + * + * @param start start time; if null, return empty array + * @param end end time; if null, return empty array + * @return inclusive non-business days between {@code start} and {@code end} + */ + default LocalDate[] nonBusinessDaysInRange(final LocalDate start, final LocalDate end){ + if (start == null || end == null) { + return new LocalDate[0]; + } + + LocalDate day = start; + final List dateList = new ArrayList<>(); + + while (!day.isAfter(end)) { + if (!isBusinessDay(day)) { + dateList.add(day); + } + day = day.plusDays(1); + } + + return dateList.toArray(new LocalDate[0]); + } /** * Returns the non-business days between {@code start} and {@code end}, inclusive. @@ -473,7 +753,13 @@ default String nextNonBusinessDay(int days) { * @param end end time; if null, return empty array * @return inclusive non-business days between {@code start} and {@code end} */ - String[] nonBusinessDaysInRange(final Instant start, final Instant end); + default LocalDate[] nonBusinessDaysInRange(final Instant start, final Instant end){ + if (start == null || end == null) { + return new LocalDate[0]; + } + + return nonBusinessDaysInRange(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone())); + } /** * Returns the non-business days between {@code start} and {@code end}, inclusive. @@ -485,14 +771,31 @@ default String nextNonBusinessDay(int days) { * @param end end time; if null, return empty array * @return inclusive non-business days between {@code start} and {@code end} */ - String[] nonBusinessDaysInRange(String start, String end); + default LocalDate[] nonBusinessDaysInRange(final ZonedDateTime start, final ZonedDateTime end){ + if (start == null || end == null) { + return new LocalDate[0]; + } + + return nonBusinessDaysInRange(DateTimeUtils.toLocalDate(start.toInstant(), timeZone()), DateTimeUtils.toLocalDate(end.toInstant(), timeZone())); + } /** - * Returns the length of a standard business day in nanoseconds. + * Returns the non-business days between {@code start} and {@code end}, inclusive. * - * @return length of a standard business day in nanoseconds. + * Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for {@code start} + * and {@code end} will be included if they are non-business days. + * + * @param start start time; if null, return empty array + * @param end end time; if null, return empty array + * @return inclusive non-business days between {@code start} and {@code end} */ - long standardBusinessDayLengthNanos(); + default LocalDate[] nonBusinessDaysInRange(String start, String end){ + if (start == null || end == null) { + return new LocalDate[0]; + } + + return nonBusinessDaysInRange(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end)); + } /** * Returns the amount of business time in nanoseconds between {@code start} and {@code end}. @@ -501,274 +804,500 @@ default String nextNonBusinessDay(int days) { * @param end end time; if null, return NULL_LONG * @return the amount of business time in nanoseconds between the {@code start} and {@code end} */ - long diffBusinessNanos(Instant start, Instant end); + default long diffBusinessNanos(final Instant start, final Instant end) { + if (start == null || end == null) { + return QueryConstants.NULL_LONG; + } + + if (DateTimeUtils.isAfter(start, end)) { + return -diffBusinessNanos(end, start); + } + + long dayDiffNanos = 0; + Instant day = start; + + while (!DateTimeUtils.isAfter(day, end)) { + if (isBusinessDay(day)) { + BusinessSchedule businessDate = getBusinessSchedule(day); + + if (businessDate != null) { + for (BusinessPeriod businessPeriod : businessDate.getBusinessPeriods()) { + Instant endOfPeriod = businessPeriod.getEndTime(); + Instant startOfPeriod = businessPeriod.getStartTime(); + + // noinspection StatementWithEmptyBody + if (DateTimeUtils.isAfter(day, endOfPeriod) || DateTimeUtils.isBefore(end, startOfPeriod)) { + // continue + } else if (!DateTimeUtils.isAfter(day, startOfPeriod)) { + if (DateTimeUtils.isBefore(end, endOfPeriod)) { + dayDiffNanos += DateTimeUtils.minus(end, startOfPeriod); + } else { + dayDiffNanos += businessPeriod.getLength(); + } + } else { + if (DateTimeUtils.isAfter(end, endOfPeriod)) { + dayDiffNanos += DateTimeUtils.minus(endOfPeriod, day); + } else { + dayDiffNanos += DateTimeUtils.minus(end, day); + } + } + } + } + } + day = getBusinessSchedule(nextBusinessDay(day)).getSOBD(); + } + return dayDiffNanos; + } /** - * Returns the amount of non-business time in nanoseconds between {@code start} and {@code end}. + * Returns the amount of business time in nanoseconds between {@code start} and {@code end}. * * @param start start time; if null, return NULL_LONG * @param end end time; if null, return NULL_LONG - * @return the amount of non-business time in nanoseconds between the {@code start} and {@code end} + * @return the amount of business time in nanoseconds between the {@code start} and {@code end} */ - long diffNonBusinessNanos(final Instant start, final Instant end); + default long diffBusinessNanos(final ZonedDateTime start, final ZonedDateTime end) { + if (start == null || end == null) { + return QueryConstants.NULL_LONG; + } + + return diffBusinessNanos(start.toInstant(), end.toInstant()); + } /** - * Returns the amount of business time in standard business days between {@code start} and {@code end}. + * Returns the amount of non-business time in nanoseconds between {@code start} and {@code end}. * * @param start start time; if null, return NULL_LONG * @param end end time; if null, return NULL_LONG - * @return the amount of business time in standard business days between the {@code start} and {@code end} + * @return the amount of non-business time in nanoseconds between the {@code start} and {@code end} */ - double diffBusinessDay(final Instant start, final Instant end); + default long diffNonBusinessNanos(final Instant start, final Instant end) { + if (start == null || end == null) { + return QueryConstants.NULL_LONG; + } + + if (DateTimeUtils.isAfter(start, end)) { + return -diffNonBusinessNanos(end, start); + } + + return DateTimeUtils.minus(end, start) - diffBusinessNanos(start, end); + } /** - * Returns the amount of non-business time in standard business days between {@code start} and {@code end}. + * Returns the amount of non-business time in nanoseconds between {@code start} and {@code end}. * * @param start start time; if null, return NULL_LONG * @param end end time; if null, return NULL_LONG - * @return the amount of non-business time in standard business days between the {@code start} and {@code end} + * @return the amount of non-business time in nanoseconds between the {@code start} and {@code end} */ - double diffNonBusinessDay(final Instant start, final Instant end); + default long diffNonBusinessNanos(final ZonedDateTime start, final ZonedDateTime end) { + if (start == null || end == null) { + return QueryConstants.NULL_LONG; + } + + return diffNonBusinessNanos(start.toInstant(), end.toInstant()); + } /** - * Returns the number of business years between {@code start} and {@code end}. + * Returns the amount of business time in standard business days between {@code start} and {@code end}. * - * @param start start; if null, return null - * @param end end; if null, return null - * @return the amount of business time in business years between the {@code start} and {@code end} + * @param start start time; if null, return NULL_LONG + * @param end end time; if null, return NULL_LONG + * @return the amount of business time in standard business days between the {@code start} and {@code end} */ - double diffBusinessYear(Instant start, Instant end); + default double diffBusinessDay(final Instant start, final Instant end) { + if (start == null || end == null) { + return QueryConstants.NULL_DOUBLE; + } + + return (double) diffBusinessNanos(start, end) / (double) standardBusinessDayLengthNanos(); + } /** - * Returns the number of business days between {@code start} and {@code end}. + * Returns the amount of business time in standard business days between {@code start} and {@code end}. * - * @param start start time; if null, return NULL_INT - * @param end end time; if null, return NULL_INT - * @return number of business days between the {@code start} and {@code end}, inclusive and exclusive respectively. + * @param start start time; if null, return NULL_LONG + * @param end end time; if null, return NULL_LONG + * @return the amount of business time in standard business days between the {@code start} and {@code end} */ - int numberOfBusinessDays(Instant start, Instant end); + default double diffBusinessDay(final ZonedDateTime start, final ZonedDateTime end) { + if (start == null || end == null) { + return QueryConstants.NULL_DOUBLE; + } + + return diffBusinessDay(start.toInstant(), end.toInstant()); + } /** - * Returns the number of business days between {@code start} and {@code end}. + * Returns the amount of non-business time in standard business days between {@code start} and {@code end}. * * @param start start time; if null, return NULL_LONG * @param end end time; if null, return NULL_LONG - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} - * respectively. + * @return the amount of non-business time in standard business days between the {@code start} and {@code end} */ - int numberOfBusinessDays(Instant start, Instant end, final boolean endInclusive); + default double diffNonBusinessDay(final Instant start, final Instant end){ + if (start == null || end == null) { + return QueryConstants.NULL_DOUBLE; + } + + return (double) diffNonBusinessNanos(start, end) / (double) standardBusinessDayLengthNanos(); + } /** - * Returns the number of business days between {@code start} and {@code end}. + * Returns the amount of non-business time in standard business days between {@code start} and {@code end}. * - * @param start start time; if null, return NULL_INT - * @param end end time; if null, return NULL_INT - * @return number of business days between the {@code start} and {@code end}, inclusive and exclusive respectively. + * @param start start time; if null, return NULL_LONG + * @param end end time; if null, return NULL_LONG + * @return the amount of non-business time in standard business days between the {@code start} and {@code end} */ - int numberOfBusinessDays(String start, String end); + default double diffNonBusinessDay(final ZonedDateTime start, final ZonedDateTime end){ + if (start == null || end == null) { + return QueryConstants.NULL_DOUBLE; + } + + return diffNonBusinessDay(start.toInstant(), end.toInstant()); + } /** - * Returns the number of business days between {@code start} and {@code end}. + * Returns the number of business years between {@code start} and {@code end}. * - * @param start start time; if null, return NULL_INT - * @param end end time; if null, return NULL_INT - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} - * respectively. + * @param start start; if null, return null + * @param end end; if null, return null + * @return the amount of business time in business years between the {@code start} and {@code end} */ - int numberOfBusinessDays(String start, String end, final boolean endInclusive); + default double diffBusinessYear(final Instant start, final Instant end){ + if (start == null || end == null) { + return QueryConstants.NULL_DOUBLE; + } + + double businessYearDiff = 0.0; + Instant time = start; + while (!DateTimeUtils.isAfter(time, end)) { + // get length of the business year + final int startYear = DateTimeUtils.year(start, timeZone()); + final long businessYearLength = cachedYearLengths.computeIfAbsent(startYear, this::getBusinessYearLength); + + final Instant endOfYear = getFirstBusinessDateTimeOfYear(startYear + 1); + final long yearDiff; + if (DateTimeUtils.isAfter(endOfYear, end)) { + yearDiff = diffBusinessNanos(time, end); + } else { + yearDiff = diffBusinessNanos(time, endOfYear); + } + + businessYearDiff += (double) yearDiff / (double) businessYearLength; + time = endOfYear; + } + + return businessYearDiff; + } /** - * Returns the number of non-business days between {@code start} and {@code end}. + * Returns the number of business years between {@code start} and {@code end}. * - * @param start start time; if null, return NULL_INT - * @param end end time; if null, return NULL_INT - * @return number of business days between the {@code start} and {@code end}, inclusive and exclusive respectively. + * @param start start; if null, return null + * @param end end; if null, return null + * @return the amount of business time in business years between the {@code start} and {@code end} */ - int numberOfNonBusinessDays(Instant start, Instant end); + default double diffBusinessYear(final ZonedDateTime start, final ZonedDateTime end) { + if (start == null || end == null) { + return QueryConstants.NULL_DOUBLE; + } + + return diffBusinessYear(start.toInstant(), end.toInstant()); + } + + // endregion + + // region Arithmetic + + //TODO: what is the simpliest API? + //TODO: simplify names? e.g. nonbusinessday -> NBD? + //TODO: should the add/subtract methods on Instants or ZDT return times of LocalDates? /** - * Returns the number of non-business days between {@code start} and {@code end}. + * Adds a specified number of business days to an input date. Adding negative days is equivalent to subtracting days. * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} - * respectively. - */ - int numberOfNonBusinessDays(Instant start, Instant end, final boolean endInclusive); + * @param date date + * @param days number of days to add. + * @return {@code days} business days after {@code date}; null if {@code date} is null or if {@code date} is not a business day and {@code days} is zero. + */ + default LocalDate addBusinessDays(final LocalDate date, int days) { + if (date == null) { + return null; + } else if(days == 0){ + return isBusinessDay() ? date : null; + } + + final int step = days > 0 ? 1 : -1; + LocalDate d = date; + int count = 0; + + while (count != days) { + d = d.plusDays(step); + count += isBusinessDay(d) ? step : 0; + } + + return d; + } /** - * Returns the number of non-business days between {@code start} and {@code end}. + * Adds a specified number of business days to an input date. Adding negative days is equivalent to subtracting days. * - * @param start start time; if null, return NULL_INT - * @param end end time; if null, return NULL_INT - * @return number of non-business days between the {@code start} and {@code end}, inclusive. + * @param date date + * @param days number of days to add. + * @return {@code days} business days after {@code date}; null if {@code date} is null or if {@code date} is not a business day and {@code days} is zero. */ - int numberOfNonBusinessDays(final String start, final String end); + default LocalDate addBusinessDays(final String date, int days) { + if(date == null){ + return null; + } + + //TODO: should the date parsing be quiet? Document exceptions? + return addBusinessDays(DateTimeUtils.parseLocalDate(date), days); + } /** - * Returns the number of non-business days between {@code start} and {@code end}. - * - * @param start start time; if null, return NULL_INT - * @param end end time; if null, return NULL_INT - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return number of non-business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} - * respectively. - */ - int numberOfNonBusinessDays(final String start, final String end, final boolean endInclusive); + * Adds a specified number of business days to an input time. Adding negative days is equivalent to subtracting days. + * + * @param time time + * @param days number of days to add. + * @return {@code days} business days after {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. + */ + default LocalDate addBusinessDays(final Instant time, int days) { + if(time == null){ + return null; + } + + return addBusinessDays(DateTimeUtils.toLocalDate(time, timeZone()), days); + } /** - * Returns the ratio of the current day's business day length and the standard business day length. For example, a - * holiday has zero business time and will therefore return 0.0. A normal business day will be of the standard - * length and will therefore return 1.0. A half day holiday will return 0.5. + * Adds a specified number of business days to an input time. Adding negative days is equivalent to subtracting days. * - * @see BusinessCalendar#fractionOfBusinessDayRemaining(Instant) - * @return ratio of the business day length and the standard business day length for the current day + * @param time time + * @param days number of days to add. + * @return {@code days} business days after {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - default double fractionOfStandardBusinessDay() { - return fractionOfStandardBusinessDay(currentDay()); + default LocalDate addBusinessDays(final ZonedDateTime time, int days) { + if(time == null){ + return null; + } + + return addBusinessDays(time.toInstant(), days); } /** - * For the given date, returns the ratio of the business day length and the standard business day length. For - * example, a holiday has zero business time and will therefore return 0.0. A normal business day will be of the - * standard length and will therefore return 1.0. A half day holiday will return 0.5. + * Subtracts a specified number of business days from an input date. Subtracting negative days is equivalent to adding days. * - * @see BusinessCalendar#fractionOfBusinessDayRemaining(Instant) - * @param time time; if null, return 0 - * @return ratio of the business day length and the standard business day length for the date + * @param date date + * @param days number of days to subtract. + * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - double fractionOfStandardBusinessDay(final Instant time); + default LocalDate subtractBusinessDays(final LocalDate date, int days) { + return addBusinessDays(date, -days); + } /** - * For the given date, returns the ratio of the business day length and the standard business day length. For - * example, a holiday has zero business time and will therefore return 0.0. A normal business day will be of the - * standard length and will therefore return 1.0. A half day holiday will return 0.5. + * Subtracts a specified number of business days from an input date. Subtracting negative days is equivalent to adding days. * - * @see BusinessCalendar#fractionOfBusinessDayRemaining(Instant) - * @param date date; if null, return 0 - * @return ratio of the business day length and the standard business day length for the date + * @param date date + * @param days number of days to subtract. + * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - double fractionOfStandardBusinessDay(final String date); + default LocalDate subtractBusinessDays(final String date, int days) { + return addBusinessDays(date, -days); + } /** - * Returns the fraction of the business day remaining after the given time. + * Subtracts a specified number of business days from an input time. Subtracting negative days is equivalent to adding days. * * @param time time - * @return the fraction of the day left after {@code time}; NULL_DOUBLE if time is null + * @param days number of days to subtract. + * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - double fractionOfBusinessDayRemaining(final Instant time); + default LocalDate subtractBusinessDays(final Instant time, int days) { + return addBusinessDays(time, -days); + } /** - * Returns the fraction of the business day complete by the given time. + * Subtracts a specified number of business days from an input time. Subtracting negative days is equivalent to adding days. * * @param time time - * @return the fraction of the day complete by {@code time}; NULL_DOUBLE if time is null + * @param days number of days to subtract. + * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - double fractionOfBusinessDayComplete(final Instant time); + default LocalDate subtractBusinessDays(final ZonedDateTime time, int days) { + return addBusinessDays(time, -days); + } /** - * Is the time on the last business day of the month with business time remaining? + * Adds a specified number of non-business days to an input date. Adding negative days is equivalent to subtracting days. * - * @param time time - * @return true if {@code time} is on the last business day of the month with business time remaining; false - * otherwise. - */ - boolean isLastBusinessDayOfMonth(final Instant time); + * @param date date + * @param days number of days to add. + * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. + */ + default LocalDate addNonBusinessDays(final LocalDate date, int days) { + if (date == null) { + return null; + } else if(days == 0){ + return isBusinessDay() ? null : date; + } + + final int step = days > 0 ? 1 : -1; + LocalDate d = date; + int count = 0; + + while (count != days) { + d = d.plusDays(step); + count += isBusinessDay(d) ? 0 : step; + } + + return d; + } /** - * Is the current day the last business day of the month? + * Adds a specified number of non-business days to an input date. Adding negative days is equivalent to subtracting days. * - * @return true if {@code date} is on the last business day of the month; false otherwise. + * @param date date + * @param days number of days to add. + * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default boolean isLastBusinessDayOfMonth() { - return isLastBusinessDayOfMonth(currentDay()); + default LocalDate addNonBusinessDays(final LocalDate date, int days) { + if(date == null){ + return null; + } + + return addNonBusinessDays(DateTimeUtils.parseLocalDate(date), days); + } + + /** + * Adds a specified number of non-business days to an input time. Adding negative days is equivalent to subtracting days. + * + * @param time time + * @param days number of days to add. + * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. + */ + default LocalDate addNonBusinessDays(final Instant time, int days) { + if(time == null){ + return null; + } + + return addNonBusinessDays(DateTimeUtils.toLocalDate(time, timeZone()), days); } /** - * Is the date the last business day of the month? + * Adds a specified number of non-business days to an input time. Adding negative days is equivalent to subtracting days. * - * @param date date - * @return true if {@code date} is on the last business day of the month; false otherwise. + * @param time time + * @param days number of days to add. + * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - boolean isLastBusinessDayOfMonth(final String date); + default LocalDate addNonBusinessDays(final ZonedDateTime time, int days) { + if(time == null){ + return null; + } + + return addNonBusinessDays(time.toInstant(), days); + } /** - * Is the current day the last business day of the week? + * Subtracts a specified number of non-business days to an input date. Subtracting negative days is equivalent to adding days. * - * @return true if {@code date} is on the last business day of the week; false otherwise. + * @param date date + * @param days number of days to subtract. + * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default boolean isLastBusinessDayOfWeek() { - return isLastBusinessDayOfWeek(currentDay()); + default LocalDate subtractNonBusinessDays(final LocalDate date, int days) { + return addNonBusinessDays(date, -days); } /** - * Is the time on the last business day of the week with business time remaining? + * Subtracts a specified number of non-business days to an input date. Subtracting negative days is equivalent to adding days. * - * @param time time - * @return true if {@code time} is on the last business day of the week with business time remaining; false - * otherwise. + * @param date date + * @param days number of days to subtract. + * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - boolean isLastBusinessDayOfWeek(final Instant time); + default LocalDate subtractNonBusinessDays(final String date, int days) { + return addNonBusinessDays(date, -days); + } /** - * Is the date the last business day of the week? + * Subtracts a specified number of non-business days to an input time. Subtracting negative days is equivalent to adding days. * - * @param date date - * @return true if {@code date} is on the last business day of the week; false otherwise. + * @param time time + * @param days number of days to subtract. + * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code time} is a business day and {@code days} is zero. */ - boolean isLastBusinessDayOfWeek(final String date); + default LocalDate subtractNonBusinessDays(final Instant time, int days) { + return addNonBusinessDays(time, -days); + } /** - * Gets the indicated business day. + * Subtracts a specified number of non-business days to an input time. Subtracting negative days is equivalent to adding days. * * @param time time - * @return the corresponding BusinessSchedule of {@code time}; null if time is null + * @param days number of days to subtract. + * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code time} is a business day and {@code days} is zero. */ - @Deprecated - BusinessSchedule getBusinessDay(final Instant time); + default LocalDate subtractNonBusinessDays(final ZonedDateTime time, int days) { + return addNonBusinessDays(time, -days); + } /** - * Gets the indicated business day. + * Adds a specified number of business days to the current date. Adding negative days is equivalent to subtracting days. * - * @param date date - * @return the corresponding BusinessSchedule of {@code date} + * @param days number of days to add. + * @return {@code days} business days after the current date; null if the current date is not a business day and {@code days} is zero. */ - @Deprecated - BusinessSchedule getBusinessDay(String date); + default LocalDate nextBusinessDay(int days) { + return addBusinessDays(currentDay(), days); + } /** - * Gets the indicated business day. + * Subtracts a specified number of business days from the current date. Subtracting negative days is equivalent to adding days. * - * @param date date - * @return the corresponding BusinessSchedule of {@code date} + * @param days number of days to subtract. + * @return {@code days} business days before the current date; null if the current date is not a business day and {@code days} is zero. */ - @Deprecated - BusinessSchedule getBusinessDay(final LocalDate date); + default LocalDate previousBusinessDay(int days) { + return subtractBusinessDays(currentDay(), days); + } /** - * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. + * Adds a specified number of non-business days to the current date. Adding negative days is equivalent to subtracting days. * - * @param time time - * @return the corresponding BusinessSchedule of {@code time}; null if time is null + * @param days number of days to add. + * @return {@code days} non-business days after the current date; null if the current date is a business day and {@code days} is zero. */ - BusinessSchedule getBusinessSchedule(final Instant time); + default LocalDate nextNonBusinessDay(int days) { + return addNonBusinessDays(currentDay(), days); + } /** - * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. + * Subtracts a specified number of non-business days to the current date. Subtracting negative days is equivalent to adding days. * - * @param date date - * @return the corresponding BusinessSchedule of {@code date} + * @param days number of days to subtract. + * @return {@code days} non-business days before the current date; null if the current date is a business day and {@code days} is zero. */ - BusinessSchedule getBusinessSchedule(String date); + default LocalDate previousNonBusinessDay(int days) { + return subtractNonBusinessDays(currentDay(), days); + } + + // endregion + //TODO: relocate + //TODO: remove from API? + //TODO: rename /** - * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. + * Gets the business periods for the default days. * - * @param date date - * @return the corresponding BusinessSchedule of {@code date} + * @return a list of strings with a comma separating open and close times */ - BusinessSchedule getBusinessSchedule(final LocalDate date); + default List getDefaultBusinessPeriods(){ + return Collections.unmodifiableList(defaultBusinessPeriodStrings); + } + } From eb583ec0a74e66da5bd954b544a27f6286f18a2f Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 27 Jun 2023 14:08:34 -0600 Subject: [PATCH 003/150] Add local date chronology methods. --- .../java/io/deephaven/time/DateTimeUtils.java | 132 ++++++++++++++++-- .../io/deephaven/time/TestDateTimeUtils.java | 47 +++++-- 2 files changed, 159 insertions(+), 20 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java b/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java index 3cb9086d07b..83dda6920ea 100644 --- a/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java +++ b/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java @@ -2497,11 +2497,27 @@ public static int hourOfDay(@Nullable final ZonedDateTime dateTime) { return minuteOfDay(dateTime) / 60; } + /** + * Returns a 1-based int value of the day of the week for a {@link ZonedDateTime} in the specified time zone, with 1 + * being Monday and 7 being Sunday. + * + * @param date date to find the day of the week of + * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the day of the week + */ + @ScriptApi + public static int dayOfWeek(@Nullable final LocalDate date) { + if (date == null) { + return io.deephaven.util.QueryConstants.NULL_INT; + } + + return date.getDayOfWeek().getValue(); + } + /** * Returns a 1-based int value of the day of the week for an {@link Instant} in the specified time zone, with 1 * being Monday and 7 being Sunday. * - * @param instant time to find the day of the month of + * @param instant time to find the day of the week of * @param timeZone time zone * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the day of the week */ @@ -2518,7 +2534,7 @@ public static int dayOfWeek(@Nullable final Instant instant, @Nullable final Zon * Returns a 1-based int value of the day of the week for a {@link ZonedDateTime} in the specified time zone, with 1 * being Monday and 7 being Sunday. * - * @param dateTime time to find the day of the month of + * @param dateTime time to find the day of the week of * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the day of the week */ @ScriptApi @@ -2530,6 +2546,22 @@ public static int dayOfWeek(@Nullable final ZonedDateTime dateTime) { return dateTime.getDayOfWeek().getValue(); } + /** + * Returns a 1-based int value of the day of the month for a {@link ZonedDateTime} and specified time zone. The + * first day of the month returns 1, the second day returns 2, etc. + * + * @param date date to find the day of the month of + * @return A {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the day of the month + */ + @ScriptApi + public static int dayOfMonth(@Nullable final LocalDate date) { + if (date == null) { + return io.deephaven.util.QueryConstants.NULL_INT; + } + + return date.getDayOfMonth(); + } + /** * Returns a 1-based int value of the day of the month for an {@link Instant} and specified time zone. The first day * of the month returns 1, the second day returns 2, etc. @@ -2563,11 +2595,27 @@ public static int dayOfMonth(@Nullable final ZonedDateTime dateTime) { return dateTime.getDayOfMonth(); } + /** + * Returns a 1-based int value of the day of the year (Julian date) for a {@link ZonedDateTime} in the specified + * time zone. The first day of the year returns 1, the second day returns 2, etc. + * + * @param date date to find the day of the year of + * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the day of the year + */ + @ScriptApi + public static int dayOfYear(@Nullable final LocalDate date) { + if (date == null) { + return io.deephaven.util.QueryConstants.NULL_INT; + } + + return date.getDayOfYear(); + } + /** * Returns a 1-based int value of the day of the year (Julian date) for an {@link Instant} in the specified time * zone. The first day of the year returns 1, the second day returns 2, etc. * - * @param instant time to find the day of the month of + * @param instant time to find the day of the year of * @param timeZone time zone * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the day of the year */ @@ -2584,7 +2632,7 @@ public static int dayOfYear(@Nullable final Instant instant, @Nullable final Zon * Returns a 1-based int value of the day of the year (Julian date) for a {@link ZonedDateTime} in the specified * time zone. The first day of the year returns 1, the second day returns 2, etc. * - * @param dateTime time to find the day of the month of + * @param dateTime time to find the day of the year of * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the day of the year */ @ScriptApi @@ -2596,11 +2644,27 @@ public static int dayOfYear(@Nullable final ZonedDateTime dateTime) { return dateTime.getDayOfYear(); } + /** + * Returns a 1-based int value of the month of the year (Julian date) for a {@link LocalDate}. + * January is 1, February is 2, etc. + * + * @param date date to find the month of the year of + * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the month of the year + */ + @ScriptApi + public static int monthOfYear(@Nullable final LocalDate date) { + if (date == null) { + return io.deephaven.util.QueryConstants.NULL_INT; + } + + return date.getMonthValue(); + } + /** * Returns a 1-based int value of the month of the year (Julian date) for an {@link Instant} in the specified time * zone. January is 1, February is 2, etc. * - * @param instant time to find the day of the month of + * @param instant time to find the month of the year of * @param timeZone time zone * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the month of the year */ @@ -2617,7 +2681,7 @@ public static int monthOfYear(@Nullable final Instant instant, @Nullable final Z * Returns a 1-based int value of the month of the year (Julian date) for a {@link ZonedDateTime} in the specified * time zone. January is 1, February is 2, etc. * - * @param dateTime time to find the day of the month of + * @param dateTime time to find the month of the year of * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the month of the year */ @ScriptApi @@ -2629,10 +2693,25 @@ public static int monthOfYear(@Nullable final ZonedDateTime dateTime) { return dateTime.getMonthValue(); } + /** + * Returns the year for a {@link LocalDate}. + * + * @param date date to find the year of + * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the year + */ + @ScriptApi + public static int year(@Nullable final LocalDate date) { + if (date == null) { + return io.deephaven.util.QueryConstants.NULL_INT; + } + + return date.getYear(); + } + /** * Returns the year for an {@link Instant} in the specified time zone. * - * @param instant time to find the day of the month of + * @param instant time to find the year of * @param timeZone time zone * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the year */ @@ -2648,7 +2727,7 @@ public static int year(@Nullable final Instant instant, @Nullable final ZoneId t /** * Returns the year for a {@link ZonedDateTime} in the specified time zone. * - * @param dateTime time to find the day of the month of + * @param dateTime time to find the year of * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the year */ @ScriptApi @@ -2660,10 +2739,26 @@ public static int year(@Nullable final ZonedDateTime dateTime) { return dateTime.getYear(); } + /** + * Returns the year of the century (two-digit year) for a {@link LocalDate} in the specified time zone. + * + * @param date date to find the year of + * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the year of the century + * (two-digit year) + */ + @ScriptApi + public static int yearOfCentury(@Nullable final LocalDate date) { + if (date == null) { + return io.deephaven.util.QueryConstants.NULL_INT; + } + + return year(date) % 100; + } + /** * Returns the year of the century (two-digit year) for an {@link Instant} in the specified time zone. * - * @param instant time to find the day of the month of + * @param instant time to find the year of * @param timeZone time zone * @return {@link QueryConstants#NULL_INT} if either input is {@code null}; otherwise, the year of the century * (two-digit year) @@ -2693,6 +2788,25 @@ public static int yearOfCentury(@Nullable final ZonedDateTime dateTime) { return year(dateTime) % 100; } + /** + * Returns an {@link ZonedDateTime} for the prior midnight in the specified time zone. + * + * @param date date to compute the prior midnight for + * @param timeZone time zone + * @return {@code null} if either input is {@code null}; otherwise an {@link ZonedDateTime} representing the prior + * midnight in the specified time zone + */ + @ScriptApi + @Nullable + public static ZonedDateTime atMidnight(@Nullable final LocalDate date, @Nullable ZoneId timeZone) { + if (date == null || timeZone == null) { + return null; + } + + return date.atStartOfDay(timeZone); + } + + //TODO: return ZDT? /** * Returns an {@link Instant} for the prior midnight in the specified time zone. * diff --git a/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java b/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java index 771195184ba..246fe50f2f7 100644 --- a/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java +++ b/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java @@ -354,9 +354,6 @@ public void testParseEpochNanosQuiet() { final long micros = DateTimeUtils.epochMicros(dt1); final long millis = DateTimeUtils.epochMillis(dt1); final long seconds = DateTimeUtils.epochSeconds(dt1); - final Instant dt1u = DateTimeUtils.epochMicrosToInstant(micros); - final Instant dt1m = DateTimeUtils.epochMillisToInstant(millis); - final Instant dt1s = DateTimeUtils.epochSecondsToInstant(seconds); TestCase.assertEquals(nanos, DateTimeUtils.parseEpochNanosQuiet(Long.toString(nanos))); TestCase.assertEquals(micros * 1_000L, DateTimeUtils.parseEpochNanosQuiet(Long.toString(micros))); TestCase.assertEquals(millis * 1_000_000L, DateTimeUtils.parseEpochNanosQuiet(Long.toString(millis))); @@ -890,7 +887,6 @@ public void testParsePeriod() { } try { - // noinspection ConstantConditions DateTimeUtils.parsePeriod("JUNK"); TestCase.fail("Should throw an exception"); } catch (Exception ex) { @@ -2319,75 +2315,99 @@ public void testDiffYears() { } public void testYear() { + final LocalDate dt1 = LocalDate.of(2023,1,2); final Instant dt2 = DateTimeUtils.parseInstant("2023-01-02T11:23:45.123456789 JP"); final ZonedDateTime dt3 = dt2.atZone(TZ_JP); + TestCase.assertEquals(2023, DateTimeUtils.year(dt1)); + TestCase.assertEquals(NULL_INT, DateTimeUtils.year((LocalDate) null)); + TestCase.assertEquals(2023, DateTimeUtils.year(dt2, TZ_JP)); TestCase.assertEquals(NULL_INT, DateTimeUtils.year(dt2, null)); TestCase.assertEquals(NULL_INT, DateTimeUtils.year(null, TZ_JP)); TestCase.assertEquals(2023, DateTimeUtils.year(dt3)); - TestCase.assertEquals(NULL_INT, DateTimeUtils.year(null)); + TestCase.assertEquals(NULL_INT, DateTimeUtils.year((ZonedDateTime) null)); } public void testYearOfCentury() { + final LocalDate dt1 = LocalDate.of(2023,1,2); final Instant dt2 = DateTimeUtils.parseInstant("2023-01-02T11:23:45.123456789 JP"); final ZonedDateTime dt3 = dt2.atZone(TZ_JP); + TestCase.assertEquals(23, DateTimeUtils.yearOfCentury(dt1)); + TestCase.assertEquals(NULL_INT, DateTimeUtils.yearOfCentury((LocalDate) null)); + TestCase.assertEquals(23, DateTimeUtils.yearOfCentury(dt2, TZ_JP)); TestCase.assertEquals(NULL_INT, DateTimeUtils.yearOfCentury(dt2, null)); TestCase.assertEquals(NULL_INT, DateTimeUtils.yearOfCentury(null, TZ_JP)); TestCase.assertEquals(23, DateTimeUtils.yearOfCentury(dt3)); - TestCase.assertEquals(NULL_INT, DateTimeUtils.yearOfCentury(null)); + TestCase.assertEquals(NULL_INT, DateTimeUtils.yearOfCentury((ZonedDateTime) null)); } public void testMonthOfYear() { + final LocalDate dt1 = LocalDate.of(2023,2,3); final Instant dt2 = DateTimeUtils.parseInstant("2023-02-03T11:23:45.123456789 JP"); final ZonedDateTime dt3 = dt2.atZone(TZ_JP); + TestCase.assertEquals(2, DateTimeUtils.monthOfYear(dt1)); + TestCase.assertEquals(NULL_INT, DateTimeUtils.monthOfYear((LocalDate) null)); + TestCase.assertEquals(2, DateTimeUtils.monthOfYear(dt2, TZ_JP)); TestCase.assertEquals(NULL_INT, DateTimeUtils.monthOfYear(dt2, null)); TestCase.assertEquals(NULL_INT, DateTimeUtils.monthOfYear(null, TZ_JP)); TestCase.assertEquals(2, DateTimeUtils.monthOfYear(dt3)); - TestCase.assertEquals(NULL_INT, DateTimeUtils.monthOfYear(null)); + TestCase.assertEquals(NULL_INT, DateTimeUtils.monthOfYear((ZonedDateTime) null)); } public void testDayOfMonth() { + final LocalDate dt1 = LocalDate.of(2023,2,3); final Instant dt2 = DateTimeUtils.parseInstant("2023-02-03T11:23:45.123456789 JP"); final ZonedDateTime dt3 = dt2.atZone(TZ_JP); + TestCase.assertEquals(3, DateTimeUtils.dayOfMonth(dt1)); + TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfMonth((LocalDate) null)); + TestCase.assertEquals(3, DateTimeUtils.dayOfMonth(dt2, TZ_JP)); TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfMonth(dt2, null)); TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfMonth(null, TZ_JP)); TestCase.assertEquals(3, DateTimeUtils.dayOfMonth(dt3)); - TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfMonth(null)); + TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfMonth((ZonedDateTime) null)); } public void testDayOfWeek() { + final LocalDate dt1 = LocalDate.of(2023,2,3); final Instant dt2 = DateTimeUtils.parseInstant("2023-02-03T11:23:45.123456789 JP"); final ZonedDateTime dt3 = dt2.atZone(TZ_JP); + TestCase.assertEquals(DayOfWeek.FRIDAY.getValue(), DateTimeUtils.dayOfWeek(dt1)); + TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfWeek((LocalDate) null)); + TestCase.assertEquals(DayOfWeek.FRIDAY.getValue(), DateTimeUtils.dayOfWeek(dt2, TZ_JP)); TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfWeek(dt2, null)); TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfWeek(null, TZ_JP)); TestCase.assertEquals(DayOfWeek.FRIDAY.getValue(), DateTimeUtils.dayOfWeek(dt3)); - TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfWeek(null)); + TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfWeek((ZonedDateTime) null)); } public void testDayOfYear() { + final LocalDate dt1 = LocalDate.of(2023,2,3); final Instant dt2 = DateTimeUtils.parseInstant("2023-02-03T11:23:45.123456789 JP"); final ZonedDateTime dt3 = dt2.atZone(TZ_JP); + TestCase.assertEquals(34, DateTimeUtils.dayOfYear(dt1)); + TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfYear((LocalDate) null)); + TestCase.assertEquals(34, DateTimeUtils.dayOfYear(dt2, TZ_JP)); TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfYear(dt2, null)); TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfYear(null, TZ_JP)); TestCase.assertEquals(34, DateTimeUtils.dayOfYear(dt3)); - TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfYear(null)); + TestCase.assertEquals(NULL_INT, DateTimeUtils.dayOfYear((ZonedDateTime) null)); } public void testHourOfDay() { @@ -2738,15 +2758,20 @@ public void testMicrosOfMilli() { } public void testAtMidnight() { + final LocalDate dt1 = LocalDate.of(2023,2,3); + final Instant dt2 = DateTimeUtils.parseInstant("2023-02-03T11:23:45.123456789 JP"); final ZonedDateTime dt3 = dt2.atZone(TZ_JP); final Instant rst2 = DateTimeUtils.parseInstant("2023-02-03T00:00:00 JP"); final ZonedDateTime rst3 = rst2.atZone(TZ_JP); + TestCase.assertEquals(rst3, DateTimeUtils.atMidnight(dt1, TZ_JP)); + TestCase.assertNull(DateTimeUtils.atMidnight((LocalDate) null, TZ_JP)); + TestCase.assertEquals(rst2, DateTimeUtils.atMidnight(dt2, TZ_JP)); TestCase.assertNull(DateTimeUtils.atMidnight(dt2, null)); - TestCase.assertNull(DateTimeUtils.atMidnight(null, TZ_JP)); + TestCase.assertNull(DateTimeUtils.atMidnight((Instant) null, TZ_JP)); TestCase.assertEquals(rst3, DateTimeUtils.atMidnight(dt3)); TestCase.assertNull(DateTimeUtils.atMidnight(null)); From 0bd59cfcadcbcf63ef3874a0034a4caa79903b67 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 27 Jun 2023 14:09:54 -0600 Subject: [PATCH 004/150] Calendar refactoring and cleanup. --- .../io/deephaven/time/calendar/Calendar.java | 363 +++++------------- 1 file changed, 98 insertions(+), 265 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java index 6fb8738c829..9987c2034b5 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java @@ -11,9 +11,9 @@ import java.util.ArrayList; import java.util.List; +//TODO: update all headers //TODO: review all docs -//TODO: future_day / past_day //TODO: add regions /** @@ -30,6 +30,8 @@ public class Calendar { private final String description; private final ZoneId timeZone; + // region Constructors + /** * Creates a new calendar. * @@ -43,6 +45,10 @@ public Calendar(String name, String description, ZoneId timeZone) { this.timeZone = timeZone; } + // endregion + + // region Getters + /** * Gets the name of the calendar. * @@ -70,254 +76,170 @@ public ZoneId timeZone() { return timeZone; } - /** - * Gets the current date. - * - * @return the current day - */ - public LocalDate currentDay() { - return DateTimeUtils.today(timeZone()); - } + // endregion + + // region Arithmetic - ***today /tomorrow /yesterday + //TODO should these methods be named add/subtract or plus/minus? /** - * Gets the date the specified number of days prior to the input date. + * Adds a specified number of days to an input date. Adding negative days is equivalent to subtracting days. * - * @param date date; if null, return null - * @param days number of days; - * @return the date {@code days} before {@code date} + * @param date date + * @param days number of days to add + * @return {@code days} days after {@code date}; null if {@code date} is null */ - public LocalDate previousDay(final LocalDate date, final int days) { + public LocalDate addDays(final LocalDate date, final int days) { if (date == null) { return null; } - return date.minusDays(days); + return date.plusDays(days); } /** - * Gets the previous date. + * Adds a specified number of days to an input date. Adding negative days is equivalent to subtracting days. * - * @param date date; if null, return null - * @return the day before {@code date} + * @param date date + * @param days number of days to add + * @return {@code days} days after {@code date}; null if {@code date} is null */ - public LocalDate previousDay(final LocalDate date) { - return previousDay(date, 1); + public LocalDate addDays(final String date, final int days) { + if (date == null) { + return null; + } + + //TODO: quiet parsing? document exception? + return addDays(DateTimeUtils.parseLocalDate(date), days); } /** - * Gets the date the specified number of days prior to the input date. + * Adds a specified number of days to an input time. Adding negative days is equivalent to subtracting days. * - * @param time time; if null, return null - * @param days number of days; - * @return the date {@code days} before {@code date} + * @param time time + * @param days number of days to add + * @return {@code days} days after {@code time}; null if {@code date} is null */ - public LocalDate previousDay(final ZonedDateTime time, final int days) { + public LocalDate addDays(final Instant time, final int days) { if (time == null) { return null; } - return previousDay(time.withZoneSameInstant(timeZone()), days); - } - - /** - * Gets the previous date. - * - * @param time time; if null, return null - * @return the day before {@code time} - */ - public LocalDate previousDay(final ZonedDateTime time) { - return previousDay(time, 1); + return addDays(DateTimeUtils.toLocalDate(time, timeZone), days); } /** - * Gets the date the specified number of days prior to the input date. + * Adds a specified number of days to an input time. Adding negative days is equivalent to subtracting days. * - * @param time time; if null, return null - * @param days number of days; - * @return the date {@code days} before {@code date} + * @param time time + * @param days number of days to add + * @return {@code days} days after {@code time}; null if {@code date} is null */ - public LocalDate previousDay(final Instant time, final int days) { + public LocalDate addDays(final ZonedDateTime time, final int days) { if (time == null) { return null; } - return previousDay(DateTimeUtils.toZonedDateTime(time, timeZone()), days); + return addDays(time.toInstant(), days); } /** - * Gets the previous date. + * Subtracts a specified number of days to an input date. Subtracting negative days is equivalent to adding days. * - * @param time time; if null, return null - * @return the day before {@code time} + * @param date date + * @param days number of days to add + * @return {@code days} days after {@code date}; null if {@code date} is null */ - public LocalDate previousDay(final Instant time) { - return previousDay(time, 1); - } - - /** - * Gets the date the specified number of days prior to the input date. - * - * @param date date; if null, return null - * @param days number of days; - * @return the date {@code days} before {@code date} - */ - public LocalDate previousDay(final String date, final int days) { + public LocalDate subtractDays(final LocalDate date, final int days) { if (date == null) { return null; } - return previousDay(DateStringUtils.parseLocalDate(date), days); - } - - /** - * Gets the previous date. - * - * @param date date; if null, return null - * @return the date before {@code date} - */ - public LocalDate previousDay(final String date) { - return previousDay(date, 1); - } - - /** - * Gets the date the specified number of days prior to the current day. - * - * @param days number of days; - * @return the date {@code days} before the current day - */ - public LocalDate previousDay(final int days) { - return previousDay(currentDay(), days); - } - - /** - * Gets yesterday's date. - * - * @return the date before the current day - */ - public LocalDate previousDay() { - return previousDay(1); + return date.minusDays(days); } /** - * Gets the date {@code days} after the input {@code time}. + * Subtracts a specified number of days to an input date. Subtracting negative days is equivalent to adding days. * - * @param date date; if null, return null - * @param days number of days; - * @return the day after {@code date} + * @param date date + * @param days number of days to add + * @return {@code days} days after {@code date}; null if {@code date} is null */ - public LocalDate nextDay(final LocalDate date, final int days) { + public LocalDate subtractDays(final String date, final int days) { if (date == null) { return null; } - return date.plusDays(days); - } - - /** - * Gets the next date. - * - * @param time time; if null, return null - * @return the day after {@code time} - */ - public LocalDate nextDay(final LocalDate time) { - return nextDay(time, 1); + return subtractDays(DateTimeUtils.parseLocalDate(date), days); } /** - * Gets the date {@code days} after the input {@code time}. + * Subtracts a specified number of days to an input time. Subtracting negative days is equivalent to adding days. * - * @param time time; if null, return null - * @param days number of days; - * @return the day after {@code time} + * @param time time + * @param days number of days to add + * @return {@code days} days after {@code time}; null if {@code date} is null */ - public LocalDate nextDay(final ZonedDateTime time, final int days) { + public LocalDate subtractDays(final Instant time, final int days) { if (time == null) { return null; } - return nextDay(time.withZoneSameInstant(timeZone()).toLocalDate(), days); + return subtractDays(DateTimeUtils.toLocalDate(time, timeZone), days); } /** - * Gets the next date. + * Subtracts a specified number of days to an input time. Subtracting negative days is equivalent to adding days. * - * @param time time; if null, return null - * @return the day after {@code time} + * @param time time + * @param days number of days to add + * @return {@code days} days after {@code time}; null if {@code date} is null */ - public LocalDate nextDay(final ZonedDateTime time) { - return nextDay(time, 1); - } - - /** - * Gets the date {@code days} after the input {@code time}. - * - * @param time time; if null, return null - * @param days number of days; - * @return the day after {@code time} - */ - public LocalDate nextDay(final Instant time, final int days) { + public LocalDate subtractDays(final ZonedDateTime time, final int days) { if (time == null) { return null; } - return nextDay(DateTimeUtils.toZonedDateTime(time, timeZone()).toLocalDate(), days); + return subtractDays(time.toInstant(), days); } +//TODO: future_day / past_day + //TODO: rename currentDate? -> nextDate() or futureDate() /** - * Gets the next date. + * Adds a specified number of days to the current date. Adding negative days is equivalent to subtracting days. * - * @param time time; if null, return null - * @return the day after {@code time} + * @param days number of days to add. + * @return {@code days} days after the current date */ - public LocalDate nextDay(final Instant time) { - return nextDay(time, 1); + public LocalDate nextDay(int days) { + return addDays(currentDay(), days); } +//TODO: future_day / past_day + //TODO: rename previousDate? /** - * Gets the date {@code days} after the input {@code date}. + * Subtracts a specified number of days from the current date. Subtracting negative days is equivalent to adding days. * - * @param date time; if null, return null - * @param days number of days; - * @return the day after {@code time} + * @param days number of days to subtract. + * @return {@code days} days before the current date */ - public LocalDate nextDay(final String date, final int days) { - if (date == null) { - return null; - } - - return nextDay(DateStringUtils.parseLocalDate(date), days); + public LocalDate previousDay(int days) { + return subtractDays(currentDay(), days); } + //TODO: rename currentDate? -> nextDate() or futureDate() /** - * Gets the next date. + * The current date. * - * @param date date; if null, return null - * @return the date after {@code time} + * @return current date */ - public LocalDate nextDay(final String date) { - return nextDay(date, 1); + public LocalDate currentDay() { + return DateTimeUtils.today(timeZone()); } - /** - * Gets the date {@code days} after the current day. - * - * @param days number of days; - * @return the day after the current day - */ - public LocalDate nextDay(final int days) { - return nextDay(currentDay(), days); - } + // endregion - /** - * Gets tomorrow's date. - * - * @return the date after the current day - */ - public LocalDate nextDay() { - return nextDay(currentDay()); - } + // region Ranges /** * Gets the days in a given range. @@ -387,6 +309,7 @@ public LocalDate[] daysInRange(final String start, final String end) { return daysInRange(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end)); } + //TODO: add InRange to the names? /** * Gets the number of days in a given range. * @@ -501,108 +424,18 @@ public int numberOfDays(final String start, final String end) { return numberOfDays(start, end, false); } - //TODO: remove -// /** -// * Returns the amount of time in nanoseconds between {@code start} and {@code end}. -// * -// * @param start start time; if null, return NULL_LONG -// * @param end end time; if null, return NULL_LONG -// * @return the amount of time in nanoseconds between the {@code start} and {@code end} -// */ -// long diffNanos(final Instant start, final Instant end); -// -// /** -// * Returns the amount of time in days between {@code start} and {@code end}. -// * -// * @param start start time; if null, return NULL_LONG -// * @param end end time; if null, return NULL_LONG -// * @return the amount of time in days between the {@code start} and {@code end} -// */ -// double diffDay(final Instant start, final Instant end); -// -// /** -// * Returns the number of 365 day years between {@code start} and {@code end}. -// * -// * @param start start; if null, return null -// * @param end end; if null, return null -// * @return the amount of time in years between the {@code start} and {@code end} -// */ -// double diffYear365(final Instant start, final Instant end); -// -// /** -// * Returns the number of average (365.2425 day) years between {@code start} and {@code end}. -// * -// * @param start start; if null, return null -// * @param end end; if null, return null -// * @return the amount of time in years between the {@code start} and {@code end} -// */ -// double diffYearAvg(final Instant start, final Instant end); - - //TODO: leave these dayOfWeek methods or remove them and just use DateTimeUtils?! - - /** - * Gets the day of the week for a time. - * - * @param date date; if null, return null - * @return the day of the week of {@code date} - */ - public DayOfWeek dayOfWeek(final LocalDate date) { - if (date == null) { - return null; - } + //TODO: +// diffBusinessDay +// diffBusinessDay +// diffBusinessNanos +// diffBusinessNanos +// diffBusinessYear +// diffBusinessYear +// diffNonBusinessDay +// diffNonBusinessDay +// diffNonBusinessNanos +// diffNonBusinessNanos - return DayOfWeek.of(DateTimeUtils.dayOfWeek(date, timeZone())); - } - - /** - * Gets the day of the week for a time. - * - * @param time time; if null, return null - * @return the day of the week of {@code time} - */ - public DayOfWeek dayOfWeek(final ZonedDateTime time) { - if (time == null) { - return null; - } - - return dayOfWeek(time.withZoneSameInstant(timeZone())); - } - - /** - * Gets the day of the week for a time. - * - * @param time time; if null, return null - * @return the day of the week of {@code time} - */ - public DayOfWeek dayOfWeek(final Instant time) { - if (time == null) { - return null; - } - - return dayOfWeek(DateTimeUtils.toLocalDate(time, timeZone())); - } - - /** - * Gets the day of the week for a time. - * - * @param date date; if null, return null - * @return the day of the week of {@code date} - */ - public DayOfWeek dayOfWeek(final String date) { - if (date == null) { - return null; - } - - return dayOfWeek(DateTimeUtils.parseLocalDate(date)); - } - - /** - * Gets the day of the week for the current day. - * - * @return the day of the week of the current day - */ - public DayOfWeek dayOfWeek() { - return dayOfWeek(currentDay()); - } + // endregion } From 3afab435ead6920273e4193d98b2edf98e9549f4 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 27 Jun 2023 14:16:49 -0600 Subject: [PATCH 005/150] Calendar refactoring and cleanup. --- .../io/deephaven/time/calendar/Calendar.java | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java index 9987c2034b5..32b50b0f371 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java @@ -13,8 +13,7 @@ //TODO: update all headers //TODO: review all docs - -//TODO: add regions +//TODO: review API /** * A calendar. @@ -80,8 +79,6 @@ public ZoneId timeZone() { // region Arithmetic - //TODO should these methods be named add/subtract or plus/minus? - /** * Adds a specified number of days to an input date. Adding negative days is equivalent to subtracting days. * @@ -89,7 +86,7 @@ public ZoneId timeZone() { * @param days number of days to add * @return {@code days} days after {@code date}; null if {@code date} is null */ - public LocalDate addDays(final LocalDate date, final int days) { + public LocalDate plusDays(final LocalDate date, final int days) { if (date == null) { return null; } @@ -104,13 +101,13 @@ public LocalDate addDays(final LocalDate date, final int days) { * @param days number of days to add * @return {@code days} days after {@code date}; null if {@code date} is null */ - public LocalDate addDays(final String date, final int days) { + public LocalDate plusDays(final String date, final int days) { if (date == null) { return null; } //TODO: quiet parsing? document exception? - return addDays(DateTimeUtils.parseLocalDate(date), days); + return plusDays(DateTimeUtils.parseLocalDate(date), days); } /** @@ -120,12 +117,12 @@ public LocalDate addDays(final String date, final int days) { * @param days number of days to add * @return {@code days} days after {@code time}; null if {@code date} is null */ - public LocalDate addDays(final Instant time, final int days) { + public LocalDate plusDays(final Instant time, final int days) { if (time == null) { return null; } - return addDays(DateTimeUtils.toLocalDate(time, timeZone), days); + return plusDays(DateTimeUtils.toLocalDate(time, timeZone), days); } /** @@ -135,22 +132,22 @@ public LocalDate addDays(final Instant time, final int days) { * @param days number of days to add * @return {@code days} days after {@code time}; null if {@code date} is null */ - public LocalDate addDays(final ZonedDateTime time, final int days) { + public LocalDate plusDays(final ZonedDateTime time, final int days) { if (time == null) { return null; } - return addDays(time.toInstant(), days); + return plusDays(time.toInstant(), days); } /** * Subtracts a specified number of days to an input date. Subtracting negative days is equivalent to adding days. * * @param date date - * @param days number of days to add + * @param days number of days to subtract * @return {@code days} days after {@code date}; null if {@code date} is null */ - public LocalDate subtractDays(final LocalDate date, final int days) { + public LocalDate minusDays(final LocalDate date, final int days) { if (date == null) { return null; } @@ -162,45 +159,45 @@ public LocalDate subtractDays(final LocalDate date, final int days) { * Subtracts a specified number of days to an input date. Subtracting negative days is equivalent to adding days. * * @param date date - * @param days number of days to add + * @param days number of days to subtract * @return {@code days} days after {@code date}; null if {@code date} is null */ - public LocalDate subtractDays(final String date, final int days) { + public LocalDate minusDays(final String date, final int days) { if (date == null) { return null; } - return subtractDays(DateTimeUtils.parseLocalDate(date), days); + return minusDays(DateTimeUtils.parseLocalDate(date), days); } /** * Subtracts a specified number of days to an input time. Subtracting negative days is equivalent to adding days. * * @param time time - * @param days number of days to add + * @param days number of days to subtract * @return {@code days} days after {@code time}; null if {@code date} is null */ - public LocalDate subtractDays(final Instant time, final int days) { + public LocalDate minusDays(final Instant time, final int days) { if (time == null) { return null; } - return subtractDays(DateTimeUtils.toLocalDate(time, timeZone), days); + return minusDays(DateTimeUtils.toLocalDate(time, timeZone), days); } /** * Subtracts a specified number of days to an input time. Subtracting negative days is equivalent to adding days. * * @param time time - * @param days number of days to add + * @param days number of days to subtract * @return {@code days} days after {@code time}; null if {@code date} is null */ - public LocalDate subtractDays(final ZonedDateTime time, final int days) { + public LocalDate minusDays(final ZonedDateTime time, final int days) { if (time == null) { return null; } - return subtractDays(time.toInstant(), days); + return minusDays(time.toInstant(), days); } //TODO: future_day / past_day @@ -212,7 +209,7 @@ public LocalDate subtractDays(final ZonedDateTime time, final int days) { * @return {@code days} days after the current date */ public LocalDate nextDay(int days) { - return addDays(currentDay(), days); + return plusDays(currentDay(), days); } //TODO: future_day / past_day @@ -224,7 +221,7 @@ public LocalDate nextDay(int days) { * @return {@code days} days before the current date */ public LocalDate previousDay(int days) { - return subtractDays(currentDay(), days); + return minusDays(currentDay(), days); } //TODO: rename currentDate? -> nextDate() or futureDate() From 527cb3a777d77a493fc0f58c05b78502e1490292 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 27 Jun 2023 14:24:48 -0600 Subject: [PATCH 006/150] Calendar refactoring and cleanup. --- .../util/TestCalendarMethodsFromTable.java | 26 +-- .../io/deephaven/time/calendar/Calendar.java | 33 ++-- .../calendar/StaticCalendarMethodsTest.java | 30 ++-- .../calendar/TestDefaultBusinessCalendar.java | 162 +++++++++--------- 4 files changed, 124 insertions(+), 127 deletions(-) diff --git a/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java b/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java index 0b5986c39f4..85bdd7be1c9 100644 --- a/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java +++ b/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java @@ -60,29 +60,29 @@ public void testCalendarMethodsTable() { assertEquals(calendar.name(), getVal(emptyTable(1).update("Name = name()"), "Name")); - assertEquals(calendar.currentDay(), getVal(emptyTable(1).update("currentDay = currentDay()"), "currentDay")); + assertEquals(calendar.currentDate(), getVal(emptyTable(1).update("currentDay = currentDay()"), "currentDay")); - assertEquals(calendar.previousDay(), + assertEquals(calendar.pastDate(), getVal(emptyTable(1).update("previousDay = previousDay()"), "previousDay")); - assertEquals(calendar.previousDay(4), + assertEquals(calendar.pastDate(4), getVal(emptyTable(1).update("previousDay = previousDay(4)"), "previousDay")); - assertEquals(calendar.previousDay(time1), + assertEquals(calendar.pastDate(time1), getVal(emptyTable(1).update("previousDay = previousDay(time1)"), "previousDay")); - assertEquals(calendar.previousDay(time1, 4), + assertEquals(calendar.pastDate(time1, 4), getVal(emptyTable(1).update("previousDay = previousDay(time1, 4)"), "previousDay")); - assertEquals(calendar.previousDay(date1), + assertEquals(calendar.pastDate(date1), getVal(emptyTable(1).update("previousDay = previousDay(date1)"), "previousDay")); - assertEquals(calendar.previousDay(date1, 14), + assertEquals(calendar.pastDate(date1, 14), getVal(emptyTable(1).update("previousDay = previousDay(date1, 14)"), "previousDay")); - assertEquals(calendar.nextDay(), getVal(emptyTable(1).update("nextDay = nextDay()"), "nextDay")); - assertEquals(calendar.nextDay(4), getVal(emptyTable(1).update("nextDay = nextDay(4)"), "nextDay")); - assertEquals(calendar.nextDay(time1), getVal(emptyTable(1).update("nextDay = nextDay(time1)"), "nextDay")); - assertEquals(calendar.nextDay(time1, 4), + assertEquals(calendar.futureDate(), getVal(emptyTable(1).update("nextDay = nextDay()"), "nextDay")); + assertEquals(calendar.futureDate(4), getVal(emptyTable(1).update("nextDay = nextDay(4)"), "nextDay")); + assertEquals(calendar.futureDate(time1), getVal(emptyTable(1).update("nextDay = nextDay(time1)"), "nextDay")); + assertEquals(calendar.futureDate(time1, 4), getVal(emptyTable(1).update("nextDay = nextDay(time1, 4)"), "nextDay")); - assertEquals(calendar.nextDay(date1), getVal(emptyTable(1).update("nextDay = nextDay(date1)"), "nextDay")); - assertEquals(calendar.nextDay(date1, 14), + assertEquals(calendar.futureDate(date1), getVal(emptyTable(1).update("nextDay = nextDay(date1)"), "nextDay")); + assertEquals(calendar.futureDate(date1, 14), getVal(emptyTable(1).update("nextDay = nextDay(date1, 14)"), "nextDay")); assertEquals(calendar.daysInRange(time1, time2), diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java index 32b50b0f371..bc2abbe90ea 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java @@ -200,44 +200,41 @@ public LocalDate minusDays(final ZonedDateTime time, final int days) { return minusDays(time.toInstant(), days); } -//TODO: future_day / past_day - //TODO: rename currentDate? -> nextDate() or futureDate() + /** + * The current date. + * + * @return current date + */ + public LocalDate currentDate() { + return DateTimeUtils.today(timeZone()); + } + /** * Adds a specified number of days to the current date. Adding negative days is equivalent to subtracting days. * * @param days number of days to add. * @return {@code days} days after the current date */ - public LocalDate nextDay(int days) { - return plusDays(currentDay(), days); + public LocalDate futureDate(int days) { + return plusDays(currentDate(), days); } -//TODO: future_day / past_day - //TODO: rename previousDate? /** * Subtracts a specified number of days from the current date. Subtracting negative days is equivalent to adding days. * * @param days number of days to subtract. * @return {@code days} days before the current date */ - public LocalDate previousDay(int days) { - return minusDays(currentDay(), days); - } - - //TODO: rename currentDate? -> nextDate() or futureDate() - /** - * The current date. - * - * @return current date - */ - public LocalDate currentDay() { - return DateTimeUtils.today(timeZone()); + public LocalDate pastDate(int days) { + return minusDays(currentDate(), days); } // endregion // region Ranges + ** + /** * Gets the days in a given range. * diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java b/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java index 578e77ff0e6..afad4caeea7 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java @@ -23,21 +23,21 @@ public class StaticCalendarMethodsTest extends BaseArrayTestCase { public void testCalendarMethods() { assertEquals(calendar.name(), StaticCalendarMethods.name()); - assertEquals(calendar.currentDay(), StaticCalendarMethods.currentDay()); - - assertEquals(calendar.previousDay(), StaticCalendarMethods.previousDay()); - assertEquals(calendar.previousDay(4), StaticCalendarMethods.previousDay(4)); - assertEquals(calendar.previousDay(time1), StaticCalendarMethods.previousDay(time1)); - assertEquals(calendar.previousDay(time1, 4), StaticCalendarMethods.previousDay(time1, 4)); - assertEquals(calendar.previousDay(date1), StaticCalendarMethods.previousDay(date1)); - assertEquals(calendar.previousDay(date1, 14), StaticCalendarMethods.previousDay(date1, 14)); - - assertEquals(calendar.nextDay(), StaticCalendarMethods.nextDay()); - assertEquals(calendar.nextDay(4), StaticCalendarMethods.nextDay(4)); - assertEquals(calendar.nextDay(time2), StaticCalendarMethods.nextDay(time2)); - assertEquals(calendar.nextDay(time2, 4), StaticCalendarMethods.nextDay(time2, 4)); - assertEquals(calendar.nextDay(date2), StaticCalendarMethods.nextDay(date2)); - assertEquals(calendar.nextDay(date2, 14), StaticCalendarMethods.nextDay(date2, 14)); + assertEquals(calendar.currentDate(), StaticCalendarMethods.currentDay()); + + assertEquals(calendar.pastDate(), StaticCalendarMethods.previousDay()); + assertEquals(calendar.pastDate(4), StaticCalendarMethods.previousDay(4)); + assertEquals(calendar.pastDate(time1), StaticCalendarMethods.previousDay(time1)); + assertEquals(calendar.pastDate(time1, 4), StaticCalendarMethods.previousDay(time1, 4)); + assertEquals(calendar.pastDate(date1), StaticCalendarMethods.previousDay(date1)); + assertEquals(calendar.pastDate(date1, 14), StaticCalendarMethods.previousDay(date1, 14)); + + assertEquals(calendar.futureDate(), StaticCalendarMethods.nextDay()); + assertEquals(calendar.futureDate(4), StaticCalendarMethods.nextDay(4)); + assertEquals(calendar.futureDate(time2), StaticCalendarMethods.nextDay(time2)); + assertEquals(calendar.futureDate(time2, 4), StaticCalendarMethods.nextDay(time2, 4)); + assertEquals(calendar.futureDate(date2), StaticCalendarMethods.nextDay(date2)); + assertEquals(calendar.futureDate(date2, 14), StaticCalendarMethods.nextDay(date2, 14)); assertEquals(calendar.daysInRange(time1, time2), StaticCalendarMethods.daysInRange(time1, time2)); assertEquals(calendar.daysInRange(date1, date2), StaticCalendarMethods.daysInRange(date1, date2)); diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java index dc75bf9d83b..13f200343f6 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java @@ -75,100 +75,100 @@ public void testName() { } public void testNextDay() { - assertEquals("2017-09-28", test.nextDay()); - assertEquals("2017-09-29", test.nextDay(2)); - assertEquals("2017-10-11", test.nextDay(14)); + assertEquals("2017-09-28", test.futureDate()); + assertEquals("2017-09-29", test.futureDate(2)); + assertEquals("2017-10-11", test.futureDate(14)); Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); String day2 = "2016-09-02"; - assertEquals(USNYSE.nextDay(day1, 2), day2); - assertEquals(JPOSE.nextDay(day1, 2), day2); - assertEquals(USNYSE.nextDay(day2, -2), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.nextDay(day2, -2), DateTimeUtils.formatDate(day1, TZ_JP)); + assertEquals(USNYSE.futureDate(day1, 2), day2); + assertEquals(JPOSE.futureDate(day1, 2), day2); + assertEquals(USNYSE.futureDate(day2, -2), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(JPOSE.futureDate(day2, -2), DateTimeUtils.formatDate(day1, TZ_JP)); - assertEquals(USNYSE.nextDay(day1, 0), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.nextDay(day1, 0), DateTimeUtils.formatDate(day1, TZ_JP)); + assertEquals(USNYSE.futureDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(JPOSE.futureDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_JP)); // leap day day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); day2 = "2016-02-29"; - assertEquals(USNYSE.nextDay(day1), day2); - assertEquals(JPOSE.nextDay(day1), day2); + assertEquals(USNYSE.futureDate(day1), day2); + assertEquals(JPOSE.futureDate(day1), day2); // new year day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); day2 = "2014-01-05"; - assertEquals(USNYSE.nextDay(day1, 5), day2); - assertEquals(JPOSE.nextDay(day1, 5), day2); - assertEquals(USNYSE.nextDay(day2, -5), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.nextDay(day2, -5), DateTimeUtils.formatDate(day1, TZ_JP)); + assertEquals(USNYSE.futureDate(day1, 5), day2); + assertEquals(JPOSE.futureDate(day1, 5), day2); + assertEquals(USNYSE.futureDate(day2, -5), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(JPOSE.futureDate(day2, -5), DateTimeUtils.formatDate(day1, TZ_JP)); // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); day2 = "2017-03-13"; - assertEquals(USNYSE.nextDay(day1), day2); - assertEquals(JPOSE.nextDay(day1), day2); + assertEquals(USNYSE.futureDate(day1), day2); + assertEquals(JPOSE.futureDate(day1), day2); // outside calendar range day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); day2 = "2070-01-01"; - assertEquals(USNYSE.nextDay(day1), day2); - assertEquals(JPOSE.nextDay(day1), day2); + assertEquals(USNYSE.futureDate(day1), day2); + assertEquals(JPOSE.futureDate(day1), day2); day1 = null; - assertNull(USNYSE.nextDay(day1)); - assertNull(JPOSE.nextDay(day1)); + assertNull(USNYSE.futureDate(day1)); + assertNull(JPOSE.futureDate(day1)); } public void testNextDayString() { String day1 = "2016-08-31"; String day2 = "2016-09-04"; - assertEquals(USNYSE.nextDay(day1, 4), day2); - assertEquals(JPOSE.nextDay(day1, 4), day2); - assertEquals(USNYSE.nextDay(day2, -4), day1); - assertEquals(JPOSE.nextDay(day2, -4), day1); + assertEquals(USNYSE.futureDate(day1, 4), day2); + assertEquals(JPOSE.futureDate(day1, 4), day2); + assertEquals(USNYSE.futureDate(day2, -4), day1); + assertEquals(JPOSE.futureDate(day2, -4), day1); - assertEquals(USNYSE.nextDay(day1, 0), day1); - assertEquals(JPOSE.nextDay(day1, 0), day1); + assertEquals(USNYSE.futureDate(day1, 0), day1); + assertEquals(JPOSE.futureDate(day1, 0), day1); // leap day day1 = "2016-02-28"; day2 = "2016-02-29"; - assertEquals(USNYSE.nextDay(day1), day2); - assertEquals(JPOSE.nextDay(day1), day2); + assertEquals(USNYSE.futureDate(day1), day2); + assertEquals(JPOSE.futureDate(day1), day2); // new year day1 = "2013-12-31"; day2 = "2014-01-01"; - assertEquals(USNYSE.nextDay(day1), day2); - assertEquals(JPOSE.nextDay(day1), day2); + assertEquals(USNYSE.futureDate(day1), day2); + assertEquals(JPOSE.futureDate(day1), day2); // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 day1 = "2017-03-12"; day2 = "2017-03-15"; - assertEquals(USNYSE.nextDay(day1, 3), day2); - assertEquals(JPOSE.nextDay(day1, 3), day2); - assertEquals(USNYSE.nextDay(day2, -3), day1); - assertEquals(JPOSE.nextDay(day2, -3), day1); + assertEquals(USNYSE.futureDate(day1, 3), day2); + assertEquals(JPOSE.futureDate(day1, 3), day2); + assertEquals(USNYSE.futureDate(day2, -3), day1); + assertEquals(JPOSE.futureDate(day2, -3), day1); day1 = null; - assertNull(USNYSE.nextDay(day1)); - assertNull(JPOSE.nextDay(day1)); + assertNull(USNYSE.futureDate(day1)); + assertNull(JPOSE.futureDate(day1)); day1 = "2014-03-10"; day2 = "2017-03-13"; - assertEquals(USNYSE.nextDay(day1, 1099), day2); + assertEquals(USNYSE.futureDate(day1, 1099), day2); // incorrectly formatted days try { - USNYSE.nextDay("2018-02-31"); + USNYSE.futureDate("2018-02-31"); fail(); } catch (IllegalArgumentException e) { // ok } try { - USNYSE.nextDay("20193-02-31"); + USNYSE.futureDate("20193-02-31"); fail(); } catch (IllegalArgumentException e) { // ok @@ -176,93 +176,93 @@ public void testNextDayString() { } public void testPreviousDay() { - assertEquals("2017-09-26", test.previousDay()); - assertEquals("2017-09-25", test.previousDay(2)); - assertEquals("2017-09-13", test.previousDay(14)); + assertEquals("2017-09-26", test.pastDate()); + assertEquals("2017-09-25", test.pastDate(2)); + assertEquals("2017-09-13", test.pastDate(14)); Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); - assertEquals(USNYSE.previousDay(day2), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.previousDay(day2), DateTimeUtils.formatDate(day1, TZ_JP)); + assertEquals(USNYSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(JPOSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); - assertEquals(USNYSE.previousDay(day1, 0), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.previousDay(day1, 0), DateTimeUtils.formatDate(day1, TZ_JP)); + assertEquals(USNYSE.pastDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(JPOSE.pastDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_JP)); // leap day day1 = DateTimeUtils.parseInstant("2016-02-29T01:00:00.000000000 NY"); day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 NY"); - assertEquals(USNYSE.previousDay(day2), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.previousDay(day2), DateTimeUtils.formatDate(day1, TZ_JP)); + assertEquals(USNYSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(JPOSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); // new year day1 = DateTimeUtils.parseInstant("2013-12-29T01:00:00.000000000 NY"); day2 = DateTimeUtils.parseInstant("2014-01-01T01:00:00.000000000 NY"); - assertEquals(USNYSE.previousDay(day2, 3), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.previousDay(day2, 3), DateTimeUtils.formatDate(day1, TZ_JP)); - assertEquals(USNYSE.previousDay(day1, -3), DateTimeUtils.formatDate(day2, TZ_NY)); - assertEquals(JPOSE.previousDay(day1, -3), DateTimeUtils.formatDate(day2, TZ_JP)); + assertEquals(USNYSE.pastDate(day2, 3), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(JPOSE.pastDate(day2, 3), DateTimeUtils.formatDate(day1, TZ_JP)); + assertEquals(USNYSE.pastDate(day1, -3), DateTimeUtils.formatDate(day2, TZ_NY)); + assertEquals(JPOSE.pastDate(day1, -3), DateTimeUtils.formatDate(day2, TZ_JP)); // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 day1 = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 NY"); - assertEquals(USNYSE.previousDay(day2, 2), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.previousDay(day2, 2), DateTimeUtils.formatDate(day1, TZ_JP)); - assertEquals(USNYSE.previousDay(day1, -2), DateTimeUtils.formatDate(day2, TZ_NY)); - assertEquals(JPOSE.previousDay(day1, -2), DateTimeUtils.formatDate(day2, TZ_JP)); + assertEquals(USNYSE.pastDate(day2, 2), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(JPOSE.pastDate(day2, 2), DateTimeUtils.formatDate(day1, TZ_JP)); + assertEquals(USNYSE.pastDate(day1, -2), DateTimeUtils.formatDate(day2, TZ_NY)); + assertEquals(JPOSE.pastDate(day1, -2), DateTimeUtils.formatDate(day2, TZ_JP)); day1 = null; - assertNull(USNYSE.previousDay(day1)); - assertNull(JPOSE.previousDay(day1)); + assertNull(USNYSE.pastDate(day1)); + assertNull(JPOSE.pastDate(day1)); } public void testPreviousDayString() { String day1 = "2016-08-30"; String day2 = "2016-09-01"; - assertEquals(USNYSE.previousDay(day2, 2), day1); - assertEquals(JPOSE.previousDay(day2, 2), day1); - assertEquals(USNYSE.previousDay(day1, -2), day2); - assertEquals(JPOSE.previousDay(day1, -2), day2); + assertEquals(USNYSE.pastDate(day2, 2), day1); + assertEquals(JPOSE.pastDate(day2, 2), day1); + assertEquals(USNYSE.pastDate(day1, -2), day2); + assertEquals(JPOSE.pastDate(day1, -2), day2); - assertEquals(USNYSE.previousDay(day1, 0), day1); - assertEquals(JPOSE.previousDay(day1, 0), day1); + assertEquals(USNYSE.pastDate(day1, 0), day1); + assertEquals(JPOSE.pastDate(day1, 0), day1); // leap day day1 = "2016-02-29"; day2 = "2016-03-01"; - assertEquals(USNYSE.previousDay(day2), day1); - assertEquals(JPOSE.previousDay(day2), day1); + assertEquals(USNYSE.pastDate(day2), day1); + assertEquals(JPOSE.pastDate(day2), day1); // new year day1 = "2013-12-31"; day2 = "2014-01-01"; - assertEquals(USNYSE.previousDay(day2), day1); - assertEquals(JPOSE.previousDay(day2), day1); + assertEquals(USNYSE.pastDate(day2), day1); + assertEquals(JPOSE.pastDate(day2), day1); // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 day1 = "2017-03-10"; day2 = "2017-03-13"; - assertEquals(USNYSE.previousDay(day2, 3), day1); - assertEquals(JPOSE.previousDay(day2, 3), day1); - assertEquals(USNYSE.previousDay(day1, -3), day2); - assertEquals(JPOSE.previousDay(day1, -3), day2); + assertEquals(USNYSE.pastDate(day2, 3), day1); + assertEquals(JPOSE.pastDate(day2, 3), day1); + assertEquals(USNYSE.pastDate(day1, -3), day2); + assertEquals(JPOSE.pastDate(day1, -3), day2); day1 = null; - assertNull(USNYSE.previousDay(day1)); - assertNull(JPOSE.previousDay(day1)); + assertNull(USNYSE.pastDate(day1)); + assertNull(JPOSE.pastDate(day1)); day1 = "2014-03-10"; day2 = "2017-03-13"; - assertEquals(USNYSE.previousDay(day2, 1099), day1); + assertEquals(USNYSE.pastDate(day2, 1099), day1); // incorrectly formatted days try { - USNYSE.previousDay("2018-02-31"); + USNYSE.pastDate("2018-02-31"); fail(); } catch (IllegalArgumentException e) { // ok } try { - USNYSE.previousDay("20193-02-31"); + USNYSE.pastDate("20193-02-31"); fail(); } catch (IllegalArgumentException e) { // ok @@ -1158,11 +1158,11 @@ public void testLastBusinessScheduleString() { day2 = "2017-03-13"; assertEquals( DateTimeUtils.formatDate( - USNYSE.previousBusinessSchedule(USNYSE.previousDay(USNYSE.previousDay(day2))).getSOBD(), TZ_NY), + USNYSE.previousBusinessSchedule(USNYSE.pastDate(USNYSE.pastDate(day2))).getSOBD(), TZ_NY), day1); assertEquals( DateTimeUtils.formatDate( - JPOSE.previousBusinessSchedule(JPOSE.previousDay(JPOSE.previousDay(day2))).getSOBD(), TZ_JP), + JPOSE.previousBusinessSchedule(JPOSE.pastDate(JPOSE.pastDate(day2))).getSOBD(), TZ_JP), day1); day1 = null; @@ -1623,7 +1623,7 @@ public void testCurrentBusinessSchedule() { public void testMidnightClose() { assertEquals(DateTimeUtils.DAY, UTC.standardBusinessDayLengthNanos()); - assertEquals("2019-04-16", UTC.nextDay("2019-04-15")); + assertEquals("2019-04-16", UTC.futureDate("2019-04-15")); assertEquals("2019-04-16", UTC.nextBusinessDay("2019-04-15")); assertEquals("2019-04-18", UTC.nextBusinessDay("2019-04-15", 3)); assertEquals("2019-08-19", From 475d8f8b0dd400d3e996cbd735409774b479da7b Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Wed, 28 Jun 2023 13:59:56 -0600 Subject: [PATCH 007/150] Calendar refactoring and cleanup. --- .../util/TestCalendarMethodsFromTable.java | 28 ++-- .../io/deephaven/time/calendar/Calendar.java | 53 +++--- .../calendar/StaticCalendarMethodsTest.java | 28 ++-- .../calendar/TestDefaultBusinessCalendar.java | 156 +++++++++--------- .../TestDefaultNoHolidayBusinessCalendar.java | 2 +- 5 files changed, 131 insertions(+), 136 deletions(-) diff --git a/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java b/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java index 85bdd7be1c9..720355e3fa7 100644 --- a/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java +++ b/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java @@ -85,19 +85,19 @@ public void testCalendarMethodsTable() { assertEquals(calendar.futureDate(date1, 14), getVal(emptyTable(1).update("nextDay = nextDay(date1, 14)"), "nextDay")); - assertEquals(calendar.daysInRange(time1, time2), + assertEquals(calendar.calendarDates(time1, time2), (String[]) getVal(emptyTable(1).update("daysInRange = daysInRange(time1, time2)"), "daysInRange")); - assertEquals(calendar.daysInRange(date1, date2), + assertEquals(calendar.calendarDates(date1, date2), (String[]) getVal(emptyTable(1).update("daysInRange = daysInRange(date1, date2)"), "daysInRange")); - assertEquals(calendar.numberOfDays(time1, time2), + assertEquals(calendar.numberCalendarDates(time1, time2), getVal(emptyTable(1).update("numberOfDays = numberOfDays(time1, time2)"), "numberOfDays")); - assertEquals(calendar.numberOfDays(time1, time2, true), + assertEquals(calendar.numberCalendarDates(time1, time2, true), getVal(emptyTable(1).update("numberOfDays = numberOfDays(time1, time2, true)"), "numberOfDays")); - assertEquals(calendar.numberOfDays(date1, date2), + assertEquals(calendar.numberCalendarDates(date1, date2), getVal(emptyTable(1).update("numberOfDays = numberOfDays(date1, date2)"), "numberOfDays")); - assertEquals(calendar.numberOfDays(date1, date2, true), + assertEquals(calendar.numberCalendarDates(date1, date2, true), getVal(emptyTable(1).update("numberOfDays = numberOfDays(date1, date2, true)"), "numberOfDays")); @@ -241,18 +241,18 @@ public void testBusinessCalendarMethodsTable() { emptyTable(1).update("nextNonBusinessDay = nextNonBusinessDay(date1, 16)"), "nextNonBusinessDay")); - assertEquals(calendar.businessDaysInRange(time1, time2), + assertEquals(calendar.businessDates(time1, time2), (String[]) getVal(emptyTable(1).update("businessDaysInRange = businessDaysInRange(time1, time2)"), "businessDaysInRange")); - assertEquals(calendar.businessDaysInRange(date1, date2), + assertEquals(calendar.businessDates(date1, date2), (String[]) getVal(emptyTable(1).update("businessDaysInRange = businessDaysInRange(date1, date2)"), "businessDaysInRange")); - assertEquals(calendar.nonBusinessDaysInRange(time1, time2), + assertEquals(calendar.nonBusinessDates(time1, time2), (String[]) getVal(emptyTable(1).update("nonBusinessDaysInRange = nonBusinessDaysInRange(time1, time2)"), "nonBusinessDaysInRange")); - assertEquals(calendar.nonBusinessDaysInRange(date1, date2), + assertEquals(calendar.nonBusinessDates(date1, date2), (String[]) getVal(emptyTable(1).update("nonBusinessDaysInRange = nonBusinessDaysInRange(date1, date2)"), "nonBusinessDaysInRange")); @@ -279,13 +279,13 @@ public void testBusinessCalendarMethodsTable() { assertEquals(calendar.numberOfBusinessDays(time1, time2), getVal(emptyTable(1).update("numberOfBusinessDays = numberOfBusinessDays(time1, time2)"), "numberOfBusinessDays")); - assertEquals(calendar.numberOfBusinessDays(time1, time2, true), + assertEquals(calendar.numberBusinessDates(time1, time2, true), getVal(emptyTable(1).update("numberOfBusinessDays = numberOfBusinessDays(time1, time2, true)"), "numberOfBusinessDays")); assertEquals(calendar.numberOfBusinessDays(date1, date2), getVal(emptyTable(1).update("numberOfBusinessDays = numberOfBusinessDays(date1, date2)"), "numberOfBusinessDays")); - assertEquals(calendar.numberOfBusinessDays(date1, date2, true), + assertEquals(calendar.numberBusinessDates(date1, date2, true), getVal(emptyTable(1).update("numberOfBusinessDays = numberOfBusinessDays(date1, date2, true)"), "numberOfBusinessDays")); @@ -293,13 +293,13 @@ public void testBusinessCalendarMethodsTable() { assertEquals(calendar.numberOfNonBusinessDays(time1, time2), getVal(emptyTable(1).update("numberOfNonBusinessDays = numberOfNonBusinessDays(time1, time2)"), "numberOfNonBusinessDays")); - assertEquals(calendar.numberOfNonBusinessDays(time1, time2, true), + assertEquals(calendar.numberNonBusinessDates(time1, time2, true), getVal(emptyTable(1).update("numberOfNonBusinessDays = numberOfNonBusinessDays(time1, time2, true)"), "numberOfNonBusinessDays")); assertEquals(calendar.numberOfNonBusinessDays(date1, date2), getVal(emptyTable(1).update("numberOfNonBusinessDays = numberOfNonBusinessDays(date1, date2)"), "numberOfNonBusinessDays")); - assertEquals(calendar.numberOfNonBusinessDays(date1, date2, true), + assertEquals(calendar.numberNonBusinessDates(date1, date2, true), getVal(emptyTable(1).update("numberOfNonBusinessDays = numberOfNonBusinessDays(date1, date2, true)"), "numberOfNonBusinessDays")); diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java index bc2abbe90ea..7e59b9c860d 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending + * Copyright (c) 2016-2023 Deephaven Data Labs and Patent Pending */ package io.deephaven.time.calendar; @@ -11,9 +11,7 @@ import java.util.ArrayList; import java.util.List; -//TODO: update all headers //TODO: review all docs -//TODO: review API /** * A calendar. @@ -233,8 +231,6 @@ public LocalDate pastDate(int days) { // region Ranges - ** - /** * Gets the days in a given range. * @@ -242,7 +238,7 @@ public LocalDate pastDate(int days) { * @param end end of a time range; if null, return empty array * @return the inclusive days between {@code start} and {@code end} */ - public LocalDate[] daysInRange(final LocalDate start, final LocalDate end) { + public LocalDate[] calendarDates(final LocalDate start, final LocalDate end) { if (start == null || end == null) { return new LocalDate[0]; } @@ -265,12 +261,12 @@ public LocalDate[] daysInRange(final LocalDate start, final LocalDate end) { * @param end end of a time range; if null, return empty array * @return the inclusive days between {@code start} and {@code end} */ - public LocalDate[] daysInRange(final ZonedDateTime start, final ZonedDateTime end) { + public LocalDate[] calendarDates(final ZonedDateTime start, final ZonedDateTime end) { if (start == null || end == null) { return new LocalDate[0]; } - return daysInRange(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate()); + return calendarDates(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate()); } /** @@ -280,12 +276,12 @@ public LocalDate[] daysInRange(final ZonedDateTime start, final ZonedDateTime en * @param end end of a time range; if null, return empty array * @return the inclusive days between {@code start} and {@code end} */ - public LocalDate[] daysInRange(final Instant start, final Instant end) { + public LocalDate[] calendarDates(final Instant start, final Instant end) { if (start == null || end == null) { return new LocalDate[0]; } - return daysInRange(DateTimeUtils.toZonedDateTime(start, timeZone()).toLocalDate(), DateTimeUtils.toZonedDateTime(end, timeZone()).toLocalDate()); + return calendarDates(DateTimeUtils.toZonedDateTime(start, timeZone()).toLocalDate(), DateTimeUtils.toZonedDateTime(end, timeZone()).toLocalDate()); } /** @@ -295,15 +291,14 @@ public LocalDate[] daysInRange(final Instant start, final Instant end) { * @param end end of a time range; if null, return empty array * @return the inclusive days between {@code start} and {@code end} */ - public LocalDate[] daysInRange(final String start, final String end) { + public LocalDate[] calendarDates(final String start, final String end) { if (start == null || end == null) { return new LocalDate[0]; } - return daysInRange(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end)); + return calendarDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end)); } - //TODO: add InRange to the names? /** * Gets the number of days in a given range. * @@ -312,7 +307,7 @@ public LocalDate[] daysInRange(final String start, final String end) { * @param endInclusive whether to treat the {@code end} inclusive or exclusively * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - public int numberOfDays(final LocalDate start, final LocalDate end, final boolean endInclusive) { + public int numberCalendarDates(final LocalDate start, final LocalDate end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } @@ -333,8 +328,8 @@ public int numberOfDays(final LocalDate start, final LocalDate end, final boolea * @param end end of a time range * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - public int numberOfDays(final LocalDate start, final LocalDate end) { - return numberOfDays(start, end, false); + public int numberCalendarDates(final LocalDate start, final LocalDate end) { + return numberCalendarDates(start, end, false); } /** @@ -345,12 +340,12 @@ public int numberOfDays(final LocalDate start, final LocalDate end) { * @param endInclusive whether to treat the {@code end} inclusive or exclusively * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - public int numberOfDays(final ZonedDateTime start, final ZonedDateTime end, final boolean endInclusive) { + public int numberCalendarDates(final ZonedDateTime start, final ZonedDateTime end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } - return numberOfDays(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate(), endInclusive); + return numberCalendarDates(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate(), endInclusive); } /** @@ -360,8 +355,8 @@ public int numberOfDays(final ZonedDateTime start, final ZonedDateTime end, fina * @param end end of a time range * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - public int numberOfDays(final ZonedDateTime start, final ZonedDateTime end) { - return numberOfDays(start, end, false); + public int numberCalendarDates(final ZonedDateTime start, final ZonedDateTime end) { + return numberCalendarDates(start, end, false); } /** @@ -372,12 +367,12 @@ public int numberOfDays(final ZonedDateTime start, final ZonedDateTime end) { * @param endInclusive whether to treat the {@code end} inclusive or exclusively * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - public int numberOfDays(final Instant start, final Instant end, final boolean endInclusive) { + public int numberCalendarDates(final Instant start, final Instant end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } - return numberOfDays(DateTimeUtils.toZonedDateTime(start, timeZone()).toLocalDate(), DateTimeUtils.toZonedDateTime(end, timeZone()).toLocalDate(), endInclusive); + return numberCalendarDates(DateTimeUtils.toZonedDateTime(start, timeZone()).toLocalDate(), DateTimeUtils.toZonedDateTime(end, timeZone()).toLocalDate(), endInclusive); } /** @@ -387,8 +382,8 @@ public int numberOfDays(final Instant start, final Instant end, final boolean en * @param end end of a time range * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - public int numberOfDays(final Instant start, final Instant end) { - return numberOfDays(start, end, false); + public int numberCalendarDates(final Instant start, final Instant end) { + return numberCalendarDates(start, end, false); } /** @@ -399,12 +394,12 @@ public int numberOfDays(final Instant start, final Instant end) { * @param endInclusive whether to treat the {@code end} inclusive or exclusively * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - public int numberOfDays(final String start, final String end, final boolean endInclusive) { + public int numberCalendarDates(final String start, final String end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } - return numberOfDays(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), endInclusive); + return numberCalendarDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), endInclusive); } /** @@ -414,11 +409,11 @@ public int numberOfDays(final String start, final String end, final boolean endI * @param end end of a time range * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. */ - public int numberOfDays(final String start, final String end) { - return numberOfDays(start, end, false); + public int numberCalendarDates(final String start, final String end) { + return numberCalendarDates(start, end, false); } - //TODO: + //TODO: time diff methods? // diffBusinessDay // diffBusinessDay // diffBusinessNanos diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java b/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java index afad4caeea7..09b55f707fc 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java @@ -39,13 +39,13 @@ public void testCalendarMethods() { assertEquals(calendar.futureDate(date2), StaticCalendarMethods.nextDay(date2)); assertEquals(calendar.futureDate(date2, 14), StaticCalendarMethods.nextDay(date2, 14)); - assertEquals(calendar.daysInRange(time1, time2), StaticCalendarMethods.daysInRange(time1, time2)); - assertEquals(calendar.daysInRange(date1, date2), StaticCalendarMethods.daysInRange(date1, date2)); + assertEquals(calendar.calendarDates(time1, time2), StaticCalendarMethods.daysInRange(time1, time2)); + assertEquals(calendar.calendarDates(date1, date2), StaticCalendarMethods.daysInRange(date1, date2)); - assertEquals(calendar.numberOfDays(time1, time2), StaticCalendarMethods.numberOfDays(time1, time2)); - assertEquals(calendar.numberOfDays(time1, time2, true), StaticCalendarMethods.numberOfDays(time1, time2, true)); - assertEquals(calendar.numberOfDays(date1, date2), StaticCalendarMethods.numberOfDays(date1, date2)); - assertEquals(calendar.numberOfDays(date1, date2, true), StaticCalendarMethods.numberOfDays(date1, date2, true)); + assertEquals(calendar.numberCalendarDates(time1, time2), StaticCalendarMethods.numberOfDays(time1, time2)); + assertEquals(calendar.numberCalendarDates(time1, time2, true), StaticCalendarMethods.numberOfDays(time1, time2, true)); + assertEquals(calendar.numberCalendarDates(date1, date2), StaticCalendarMethods.numberOfDays(date1, date2)); + assertEquals(calendar.numberCalendarDates(date1, date2, true), StaticCalendarMethods.numberOfDays(date1, date2, true)); assertEquals(calendar.dayOfWeek(), StaticCalendarMethods.dayOfWeek()); @@ -122,15 +122,15 @@ public void testBusinessCalendarMethods() { assertEquals(calendar.nextNonBusinessDay(date1, 16), StaticCalendarMethods.nextNonBusinessDay(date1, 16)); - assertEquals(calendar.businessDaysInRange(time1, time2), + assertEquals(calendar.businessDates(time1, time2), StaticCalendarMethods.businessDaysInRange(time1, time2)); - assertEquals(calendar.businessDaysInRange(date1, date2), + assertEquals(calendar.businessDates(date1, date2), StaticCalendarMethods.businessDaysInRange(date1, date2)); - assertEquals(calendar.nonBusinessDaysInRange(time1, time2), + assertEquals(calendar.nonBusinessDates(time1, time2), StaticCalendarMethods.nonBusinessDaysInRange(time1, time2)); - assertEquals(calendar.nonBusinessDaysInRange(date1, date2), + assertEquals(calendar.nonBusinessDates(date1, date2), StaticCalendarMethods.nonBusinessDaysInRange(date1, date2)); @@ -147,21 +147,21 @@ public void testBusinessCalendarMethods() { assertEquals(calendar.numberOfBusinessDays(time1, time2), StaticCalendarMethods.numberOfBusinessDays(time1, time2)); - assertEquals(calendar.numberOfBusinessDays(time1, time2, true), + assertEquals(calendar.numberBusinessDates(time1, time2, true), StaticCalendarMethods.numberOfBusinessDays(time1, time2, true)); assertEquals(calendar.numberOfBusinessDays(date1, date2), StaticCalendarMethods.numberOfBusinessDays(date1, date2)); - assertEquals(calendar.numberOfBusinessDays(date1, date2, true), + assertEquals(calendar.numberBusinessDates(date1, date2, true), StaticCalendarMethods.numberOfBusinessDays(date1, date2, true)); assertEquals(calendar.numberOfNonBusinessDays(time1, time2), StaticCalendarMethods.numberOfNonBusinessDays(time1, time2)); - assertEquals(calendar.numberOfNonBusinessDays(time1, time2, true), + assertEquals(calendar.numberNonBusinessDates(time1, time2, true), StaticCalendarMethods.numberOfNonBusinessDays(time1, time2, true)); assertEquals(calendar.numberOfNonBusinessDays(date1, date2), StaticCalendarMethods.numberOfNonBusinessDays(date1, date2)); - assertEquals(calendar.numberOfNonBusinessDays(date1, date2, true), + assertEquals(calendar.numberNonBusinessDates(date1, date2, true), StaticCalendarMethods.numberOfNonBusinessDays(date1, date2, true)); diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java index 13f200343f6..32b738159a8 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java @@ -281,7 +281,7 @@ public void testDateRange() { "2017-03-14" }; - String[] results = USNYSE.daysInRange(startDate, endDate); + String[] results = USNYSE.calendarDates(startDate, endDate); Arrays.sort(goodResults); Arrays.sort(results); boolean answer = Arrays.equals(goodResults, results); @@ -290,7 +290,7 @@ public void testDateRange() { startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 JP"); endDate = DateTimeUtils.parseInstant("2017-03-14T01:00:00.000000000 JP"); - results = JPOSE.daysInRange(startDate, endDate); + results = JPOSE.calendarDates(startDate, endDate); Arrays.sort(goodResults); Arrays.sort(results); answer = Arrays.equals(goodResults, results); @@ -298,8 +298,8 @@ public void testDateRange() { startDate = null; - assertEquals(USNYSE.daysInRange(startDate, endDate).length, 0); - assertEquals(JPOSE.daysInRange(startDate, endDate).length, 0); + assertEquals(USNYSE.calendarDates(startDate, endDate).length, 0); + assertEquals(JPOSE.calendarDates(startDate, endDate).length, 0); } public void testDateStringRange() { @@ -311,13 +311,13 @@ public void testDateStringRange() { "2014-03-01", "2014-03-02", "2014-03-03", "2014-03-04", "2014-03-05" }; - String[] results = USNYSE.daysInRange(startDate, endDate); + String[] results = USNYSE.calendarDates(startDate, endDate); Arrays.sort(goodResults); Arrays.sort(results); boolean answer = Arrays.equals(goodResults, results); assertTrue(answer); - results = JPOSE.daysInRange(startDate, endDate); + results = JPOSE.calendarDates(startDate, endDate); Arrays.sort(goodResults); Arrays.sort(results); answer = Arrays.equals(goodResults, results); @@ -326,114 +326,114 @@ public void testDateStringRange() { startDate = "2020-01-01"; endDate = "2020-01-20"; - results = USNYSE.daysInRange(startDate, endDate); + results = USNYSE.calendarDates(startDate, endDate); assertEquals(results.length, 20); - results = JPOSE.daysInRange(startDate, endDate); + results = JPOSE.calendarDates(startDate, endDate); assertEquals(results.length, 20); startDate = null; - assertEquals(USNYSE.daysInRange(startDate, endDate).length, 0); - assertEquals(JPOSE.daysInRange(startDate, endDate).length, 0); + assertEquals(USNYSE.calendarDates(startDate, endDate).length, 0); + assertEquals(JPOSE.calendarDates(startDate, endDate).length, 0); // incorrectly formatted days - assertEquals(new String[0], USNYSE.daysInRange("2018-02-31", "2019-02-31")); + assertEquals(new String[0], USNYSE.calendarDates("2018-02-31", "2019-02-31")); } public void testNumberOfDays() { Instant startDate = DateTimeUtils.parseInstant("2014-02-18T01:00:00.000000000 NY"); Instant endDate = DateTimeUtils.parseInstant("2014-03-05T01:00:00.000000000 NY"); - assertEquals(USNYSE.numberOfDays(startDate, endDate), 15); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 15); assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 11); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate, false), 11); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate, true), 12); + assertEquals(USNYSE.numberBusinessDates(startDate, endDate, false), 11); + assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 12); assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 4); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate, false), 4); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate, true), 4); + assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, false), 4); + assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 4); startDate = DateTimeUtils.parseInstant("2020-01-01T01:00:00.000000000 NY"); endDate = DateTimeUtils.parseInstant("2020-01-20T01:00:00.000000000 NY"); - assertEquals(USNYSE.numberOfDays(startDate, endDate), 19); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 19); assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 12); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate, true), 12); + assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 12); assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 7); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate, true), 8); + assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 8); startDate = endDate; - assertEquals(USNYSE.numberOfDays(startDate, endDate), 0); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 0); assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 0); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate, true), 0); + assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 0); assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 0); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate, true), 1); + assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 1); startDate = DateTimeUtils.parseInstant("2020-01-02T01:00:00.000000000 NY"); endDate = startDate; - assertEquals(USNYSE.numberOfDays(startDate, endDate), 0); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 0); assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 0); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate, true), 1); + assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 1); assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 0); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate, true), 0); + assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 0); startDate = null; - assertEquals(USNYSE.numberOfDays(startDate, endDate), QueryConstants.NULL_INT); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate, true), QueryConstants.NULL_INT); + assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate, true), QueryConstants.NULL_INT); + assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); startDate = DateTimeUtils.parseInstant("2014-02-18T01:00:00.000000000 NY"); endDate = null; - assertEquals(USNYSE.numberOfDays(startDate, endDate), QueryConstants.NULL_INT); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate, true), QueryConstants.NULL_INT); + assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate, true), QueryConstants.NULL_INT); + assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); startDate = DateTimeUtils.parseInstant("2014-02-18T01:00:00.000000000 NY"); endDate = DateTimeUtils.parseInstant("2017-02-18T01:00:00.000000000 NY"); - assertEquals(USNYSE.numberOfDays(startDate, endDate), 1096); - assertEquals(USNYSE.numberOfDays(startDate, endDate, true), 1097); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 1096); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate, true), 1097); assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 758); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate, true), 758); + assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 758); assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 338); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate, true), 339); + assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 339); } public void testNumberOfDaysString() { String startDate = "2014-02-18"; String endDate = "2014-03-05"; - assertEquals(USNYSE.numberOfDays(startDate, endDate), 15); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 15); assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 11); assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 4); - assertEquals(USNYSE.numberOfDays(startDate, endDate, false), 15); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate, false), 11); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate, false), 4); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate, false), 15); + assertEquals(USNYSE.numberBusinessDates(startDate, endDate, false), 11); + assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, false), 4); - assertEquals(USNYSE.numberOfDays(startDate, endDate, true), 16); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate, true), 12); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate, true), 4); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate, true), 16); + assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 12); + assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 4); - assertEquals(USNYSE.numberOfDays(endDate, startDate), -15); + assertEquals(USNYSE.numberCalendarDates(endDate, startDate), -15); assertEquals(USNYSE.numberOfBusinessDays(endDate, startDate), -11); assertEquals(USNYSE.numberOfNonBusinessDays(endDate, startDate), -4); - assertEquals(USNYSE.numberOfDays(endDate, startDate, false), -15); - assertEquals(USNYSE.numberOfBusinessDays(endDate, startDate, false), -11); - assertEquals(USNYSE.numberOfNonBusinessDays(endDate, startDate, false), -4); + assertEquals(USNYSE.numberCalendarDates(endDate, startDate, false), -15); + assertEquals(USNYSE.numberBusinessDates(endDate, startDate, false), -11); + assertEquals(USNYSE.numberNonBusinessDates(endDate, startDate, false), -4); - assertEquals(USNYSE.numberOfDays(endDate, startDate, true), -16); - assertEquals(USNYSE.numberOfBusinessDays(endDate, startDate, true), -12); - assertEquals(USNYSE.numberOfNonBusinessDays(endDate, startDate, true), -4); + assertEquals(USNYSE.numberCalendarDates(endDate, startDate, true), -16); + assertEquals(USNYSE.numberBusinessDates(endDate, startDate, true), -12); + assertEquals(USNYSE.numberNonBusinessDates(endDate, startDate, true), -4); endDate = startDate; - assertEquals(USNYSE.numberOfDays(startDate, endDate), 0); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 0); assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 0); assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 0); @@ -441,18 +441,18 @@ public void testNumberOfDaysString() { startDate = "2020-01-01"; endDate = "2020-01-20"; - assertEquals(USNYSE.numberOfDays(startDate, endDate), 19); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 19); assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 12); assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 7); startDate = null; - assertEquals(USNYSE.numberOfDays(startDate, endDate), QueryConstants.NULL_INT); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); startDate = "2014-02-18"; endDate = null; - assertEquals(USNYSE.numberOfDays(startDate, endDate), QueryConstants.NULL_INT); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); @@ -460,17 +460,17 @@ public void testNumberOfDaysString() { startDate = "2014-02-18"; endDate = "2017-02-18"; - assertEquals(USNYSE.numberOfDays(startDate, endDate), 1096); - assertEquals(USNYSE.numberOfDays(startDate, endDate, true), 1097); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 1096); + assertEquals(USNYSE.numberCalendarDates(startDate, endDate, true), 1097); assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 758); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate, true), 758); + assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 758); assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 338); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate, true), 339); + assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 339); // incorrectly formatted days try { - USNYSE.numberOfDays("2018-02-31", "2019-02-31"); + USNYSE.numberCalendarDates("2018-02-31", "2019-02-31"); fail(); } catch (IllegalArgumentException e) { // ok @@ -1360,13 +1360,13 @@ public void testBusinessDateRange() { "2017-03-14" }; - String[] results = USNYSE.businessDaysInRange(startDate, endDate); + String[] results = USNYSE.businessDates(startDate, endDate); Arrays.sort(goodResults); Arrays.sort(results); boolean answer = Arrays.equals(goodResults, results); assertTrue(answer); - assertEquals(new String[0], USNYSE.businessDaysInRange(endDate, startDate)); + assertEquals(new String[0], USNYSE.businessDates(endDate, startDate)); startDate = DateTimeUtils.parseInstant("2017-11-23T01:00:00.000000000 JP"); endDate = DateTimeUtils.parseInstant("2017-11-25T01:00:00.000000000 JP"); @@ -1375,14 +1375,14 @@ public void testBusinessDateRange() { "2017-11-24" }; - results = JPOSE.businessDaysInRange(startDate, endDate); + results = JPOSE.businessDates(startDate, endDate); Arrays.sort(goodResults); Arrays.sort(results); answer = Arrays.equals(goodResults, results); assertTrue(answer); startDate = null; - assertEquals(JPOSE.businessDaysInRange(startDate, endDate).length, 0); + assertEquals(JPOSE.businessDates(startDate, endDate).length, 0); // non business startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); @@ -1393,7 +1393,7 @@ public void testBusinessDateRange() { "2017-03-12" }; - results = USNYSE.nonBusinessDaysInRange(startDate, endDate); + results = USNYSE.nonBusinessDates(startDate, endDate); Arrays.sort(goodResults); Arrays.sort(results); answer = Arrays.equals(goodResults, results); @@ -1408,18 +1408,18 @@ public void testBusinessDateRange() { "2017-11-25" }; - assertEquals(new String[0], USNYSE.nonBusinessDaysInRange(endDate, startDate)); - results = JPOSE.nonBusinessDaysInRange(startDate, endDate); + assertEquals(new String[0], USNYSE.nonBusinessDates(endDate, startDate)); + results = JPOSE.nonBusinessDates(startDate, endDate); Arrays.sort(goodResults); Arrays.sort(results); answer = Arrays.equals(goodResults, results); assertTrue(answer); startDate = null; - assertEquals(JPOSE.nonBusinessDaysInRange(startDate, endDate).length, 0); + assertEquals(JPOSE.nonBusinessDates(startDate, endDate).length, 0); startDate = null; - assertEquals(USNYSE.nonBusinessDaysInRange(startDate, endDate).length, 0); + assertEquals(USNYSE.nonBusinessDates(startDate, endDate).length, 0); } public void testBusinessDateStringRange() { @@ -1432,18 +1432,18 @@ public void testBusinessDateStringRange() { "2014-03-03", "2014-03-04", "2014-03-05", }; - assertEquals(new String[0], USNYSE.businessDaysInRange(endDate, startDate)); - String[] results = USNYSE.businessDaysInRange(startDate, endDate); + assertEquals(new String[0], USNYSE.businessDates(endDate, startDate)); + String[] results = USNYSE.businessDates(startDate, endDate); Arrays.sort(goodResults); Arrays.sort(results); boolean answer = Arrays.equals(goodResults, results); assertTrue(answer); startDate = null; - assertEquals(USNYSE.businessDaysInRange(startDate, endDate).length, 0); + assertEquals(USNYSE.businessDates(startDate, endDate).length, 0); startDate = endDate; - assertEquals(USNYSE.businessDaysInRange(startDate, endDate).length, 1); + assertEquals(USNYSE.businessDates(startDate, endDate).length, 1); // JPOSE startDate = "2018-01-01"; @@ -1453,7 +1453,7 @@ public void testBusinessDateStringRange() { "2018-01-05" }; - results = JPOSE.businessDaysInRange(startDate, endDate); + results = JPOSE.businessDates(startDate, endDate); Arrays.sort(goodResults); Arrays.sort(results); answer = Arrays.equals(goodResults, results); @@ -1468,8 +1468,8 @@ public void testBusinessDateStringRange() { "2020-01-18", "2020-01-19", "2020-01-20" }; - assertEquals(new String[0], USNYSE.nonBusinessDaysInRange(endDate, startDate)); - results = USNYSE.nonBusinessDaysInRange(startDate, endDate); + assertEquals(new String[0], USNYSE.nonBusinessDates(endDate, startDate)); + results = USNYSE.nonBusinessDates(startDate, endDate); Arrays.sort(goodResults); Arrays.sort(results); answer = Arrays.equals(goodResults, results); @@ -1485,7 +1485,7 @@ public void testBusinessDateStringRange() { "2018-01-03" }; - results = JPOSE.nonBusinessDaysInRange(startDate, endDate); + results = JPOSE.nonBusinessDates(startDate, endDate); Arrays.sort(goodResults); Arrays.sort(results); answer = Arrays.equals(goodResults, results); @@ -1494,14 +1494,14 @@ public void testBusinessDateStringRange() { // null tests startDate = null; - assertEquals(USNYSE.nonBusinessDaysInRange(startDate, endDate).length, 0); + assertEquals(USNYSE.nonBusinessDates(startDate, endDate).length, 0); startDate = endDate = "2018-01-06"; - assertEquals(USNYSE.nonBusinessDaysInRange(startDate, endDate).length, 1); + assertEquals(USNYSE.nonBusinessDates(startDate, endDate).length, 1); // incorrectly formatted days try { - USNYSE.nonBusinessDaysInRange("2018-09-31", "2018-010-31"); + USNYSE.nonBusinessDates("2018-09-31", "2018-010-31"); fail(); } catch (IllegalArgumentException e) { // ok diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java index 46d7b7f2991..5f49b464c0a 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java @@ -158,7 +158,7 @@ public void testNonBusinessDayMethods() { // ok } - assertEquals(noNonBusinessDays.nonBusinessDaysInRange("2010-01-01", "2019-01-01"), new String[0]); + assertEquals(noNonBusinessDays.nonBusinessDates("2010-01-01", "2019-01-01"), new String[0]); assertEquals( noNonBusinessDays.diffNonBusinessNanos( DateTimeUtils.parseInstant("2010-01-01T01:00:00.000000000 NY"), From fabbe4abb9e22b80238f01ee38f4471cfde40610 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Fri, 30 Jun 2023 18:13:26 -0700 Subject: [PATCH 008/150] BusinessCalendar refactoring and cleanup. --- .../AxisTransformBusinessCalendar.java | 10 +- .../util/TestCalendarMethodsFromTable.java | 60 +-- .../time/calendar/BusinessCalendar.java | 225 ++++++----- .../calendar/DefaultBusinessCalendar.java | 11 +- .../DefaultNoHolidayBusinessCalendar.java | 10 +- .../time/calendar/StaticCalendarMethods.java | 114 +++--- .../calendar/StaticCalendarMethodsTest.java | 60 +-- .../calendar/TestDefaultBusinessCalendar.java | 352 +++++++++--------- .../TestDefaultNoHolidayBusinessCalendar.java | 20 +- .../figure/FigureWidgetTranslator.java | 2 +- 10 files changed, 425 insertions(+), 439 deletions(-) diff --git a/Plot/src/main/java/io/deephaven/plot/axistransformations/AxisTransformBusinessCalendar.java b/Plot/src/main/java/io/deephaven/plot/axistransformations/AxisTransformBusinessCalendar.java index 5a635f78f0f..9f77faeb2e9 100644 --- a/Plot/src/main/java/io/deephaven/plot/axistransformations/AxisTransformBusinessCalendar.java +++ b/Plot/src/main/java/io/deephaven/plot/axistransformations/AxisTransformBusinessCalendar.java @@ -65,14 +65,14 @@ private Nugget getNuggetByTime(final double timeNanos) { if (nMin == null) { final Instant t = DateTimeUtils.epochNanosToInstant((long) timeNanos); - nMin = new Nugget(busCal.getBusinessSchedule(busCal.previousBusinessDay(t)), 0); + nMin = new Nugget(busCal.businessSchedule(busCal.pastBusinessDate(t)), 0); nMax = nMin; nuggets.add(nMin); } while (timeNanos < DateTimeUtils.epochNanos(nMin.businessDay.getSOBD())) { final BusinessSchedule d = - busCal.getBusinessSchedule(busCal.previousBusinessDay(nMin.businessDay.getSOBD())); + busCal.businessSchedule(busCal.pastBusinessDate(nMin.businessDay.getSOBD())); final Nugget n = new Nugget(d, nMin.cumulativeBusinessTimeNanosAtStartOfDay - d.getLOBD()); nuggets.add(0, n); @@ -81,7 +81,7 @@ private Nugget getNuggetByTime(final double timeNanos) { // noinspection ConstantConditions nMax can't cause NPE (for now! Don't add nulls to nuggets!) while (timeNanos > DateTimeUtils.epochNanos(nMax.businessDay.getEOBD())) { - final BusinessSchedule d = busCal.getBusinessSchedule(busCal.nextBusinessDay(nMax.businessDay.getEOBD())); + final BusinessSchedule d = busCal.businessSchedule(busCal.futureBusinessDate(nMax.businessDay.getEOBD())); final Nugget n = new Nugget(d, nMax.cumulativeBusinessTimeNanosAtStartOfDay + nMax.businessDay.getLOBD()); nuggets.add(n); @@ -105,7 +105,7 @@ private Nugget getNuggetByValue(final double value) { while (value < nMin.cumulativeBusinessTimeNanosAtStartOfDay) { final BusinessSchedule d = - busCal.getBusinessSchedule(busCal.previousBusinessDay(nMin.businessDay.getSOBD())); + busCal.businessSchedule(busCal.pastBusinessDate(nMin.businessDay.getSOBD())); final Nugget n = new Nugget(d, nMin.cumulativeBusinessTimeNanosAtStartOfDay - d.getLOBD()); nuggets.add(0, n); @@ -117,7 +117,7 @@ private Nugget getNuggetByValue(final double value) { } while (value > nMax.cumulativeBusinessTimeNanosAtStartOfDay + nMax.businessDay.getLOBD()) { - final BusinessSchedule d = busCal.getBusinessSchedule(busCal.nextBusinessDay(nMax.businessDay.getEOBD())); + final BusinessSchedule d = busCal.businessSchedule(busCal.futureBusinessDate(nMax.businessDay.getEOBD())); final Nugget n = new Nugget(d, nMax.cumulativeBusinessTimeNanosAtStartOfDay + nMax.businessDay.getLOBD()); nuggets.add(n); diff --git a/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java b/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java index 720355e3fa7..6082dc9de6d 100644 --- a/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java +++ b/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java @@ -146,17 +146,17 @@ public void testBusinessCalendarMethodsTable() { getVal(emptyTable(1).update("isBusinessTime = isBusinessTime(time2)"), "isBusinessTime")); - assertEquals(calendar.previousBusinessDay(), + assertEquals(calendar.pastBusinessDate(), getVal(emptyTable(1).update("previousBusinessDay = previousBusinessDay()"), "previousBusinessDay")); - assertEquals(calendar.previousBusinessDay(12), + assertEquals(calendar.pastBusinessDate(12), getVal(emptyTable(1).update("previousBusinessDay = previousBusinessDay(12)"), "previousBusinessDay")); - assertEquals(calendar.previousBusinessDay(time1), getVal( + assertEquals(calendar.pastBusinessDate(time1), getVal( emptyTable(1).update("previousBusinessDay = previousBusinessDay(time1)"), "previousBusinessDay")); - assertEquals(calendar.previousBusinessDay(time1, 6), getVal( + assertEquals(calendar.pastBusinessDate(time1, 6), getVal( emptyTable(1).update("previousBusinessDay = previousBusinessDay(time1, 6)"), "previousBusinessDay")); - assertEquals(calendar.previousBusinessDay(date1), getVal( + assertEquals(calendar.pastBusinessDate(date1), getVal( emptyTable(1).update("previousBusinessDay = previousBusinessDay(date1)"), "previousBusinessDay")); - assertEquals(calendar.previousBusinessDay(date1, 16), getVal( + assertEquals(calendar.pastBusinessDate(date1, 16), getVal( emptyTable(1).update("previousBusinessDay = previousBusinessDay(date1, 16)"), "previousBusinessDay")); @@ -180,35 +180,35 @@ public void testBusinessCalendarMethodsTable() { "previousBusinessSchedule")); - assertEquals(calendar.previousNonBusinessDay(), getVal( + assertEquals(calendar.pastNonBusinessDate(), getVal( emptyTable(1).update("previousNonBusinessDay = previousNonBusinessDay()"), "previousNonBusinessDay")); - assertEquals(calendar.previousNonBusinessDay(12), getVal( + assertEquals(calendar.pastNonBusinessDate(12), getVal( emptyTable(1).update("previousNonBusinessDay = previousNonBusinessDay(12)"), "previousNonBusinessDay")); - assertEquals(calendar.previousNonBusinessDay(time1), + assertEquals(calendar.pastNonBusinessDate(time1), getVal(emptyTable(1).update("previousNonBusinessDay = previousNonBusinessDay(time1)"), "previousNonBusinessDay")); - assertEquals(calendar.previousNonBusinessDay(time1, 6), + assertEquals(calendar.pastNonBusinessDate(time1, 6), getVal(emptyTable(1).update("previousNonBusinessDay = previousNonBusinessDay(time1, 6)"), "previousNonBusinessDay")); - assertEquals(calendar.previousNonBusinessDay(date1), + assertEquals(calendar.pastNonBusinessDate(date1), getVal(emptyTable(1).update("previousNonBusinessDay = previousNonBusinessDay(date1)"), "previousNonBusinessDay")); - assertEquals(calendar.previousNonBusinessDay(date1, 16), + assertEquals(calendar.pastNonBusinessDate(date1, 16), getVal(emptyTable(1).update("previousNonBusinessDay = previousNonBusinessDay(date1, 16)"), "previousNonBusinessDay")); - assertEquals(calendar.nextBusinessDay(), + assertEquals(calendar.futureBusinessDate(), getVal(emptyTable(1).update("nextBusinessDay = nextBusinessDay()"), "nextBusinessDay")); - assertEquals(calendar.nextBusinessDay(12), + assertEquals(calendar.futureBusinessDate(12), getVal(emptyTable(1).update("nextBusinessDay = nextBusinessDay(12)"), "nextBusinessDay")); - assertEquals(calendar.nextBusinessDay(time1), + assertEquals(calendar.futureBusinessDate(time1), getVal(emptyTable(1).update("nextBusinessDay = nextBusinessDay(time1)"), "nextBusinessDay")); - assertEquals(calendar.nextBusinessDay(time1, 6), + assertEquals(calendar.futureBusinessDate(time1, 6), getVal(emptyTable(1).update("nextBusinessDay = nextBusinessDay(time1, 6)"), "nextBusinessDay")); - assertEquals(calendar.nextBusinessDay(date1), + assertEquals(calendar.futureBusinessDate(date1), getVal(emptyTable(1).update("nextBusinessDay = nextBusinessDay(date1)"), "nextBusinessDay")); - assertEquals(calendar.nextBusinessDay(date1, 16), + assertEquals(calendar.futureBusinessDate(date1, 16), getVal(emptyTable(1).update("nextBusinessDay = nextBusinessDay(date1, 16)"), "nextBusinessDay")); @@ -227,17 +227,17 @@ public void testBusinessCalendarMethodsTable() { "nextBusinessSchedule")); - assertEquals(calendar.nextNonBusinessDay(), + assertEquals(calendar.futureNonBusinessDate(), getVal(emptyTable(1).update("nextNonBusinessDay = nextNonBusinessDay()"), "nextNonBusinessDay")); - assertEquals(calendar.nextNonBusinessDay(12), + assertEquals(calendar.futureNonBusinessDate(12), getVal(emptyTable(1).update("nextNonBusinessDay = nextNonBusinessDay(12)"), "nextNonBusinessDay")); - assertEquals(calendar.nextNonBusinessDay(time1), + assertEquals(calendar.futureNonBusinessDate(time1), getVal(emptyTable(1).update("nextNonBusinessDay = nextNonBusinessDay(time1)"), "nextNonBusinessDay")); - assertEquals(calendar.nextNonBusinessDay(time1, 6), getVal( + assertEquals(calendar.futureNonBusinessDate(time1, 6), getVal( emptyTable(1).update("nextNonBusinessDay = nextNonBusinessDay(time1, 6)"), "nextNonBusinessDay")); - assertEquals(calendar.nextNonBusinessDay(date1), + assertEquals(calendar.futureNonBusinessDate(date1), getVal(emptyTable(1).update("nextNonBusinessDay = nextNonBusinessDay(date1)"), "nextNonBusinessDay")); - assertEquals(calendar.nextNonBusinessDay(date1, 16), getVal( + assertEquals(calendar.futureNonBusinessDate(date1, 16), getVal( emptyTable(1).update("nextNonBusinessDay = nextNonBusinessDay(date1, 16)"), "nextNonBusinessDay")); @@ -267,11 +267,11 @@ public void testBusinessCalendarMethodsTable() { assertEquals(calendar.diffNonBusinessNanos(time1, time2), getVal(emptyTable(1).update("diffNonBusinessNanos = diffNonBusinessNanos(time1, time2)"), "diffNonBusinessNanos")); - assertEquals(calendar.diffBusinessDay(time1, time2), + assertEquals(calendar.diffBusinessDays(time1, time2), getVal(emptyTable(1).update("diffBusinessDay = diffBusinessDay(time1, time2)"), "diffBusinessDay")); - assertEquals(calendar.diffNonBusinessDay(time1, time2), getVal( + assertEquals(calendar.diffNonBusinessDays(time1, time2), getVal( emptyTable(1).update("diffNonBusinessDay = diffNonBusinessDay(time1, time2)"), "diffNonBusinessDay")); - assertEquals(calendar.diffBusinessYear(time1, time2), + assertEquals(calendar.diffBusinessYears(time1, time2), getVal(emptyTable(1).update("diffBusinessYear = diffBusinessYear(time1, time2)"), "diffBusinessYear")); @@ -345,11 +345,11 @@ public void testBusinessCalendarMethodsTable() { "isLastBusinessDayOfWeek")); - assertEquals(calendar.getBusinessSchedule(time1), getVal( + assertEquals(calendar.businessSchedule(time1), getVal( emptyTable(1).update("getBusinessSchedule = getBusinessSchedule(time1)"), "getBusinessSchedule")); - assertEquals(calendar.getBusinessSchedule(date1), getVal( + assertEquals(calendar.businessSchedule(date1), getVal( emptyTable(1).update("getBusinessSchedule = getBusinessSchedule(date1)"), "getBusinessSchedule")); - assertEquals(calendar.getBusinessSchedule(localDate), getVal( + assertEquals(calendar.businessSchedule(localDate), getVal( emptyTable(1).update("getBusinessSchedule = getBusinessSchedule(localDate)"), "getBusinessSchedule")); } diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index e2597b562db..fc906d499fa 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -3,7 +3,6 @@ */ package io.deephaven.time.calendar; -import io.deephaven.base.verify.Require; import io.deephaven.time.DateTimeUtils; import io.deephaven.util.QueryConstants; @@ -16,8 +15,10 @@ import java.util.List; import java.util.Map; +//TODO: update all headers //TODO: review all docs + /** * A business calendar. Calendar is extended with the concept of business and non-business time. * @@ -30,81 +31,76 @@ public interface BusinessCalendar extends Calendar { // region Business Schedule - //TODO: rename /** * Gets business schedules for dates that are different from the defaults. This returns all dates that are defined * as a holiday for the calendar. * * @return a map of dates and to their business periods */ - default Map getHolidays() { + default Map holidays() { return Collections.unmodifiableMap(holidays); } - //TODO: rename schedule or businessSchedule /** * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. * * @param date date * @return the corresponding BusinessSchedule of {@code date} */ - default BusinessSchedule getBusinessSchedule(final LocalDate date) { + default BusinessSchedule businessSchedule(final LocalDate date) { return dates.computeIfAbsent(date, this::newBusinessDay); } - //TODO: rename schedule /** * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. * * @param time time * @return the corresponding BusinessSchedule of {@code time}; null if time is null */ - default BusinessSchedule getBusinessSchedule(final ZonedDateTime time) { + default BusinessSchedule businessSchedule(final ZonedDateTime time) { if (time == null) { return null; } - return getBusinessSchedule(time.withZoneSameInstant(timeZone())); + return businessSchedule(time.withZoneSameInstant(timeZone())); } - //TODO: rename schedule /** * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. * * @param time time * @return the corresponding BusinessSchedule of {@code time}; null if time is null */ - default BusinessSchedule getBusinessSchedule(final Instant time) { + default BusinessSchedule businessSchedule(final Instant time) { if (time == null) { return null; } - return getBusinessSchedule(time.atZone(timeZone())); + return businessSchedule(time.atZone(timeZone())); } - //TODO: rename schedule /** * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. * * @param date date * @return the corresponding BusinessSchedule of {@code date} */ - default BusinessSchedule getBusinessSchedule(String date) { + default BusinessSchedule businessSchedule(String date) { if (date == null) { return null; } - return getBusinessSchedule(DateTimeUtils.parseLocalDate(date)); + return businessSchedule(DateTimeUtils.parseLocalDate(date)); } - //TODO: rename current schedule? + //TODO: rename current schedule? --> or zero arg? /** * Gets today's business schedule. * * @return today's business schedule */ default BusinessSchedule currentBusinessSchedule() { - return getBusinessSchedule(currentDay()); + return businessSchedule(currentDate()); } // endregion @@ -118,7 +114,7 @@ default BusinessSchedule currentBusinessSchedule() { * @return true if the date is a business day; false otherwise. */ default boolean isBusinessDay(final LocalDate date) { - return date != null && getBusinessSchedule(date).isBusinessDay(); + return date != null && businessSchedule(date).isBusinessDay(); } /** @@ -157,7 +153,6 @@ default boolean isBusinessDay(final Instant time){ return fractionOfStandardBusinessDay(time) > 0.0; } - //TODO: rename? /** * Is the day of the week a business day? A business day is a day that has a business schedule with one or more * business periods defined. @@ -176,7 +171,7 @@ default boolean isBusinessDay(DayOfWeek day){ * @return true if the current day is a business day; false otherwise. */ default boolean isBusinessDay() { - return isBusinessDay(currentDay()); + return isBusinessDay(currentDate()); } /** @@ -191,7 +186,7 @@ boolean isLastBusinessDayOfMonth(final LocalDate date) { return false; } - final LocalDate nextBusAfterDate = nextBusinessDay(date); + final LocalDate nextBusAfterDate = futureBusinessDate(date); if(nextBusAfterDate == null){ ** raise an error; @@ -254,7 +249,7 @@ boolean isLastBusinessDayOfMonth(final String date) { * @return true if {@code date} is on the last business day of the month; false otherwise. */ default boolean isLastBusinessDayOfMonth() { - return isLastBusinessDayOfMonth(currentDay()); + return isLastBusinessDayOfMonth(currentDate()); } /** @@ -273,8 +268,8 @@ default boolean isLastBusinessDayOfWeek(final LocalDate date){ return false; } - final LocalDate nextBusinessDay = nextBusinessDay(date); - return dayOfWeek(date).compareTo(dayOfWeek(nextBusinessDay)) > 0 || numberOfDays(date, nextBusinessDay) > 6; + final LocalDate nextBusinessDay = futureBusinessDate(date); + return dayOfWeek(date).compareTo(dayOfWeek(nextBusinessDay)) > 0 || numberCalendarDates(date, nextBusinessDay) > 6; } /** @@ -330,9 +325,12 @@ default boolean isLastBusinessDayOfWeek(final String date){ * @return true if {@code date} is on the last business day of the week; false otherwise. */ default boolean isLastBusinessDayOfWeek() { - return isLastBusinessDayOfWeek(currentDay()); + return isLastBusinessDayOfWeek(currentDate()); } + //TODO: isLastBusinessDayOfYear() + //TODO: isLastNonBusinessDayOfYear() -> and other non business day equivalents + // endregion // region Business Time @@ -345,9 +343,10 @@ default boolean isLastBusinessDayOfWeek() { * @return true if the specified time is a business time; otherwise, false. */ default boolean isBusinessTime(final ZonedDateTime time) { - return time != null && getBusinessSchedule(time).isBusinessTime(time); + return time != null && businessSchedule(time).isBusinessTime(time); } + //TODO: zero arg version? /** * Determines if the specified time is a business time. If the time falls between business periods, false will be * returned. @@ -356,7 +355,7 @@ default boolean isBusinessTime(final ZonedDateTime time) { * @return true if the specified time is a business time; otherwise, false. */ default boolean isBusinessTime(final Instant time) { - return time != null && getBusinessSchedule(time).isBusinessTime(time); + return time != null && businessSchedule(time).isBusinessTime(time); } /** @@ -378,7 +377,7 @@ default long standardBusinessDayLengthNanos() { * @return ratio of the business day length and the standard business day length for the date */ default double fractionOfStandardBusinessDay(final LocalDate date){ - final BusinessSchedule schedule = getBusinessSchedule(date); + final BusinessSchedule schedule = businessSchedule(date); return schedule == null ? 0.0 : (double) schedule.getLOBD() / (double) standardBusinessDayLengthNanos(); } @@ -408,6 +407,7 @@ default double fractionOfStandardBusinessDay(final ZonedDateTime time){ return time == null ? 0.0 : fractionOfStandardBusinessDay(DateTimeUtils.toLocalDate(time.toInstant(), timeZone())); } + //TODO: add zero arg methods for other funcs /** * Returns the ratio of the current day's business day length and the standard business day length. For example, a * holiday has zero business time and will therefore return 0.0. A normal business day will be of the standard @@ -417,7 +417,7 @@ default double fractionOfStandardBusinessDay(final ZonedDateTime time){ * @return ratio of the business day length and the standard business day length for the current day */ default double fractionOfStandardBusinessDay() { - return fractionOfStandardBusinessDay(currentDay()); + return fractionOfStandardBusinessDay(currentDate()); } /** @@ -427,7 +427,7 @@ default double fractionOfStandardBusinessDay() { * @return the fraction of the day left after {@code time}; NULL_DOUBLE if time is null */ default double fractionOfBusinessDayRemaining(final Instant time){ - final BusinessSchedule businessDate = getBusinessSchedule(time); + final BusinessSchedule businessDate = businessSchedule(time); if (businessDate == null) { return QueryConstants.NULL_DOUBLE; } @@ -454,6 +454,7 @@ default double fractionOfBusinessDayRemaining(final ZonedDateTime time){ return fractionOfBusinessDayRemaining(time.toInstant()); } + //TODO: remove Of from function names! /** * Returns the fraction of the business day complete by the given time. * @@ -488,7 +489,6 @@ default double fractionOfBusinessDayComplete(final ZonedDateTime time) { //TODO: consistently handle inclusive / exclusive in these ranges - //TODO: add InRange to name /** * Returns the number of business days between {@code start} and {@code end}. * @@ -498,7 +498,7 @@ default double fractionOfBusinessDayComplete(final ZonedDateTime time) { * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberOfBusinessDays(final LocalDate start, final LocalDate end, final boolean endInclusive) { + default int numberBusinessDates(final LocalDate start, final LocalDate end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } @@ -508,23 +508,22 @@ default int numberOfBusinessDays(final LocalDate start, final LocalDate end, fin if (isBusinessDay(start)) { days++; } - start = nextBusinessDay(start); + start = futureBusinessDate(start); } else if (start.isAfter(end)) { //TODO: is this working right? - return -numberOfBusinessDays(end, start, endInclusive); + return -numberBusinessDates(end, start, endInclusive); } LocalDate day = start; while (day.isBefore(end)) { days++; - day = nextBusinessDay(day); + day = futureBusinessDate(day); } return days + (endInclusive && isBusinessDay(end) ? 1 : 0); } - //TODO: add InRange to name //TODO: add endInclusive on all methods /** * Returns the number of business days between {@code start} and {@code end}. @@ -535,15 +534,14 @@ default int numberOfBusinessDays(final LocalDate start, final LocalDate end, fin * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberOfBusinessDays(Instant start, Instant end, final boolean endInclusive) { + default int numberBusinessDates(Instant start, Instant end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } - return numberOfBusinessDays(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), endInclusive); + return numberBusinessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), endInclusive); } - //TODO: add InRange to name /** * Returns the number of business days between {@code start} and {@code end}. * @@ -553,15 +551,14 @@ default int numberOfBusinessDays(Instant start, Instant end, final boolean endIn * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberOfBusinessDays(ZonedDateTime start, ZonedDateTime end, final boolean endInclusive) { + default int numberBusinessDates(ZonedDateTime start, ZonedDateTime end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } - return numberOfBusinessDays(DateTimeUtils.toLocalDate(start.toInstant(), timeZone()), DateTimeUtils.toLocalDate(end.toInstant(), timeZone()), endInclusive); + return numberBusinessDates(DateTimeUtils.toLocalDate(start.toInstant(), timeZone()), DateTimeUtils.toLocalDate(end.toInstant(), timeZone()), endInclusive); } - //TODO: add InRange to name /** * Returns the number of business days between {@code start} and {@code end}. * @@ -571,15 +568,14 @@ default int numberOfBusinessDays(ZonedDateTime start, ZonedDateTime end, final b * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberOfBusinessDays(String start, String end, final boolean endInclusive) { + default int numberBusinessDates(String start, String end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } - return numberOfBusinessDays(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), endInclusive); + return numberBusinessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), endInclusive); } - //TODO: add InRange to name /** * Returns the number of non-business days between {@code start} and {@code end}. * @@ -589,15 +585,14 @@ default int numberOfBusinessDays(String start, String end, final boolean endIncl * @return number of non-business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberOfNonBusinessDays(final LocalDate start, final LocalDate end, final boolean endInclusive) { + default int numberNonBusinessDates(final LocalDate start, final LocalDate end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } - return numberOfDays(start, end, endInclusive) - numberOfBusinessDays(start, end, endInclusive); + return numberCalendarDates(start, end, endInclusive) - numberBusinessDates(start, end, endInclusive); } - //TODO: add InRange to name /** * Returns the number of non-business days between {@code start} and {@code end}. * @@ -607,15 +602,14 @@ default int numberOfNonBusinessDays(final LocalDate start, final LocalDate end, * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberOfNonBusinessDays(Instant start, Instant end, final boolean endInclusive) { + default int numberNonBusinessDates(Instant start, Instant end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } - return numberOfNonBusinessDays(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), endInclusive); + return numberNonBusinessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), endInclusive); } - //TODO: add InRange to name /** * Returns the number of non-business days between {@code start} and {@code end}. * @@ -625,12 +619,12 @@ default int numberOfNonBusinessDays(Instant start, Instant end, final boolean en * @return number of non-business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberOfNonBusinessDays(final String start, final String end, final boolean endInclusive) { + default int numberNonBusinessDates(final String start, final String end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } - return numberOfNonBusinessDays(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), endInclusive); + return numberNonBusinessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), endInclusive); } /** @@ -643,7 +637,7 @@ default int numberOfNonBusinessDays(final String start, final String end, final * @param end end time; if null, return empty array * @return inclusive business days between {@code start} and {@code end} */ - default LocalDate[] businessDaysInRange(final LocalDate start, final LocalDate end) { + default LocalDate[] businessDates(final LocalDate start, final LocalDate end) { if (start == null || end == null) { return new LocalDate[0]; } @@ -671,12 +665,12 @@ default LocalDate[] businessDaysInRange(final LocalDate start, final LocalDate e * @param end end time; if null, return empty array * @return inclusive business days between {@code start} and {@code end} */ - default LocalDate[] businessDaysInRange(final Instant start, final Instant end) { + default LocalDate[] businessDates(final Instant start, final Instant end) { if (start == null || end == null) { return new LocalDate[0]; } - return businessDaysInRange(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone())); + return businessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone())); } /** @@ -689,12 +683,12 @@ default LocalDate[] businessDaysInRange(final Instant start, final Instant end) * @param end end time; if null, return empty array * @return inclusive business days between {@code start} and {@code end} */ - default LocalDate[] businessDaysInRange(final ZonedDateTime start, final ZonedDateTime end) { + default LocalDate[] businessDates(final ZonedDateTime start, final ZonedDateTime end) { if (start == null || end == null) { return new LocalDate[0]; } - return businessDaysInRange(DateTimeUtils.toLocalDate(start.toInstant(), timeZone()), DateTimeUtils.toLocalDate(end.toInstant(), timeZone())); + return businessDates(DateTimeUtils.toLocalDate(start.toInstant(), timeZone()), DateTimeUtils.toLocalDate(end.toInstant(), timeZone())); } /** @@ -707,12 +701,12 @@ default LocalDate[] businessDaysInRange(final ZonedDateTime start, final ZonedDa * @param end end time; if null, return empty array * @return inclusive business days between {@code start} and {@code end} */ - default LocalDate[] businessDaysInRange(String start, String end){ + default LocalDate[] businessDates(String start, String end){ if (start == null || end == null) { return new LocalDate[0]; } - return businessDaysInRange(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end)); + return businessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end)); } /** @@ -725,7 +719,7 @@ default LocalDate[] businessDaysInRange(String start, String end){ * @param end end time; if null, return empty array * @return inclusive non-business days between {@code start} and {@code end} */ - default LocalDate[] nonBusinessDaysInRange(final LocalDate start, final LocalDate end){ + default LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end){ if (start == null || end == null) { return new LocalDate[0]; } @@ -753,12 +747,12 @@ default LocalDate[] nonBusinessDaysInRange(final LocalDate start, final LocalDat * @param end end time; if null, return empty array * @return inclusive non-business days between {@code start} and {@code end} */ - default LocalDate[] nonBusinessDaysInRange(final Instant start, final Instant end){ + default LocalDate[] nonBusinessDates(final Instant start, final Instant end){ if (start == null || end == null) { return new LocalDate[0]; } - return nonBusinessDaysInRange(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone())); + return nonBusinessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone())); } /** @@ -771,12 +765,12 @@ default LocalDate[] nonBusinessDaysInRange(final Instant start, final Instant en * @param end end time; if null, return empty array * @return inclusive non-business days between {@code start} and {@code end} */ - default LocalDate[] nonBusinessDaysInRange(final ZonedDateTime start, final ZonedDateTime end){ + default LocalDate[] nonBusinessDates(final ZonedDateTime start, final ZonedDateTime end){ if (start == null || end == null) { return new LocalDate[0]; } - return nonBusinessDaysInRange(DateTimeUtils.toLocalDate(start.toInstant(), timeZone()), DateTimeUtils.toLocalDate(end.toInstant(), timeZone())); + return nonBusinessDates(DateTimeUtils.toLocalDate(start.toInstant(), timeZone()), DateTimeUtils.toLocalDate(end.toInstant(), timeZone())); } /** @@ -789,12 +783,12 @@ default LocalDate[] nonBusinessDaysInRange(final ZonedDateTime start, final Zone * @param end end time; if null, return empty array * @return inclusive non-business days between {@code start} and {@code end} */ - default LocalDate[] nonBusinessDaysInRange(String start, String end){ + default LocalDate[] nonBusinessDates(String start, String end){ if (start == null || end == null) { return new LocalDate[0]; } - return nonBusinessDaysInRange(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end)); + return nonBusinessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end)); } /** @@ -818,7 +812,7 @@ default long diffBusinessNanos(final Instant start, final Instant end) { while (!DateTimeUtils.isAfter(day, end)) { if (isBusinessDay(day)) { - BusinessSchedule businessDate = getBusinessSchedule(day); + BusinessSchedule businessDate = businessSchedule(day); if (businessDate != null) { for (BusinessPeriod businessPeriod : businessDate.getBusinessPeriods()) { @@ -844,7 +838,7 @@ default long diffBusinessNanos(final Instant start, final Instant end) { } } } - day = getBusinessSchedule(nextBusinessDay(day)).getSOBD(); + day = businessSchedule(futureBusinessDate(day)).getSOBD(); } return dayDiffNanos; } @@ -905,7 +899,7 @@ default long diffNonBusinessNanos(final ZonedDateTime start, final ZonedDateTime * @param end end time; if null, return NULL_LONG * @return the amount of business time in standard business days between the {@code start} and {@code end} */ - default double diffBusinessDay(final Instant start, final Instant end) { + default double diffBusinessDays(final Instant start, final Instant end) { if (start == null || end == null) { return QueryConstants.NULL_DOUBLE; } @@ -920,12 +914,12 @@ default double diffBusinessDay(final Instant start, final Instant end) { * @param end end time; if null, return NULL_LONG * @return the amount of business time in standard business days between the {@code start} and {@code end} */ - default double diffBusinessDay(final ZonedDateTime start, final ZonedDateTime end) { + default double diffBusinessDays(final ZonedDateTime start, final ZonedDateTime end) { if (start == null || end == null) { return QueryConstants.NULL_DOUBLE; } - return diffBusinessDay(start.toInstant(), end.toInstant()); + return diffBusinessDays(start.toInstant(), end.toInstant()); } /** @@ -935,7 +929,7 @@ default double diffBusinessDay(final ZonedDateTime start, final ZonedDateTime en * @param end end time; if null, return NULL_LONG * @return the amount of non-business time in standard business days between the {@code start} and {@code end} */ - default double diffNonBusinessDay(final Instant start, final Instant end){ + default double diffNonBusinessDays(final Instant start, final Instant end){ if (start == null || end == null) { return QueryConstants.NULL_DOUBLE; } @@ -950,12 +944,12 @@ default double diffNonBusinessDay(final Instant start, final Instant end){ * @param end end time; if null, return NULL_LONG * @return the amount of non-business time in standard business days between the {@code start} and {@code end} */ - default double diffNonBusinessDay(final ZonedDateTime start, final ZonedDateTime end){ + default double diffNonBusinessDays(final ZonedDateTime start, final ZonedDateTime end){ if (start == null || end == null) { return QueryConstants.NULL_DOUBLE; } - return diffNonBusinessDay(start.toInstant(), end.toInstant()); + return diffNonBusinessDays(start.toInstant(), end.toInstant()); } /** @@ -965,7 +959,7 @@ default double diffNonBusinessDay(final ZonedDateTime start, final ZonedDateTime * @param end end; if null, return null * @return the amount of business time in business years between the {@code start} and {@code end} */ - default double diffBusinessYear(final Instant start, final Instant end){ + default double diffBusinessYears(final Instant start, final Instant end){ if (start == null || end == null) { return QueryConstants.NULL_DOUBLE; } @@ -999,20 +993,18 @@ default double diffBusinessYear(final Instant start, final Instant end){ * @param end end; if null, return null * @return the amount of business time in business years between the {@code start} and {@code end} */ - default double diffBusinessYear(final ZonedDateTime start, final ZonedDateTime end) { + default double diffBusinessYears(final ZonedDateTime start, final ZonedDateTime end) { if (start == null || end == null) { return QueryConstants.NULL_DOUBLE; } - return diffBusinessYear(start.toInstant(), end.toInstant()); + return diffBusinessYears(start.toInstant(), end.toInstant()); } // endregion // region Arithmetic - //TODO: what is the simpliest API? - //TODO: simplify names? e.g. nonbusinessday -> NBD? //TODO: should the add/subtract methods on Instants or ZDT return times of LocalDates? /** @@ -1022,7 +1014,7 @@ default double diffBusinessYear(final ZonedDateTime start, final ZonedDateTime e * @param days number of days to add. * @return {@code days} business days after {@code date}; null if {@code date} is null or if {@code date} is not a business day and {@code days} is zero. */ - default LocalDate addBusinessDays(final LocalDate date, int days) { + default LocalDate plusBusinessDays(final LocalDate date, int days) { if (date == null) { return null; } else if(days == 0){ @@ -1048,13 +1040,13 @@ default LocalDate addBusinessDays(final LocalDate date, int days) { * @param days number of days to add. * @return {@code days} business days after {@code date}; null if {@code date} is null or if {@code date} is not a business day and {@code days} is zero. */ - default LocalDate addBusinessDays(final String date, int days) { + default LocalDate plusBusinessDays(final String date, int days) { if(date == null){ return null; } //TODO: should the date parsing be quiet? Document exceptions? - return addBusinessDays(DateTimeUtils.parseLocalDate(date), days); + return plusBusinessDays(DateTimeUtils.parseLocalDate(date), days); } /** @@ -1064,12 +1056,12 @@ default LocalDate addBusinessDays(final String date, int days) { * @param days number of days to add. * @return {@code days} business days after {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - default LocalDate addBusinessDays(final Instant time, int days) { + default LocalDate plusBusinessDays(final Instant time, int days) { if(time == null){ return null; } - return addBusinessDays(DateTimeUtils.toLocalDate(time, timeZone()), days); + return plusBusinessDays(DateTimeUtils.toLocalDate(time, timeZone()), days); } /** @@ -1079,12 +1071,12 @@ default LocalDate addBusinessDays(final Instant time, int days) { * @param days number of days to add. * @return {@code days} business days after {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - default LocalDate addBusinessDays(final ZonedDateTime time, int days) { + default LocalDate plusBusinessDays(final ZonedDateTime time, int days) { if(time == null){ return null; } - return addBusinessDays(time.toInstant(), days); + return plusBusinessDays(time.toInstant(), days); } /** @@ -1094,8 +1086,8 @@ default LocalDate addBusinessDays(final ZonedDateTime time, int days) { * @param days number of days to subtract. * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - default LocalDate subtractBusinessDays(final LocalDate date, int days) { - return addBusinessDays(date, -days); + default LocalDate minusBusinessDays(final LocalDate date, int days) { + return plusBusinessDays(date, -days); } /** @@ -1105,8 +1097,8 @@ default LocalDate subtractBusinessDays(final LocalDate date, int days) { * @param days number of days to subtract. * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - default LocalDate subtractBusinessDays(final String date, int days) { - return addBusinessDays(date, -days); + default LocalDate minusBusinessDays(final String date, int days) { + return plusBusinessDays(date, -days); } /** @@ -1116,8 +1108,8 @@ default LocalDate subtractBusinessDays(final String date, int days) { * @param days number of days to subtract. * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - default LocalDate subtractBusinessDays(final Instant time, int days) { - return addBusinessDays(time, -days); + default LocalDate minusBusinessDays(final Instant time, int days) { + return plusBusinessDays(time, -days); } /** @@ -1127,8 +1119,8 @@ default LocalDate subtractBusinessDays(final Instant time, int days) { * @param days number of days to subtract. * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - default LocalDate subtractBusinessDays(final ZonedDateTime time, int days) { - return addBusinessDays(time, -days); + default LocalDate minusBusinessDays(final ZonedDateTime time, int days) { + return plusBusinessDays(time, -days); } /** @@ -1138,7 +1130,7 @@ default LocalDate subtractBusinessDays(final ZonedDateTime time, int days) { * @param days number of days to add. * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default LocalDate addNonBusinessDays(final LocalDate date, int days) { + default LocalDate plusNonBusinessDays(final LocalDate date, int days) { if (date == null) { return null; } else if(days == 0){ @@ -1164,12 +1156,12 @@ default LocalDate addNonBusinessDays(final LocalDate date, int days) { * @param days number of days to add. * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default LocalDate addNonBusinessDays(final LocalDate date, int days) { + default LocalDate plusNonBusinessDays(final LocalDate date, int days) { if(date == null){ return null; } - return addNonBusinessDays(DateTimeUtils.parseLocalDate(date), days); + return this.plusNonBusinessDays(DateTimeUtils.parseLocalDate(date), days); } /** @@ -1179,12 +1171,12 @@ default LocalDate addNonBusinessDays(final LocalDate date, int days) { * @param days number of days to add. * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default LocalDate addNonBusinessDays(final Instant time, int days) { + default LocalDate plusNonBusinessDays(final Instant time, int days) { if(time == null){ return null; } - return addNonBusinessDays(DateTimeUtils.toLocalDate(time, timeZone()), days); + return this.plusNonBusinessDays(DateTimeUtils.toLocalDate(time, timeZone()), days); } /** @@ -1194,12 +1186,12 @@ default LocalDate addNonBusinessDays(final Instant time, int days) { * @param days number of days to add. * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default LocalDate addNonBusinessDays(final ZonedDateTime time, int days) { + default LocalDate plusNonBusinessDays(final ZonedDateTime time, int days) { if(time == null){ return null; } - return addNonBusinessDays(time.toInstant(), days); + return plusNonBusinessDays(time.toInstant(), days); } /** @@ -1209,8 +1201,8 @@ default LocalDate addNonBusinessDays(final ZonedDateTime time, int days) { * @param days number of days to subtract. * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default LocalDate subtractNonBusinessDays(final LocalDate date, int days) { - return addNonBusinessDays(date, -days); + default LocalDate minusNonBusinessDays(final LocalDate date, int days) { + return this.plusNonBusinessDays(date, -days); } /** @@ -1220,7 +1212,7 @@ default LocalDate subtractNonBusinessDays(final LocalDate date, int days) { * @param days number of days to subtract. * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default LocalDate subtractNonBusinessDays(final String date, int days) { + default LocalDate minusNonBusinessDays(final String date, int days) { return addNonBusinessDays(date, -days); } @@ -1231,8 +1223,8 @@ default LocalDate subtractNonBusinessDays(final String date, int days) { * @param days number of days to subtract. * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code time} is a business day and {@code days} is zero. */ - default LocalDate subtractNonBusinessDays(final Instant time, int days) { - return addNonBusinessDays(time, -days); + default LocalDate minusNonBusinessDays(final Instant time, int days) { + return plusNonBusinessDays(time, -days); } /** @@ -1242,8 +1234,8 @@ default LocalDate subtractNonBusinessDays(final Instant time, int days) { * @param days number of days to subtract. * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code time} is a business day and {@code days} is zero. */ - default LocalDate subtractNonBusinessDays(final ZonedDateTime time, int days) { - return addNonBusinessDays(time, -days); + default LocalDate minusNonBusinessDays(final ZonedDateTime time, int days) { + return plusNonBusinessDays(time, -days); } /** @@ -1252,8 +1244,8 @@ default LocalDate subtractNonBusinessDays(final ZonedDateTime time, int days) { * @param days number of days to add. * @return {@code days} business days after the current date; null if the current date is not a business day and {@code days} is zero. */ - default LocalDate nextBusinessDay(int days) { - return addBusinessDays(currentDay(), days); + default LocalDate futureBusinessDate(int days) { + return plusBusinessDays(currentDate(), days); } /** @@ -1262,8 +1254,8 @@ default LocalDate nextBusinessDay(int days) { * @param days number of days to subtract. * @return {@code days} business days before the current date; null if the current date is not a business day and {@code days} is zero. */ - default LocalDate previousBusinessDay(int days) { - return subtractBusinessDays(currentDay(), days); + default LocalDate pastBusinessDate(int days) { + return minusBusinessDays(currentDate(), days); } /** @@ -1272,8 +1264,8 @@ default LocalDate previousBusinessDay(int days) { * @param days number of days to add. * @return {@code days} non-business days after the current date; null if the current date is a business day and {@code days} is zero. */ - default LocalDate nextNonBusinessDay(int days) { - return addNonBusinessDays(currentDay(), days); + default LocalDate futureNonBusinessDate(int days) { + return this.plusNonBusinessDays(currentDate(), days); } /** @@ -1282,12 +1274,13 @@ default LocalDate nextNonBusinessDay(int days) { * @param days number of days to subtract. * @return {@code days} non-business days before the current date; null if the current date is a business day and {@code days} is zero. */ - default LocalDate previousNonBusinessDay(int days) { - return subtractNonBusinessDays(currentDay(), days); + default LocalDate pastNonBusinessDate(int days) { + return minusNonBusinessDays(currentDate(), days); } // endregion + //TODO: add to a region //TODO: relocate //TODO: remove from API? //TODO: rename diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/DefaultBusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/DefaultBusinessCalendar.java index c1c70dd9f1d..b7c02cefec1 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/DefaultBusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/DefaultBusinessCalendar.java @@ -318,13 +318,6 @@ private static BusinessPeriod[] parseBusinessPeriods(final ZoneId timeZone, fina return businessPeriods; } - @Override - public List getDefaultBusinessPeriods() { - return Collections.unmodifiableList(defaultBusinessPeriodStrings); - } - - - private static String getText(Element element) { return element == null ? null : element.getTextTrim(); } @@ -354,7 +347,7 @@ private long getBusinessYearLength(final int year) { for (int j = 0; j < numDays; j++) { final int day = j + 1; - final BusinessSchedule businessDate = getBusinessSchedule(LocalDate.ofYearDay(year, day)); + final BusinessSchedule businessDate = businessSchedule(LocalDate.ofYearDay(year, day)); yearLength += businessDate.getLOBD(); } @@ -365,7 +358,7 @@ private Instant getFirstBusinessDateTimeOfYear(final int year) { boolean isLeap = DateStringUtils.isLeapYear(year); int numDays = 365 + (isLeap ? 1 : 0); for (int j = 0; j < numDays; j++) { - final BusinessSchedule businessDate = getBusinessSchedule(LocalDate.ofYearDay(year, j + 1)); + final BusinessSchedule businessDate = businessSchedule(LocalDate.ofYearDay(year, j + 1)); if (!(businessDate instanceof Holiday)) { return businessDate.getSOBD(); } diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/DefaultNoHolidayBusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/DefaultNoHolidayBusinessCalendar.java index bf8add185ef..8e5682811aa 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/DefaultNoHolidayBusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/DefaultNoHolidayBusinessCalendar.java @@ -34,7 +34,7 @@ public List getDefaultBusinessPeriods() { @Override public Map getHolidays() { - return calendar.getHolidays(); + return calendar.holidays(); } @Override @@ -59,17 +59,17 @@ public long standardBusinessDayLengthNanos() { @Override public BusinessSchedule getBusinessSchedule(final Instant time) { - return calendar.getBusinessSchedule(time); + return calendar.businessSchedule(time); } @Override public BusinessSchedule getBusinessSchedule(final String date) { - return calendar.getBusinessSchedule(date); + return calendar.businessSchedule(date); } @Override public BusinessSchedule getBusinessSchedule(final LocalDate date) { - return calendar.getBusinessSchedule(date); + return calendar.businessSchedule(date); } @Override @@ -79,7 +79,7 @@ public long diffBusinessNanos(final Instant start, final Instant end) { @Override public double diffBusinessYear(final Instant startTime, final Instant endTime) { - return calendar.diffBusinessYear(startTime, endTime); + return calendar.diffBusinessYears(startTime, endTime); } @Override diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/StaticCalendarMethods.java b/engine/time/src/main/java/io/deephaven/time/calendar/StaticCalendarMethods.java index c446c5080a7..4e7a4a728dd 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/StaticCalendarMethods.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/StaticCalendarMethods.java @@ -29,79 +29,79 @@ public static String name() { } public static String currentDay() { - return Calendars.calendar().currentDay(); + return Calendars.calendar().currentDate(); } public static String previousDay() { - return Calendars.calendar().previousDay(); + return Calendars.calendar().pastDate(); } public static String previousDay(int days) { - return Calendars.calendar().previousDay(days); + return Calendars.calendar().pastDate(days); } public static String previousDay(final Instant time) { - return Calendars.calendar().previousDay(time); + return Calendars.calendar().pastDate(time); } public static String previousDay(final Instant time, final int days) { - return Calendars.calendar().previousDay(time, days); + return Calendars.calendar().pastDate(time, days); } public static String previousDay(final String date) { - return Calendars.calendar().previousDay(date); + return Calendars.calendar().pastDate(date); } public static String previousDay(final String date, final int days) { - return Calendars.calendar().previousDay(date, days); + return Calendars.calendar().pastDate(date, days); } public static String nextDay() { - return Calendars.calendar().nextDay(); + return Calendars.calendar().futureDate(); } public static String nextDay(int days) { - return Calendars.calendar().nextDay(days); + return Calendars.calendar().futureDate(days); } public static String nextDay(final Instant time) { - return Calendars.calendar().nextDay(time); + return Calendars.calendar().futureDate(time); } public static String nextDay(final Instant time, final int days) { - return Calendars.calendar().nextDay(time, days); + return Calendars.calendar().futureDate(time, days); } public static String nextDay(final String date) { - return Calendars.calendar().nextDay(date); + return Calendars.calendar().futureDate(date); } public static String nextDay(final String date, final int days) { - return Calendars.calendar().nextDay(date, days); + return Calendars.calendar().futureDate(date, days); } public static String[] daysInRange(Instant start, Instant end) { - return Calendars.calendar().daysInRange(start, end); + return Calendars.calendar().calendarDates(start, end); } public static String[] daysInRange(final String start, final String end) { - return Calendars.calendar().daysInRange(start, end); + return Calendars.calendar().calendarDates(start, end); } public static int numberOfDays(final Instant start, final Instant end) { - return Calendars.calendar().numberOfDays(start, end); + return Calendars.calendar().numberCalendarDates(start, end); } public static int numberOfDays(final Instant start, final Instant end, final boolean endInclusive) { - return Calendars.calendar().numberOfDays(start, end, endInclusive); + return Calendars.calendar().numberCalendarDates(start, end, endInclusive); } public static int numberOfDays(final String start, final String end) { - return Calendars.calendar().numberOfDays(start, end); + return Calendars.calendar().numberCalendarDates(start, end); } public static int numberOfDays(final String start, final String end, final boolean endInclusive) { - return Calendars.calendar().numberOfDays(start, end, endInclusive); + return Calendars.calendar().numberCalendarDates(start, end, endInclusive); } public static DayOfWeek dayOfWeek() { @@ -141,27 +141,27 @@ public static boolean isBusinessTime(Instant time) { } public static String previousBusinessDay() { - return Calendars.calendar().previousBusinessDay(); + return Calendars.calendar().pastBusinessDate(); } public static String previousBusinessDay(int days) { - return Calendars.calendar().previousBusinessDay(days); + return Calendars.calendar().pastBusinessDate(days); } public static String previousBusinessDay(Instant time) { - return Calendars.calendar().previousBusinessDay(time); + return Calendars.calendar().pastBusinessDate(time); } public static String previousBusinessDay(Instant time, int days) { - return Calendars.calendar().previousBusinessDay(time, days); + return Calendars.calendar().pastBusinessDate(time, days); } public static String previousBusinessDay(String date) { - return Calendars.calendar().previousBusinessDay(date); + return Calendars.calendar().pastBusinessDate(date); } public static String previousBusinessDay(String date, int days) { - return Calendars.calendar().previousBusinessDay(date, days); + return Calendars.calendar().pastBusinessDate(date, days); } public static BusinessSchedule previousBusinessSchedule() { @@ -189,51 +189,51 @@ public static BusinessSchedule previousBusinessSchedule(String date, int days) { } public static String previousNonBusinessDay() { - return Calendars.calendar().previousNonBusinessDay(); + return Calendars.calendar().pastNonBusinessDate(); } public static String previousNonBusinessDay(int days) { - return Calendars.calendar().previousNonBusinessDay(days); + return Calendars.calendar().pastNonBusinessDate(days); } public static String previousNonBusinessDay(Instant time) { - return Calendars.calendar().previousNonBusinessDay(time); + return Calendars.calendar().pastNonBusinessDate(time); } public static String previousNonBusinessDay(Instant time, int days) { - return Calendars.calendar().previousNonBusinessDay(time, days); + return Calendars.calendar().pastNonBusinessDate(time, days); } public static String previousNonBusinessDay(String date) { - return Calendars.calendar().previousNonBusinessDay(date); + return Calendars.calendar().pastNonBusinessDate(date); } public static String previousNonBusinessDay(String date, int days) { - return Calendars.calendar().previousNonBusinessDay(date, days); + return Calendars.calendar().pastNonBusinessDate(date, days); } public static String nextBusinessDay() { - return Calendars.calendar().nextBusinessDay(); + return Calendars.calendar().futureBusinessDate(); } public static String nextBusinessDay(int days) { - return Calendars.calendar().nextBusinessDay(days); + return Calendars.calendar().futureBusinessDate(days); } public static String nextBusinessDay(Instant time) { - return Calendars.calendar().nextBusinessDay(time); + return Calendars.calendar().futureBusinessDate(time); } public static String nextBusinessDay(Instant time, int days) { - return Calendars.calendar().nextBusinessDay(time, days); + return Calendars.calendar().futureBusinessDate(time, days); } public static String nextBusinessDay(String date) { - return Calendars.calendar().nextBusinessDay(date); + return Calendars.calendar().futureBusinessDate(date); } public static String nextBusinessDay(String date, int days) { - return Calendars.calendar().nextBusinessDay(date, days); + return Calendars.calendar().futureBusinessDate(date, days); } public static BusinessSchedule nextBusinessSchedule() { @@ -261,43 +261,43 @@ public static BusinessSchedule nextBusinessSchedule(String date, int days) { } public static String nextNonBusinessDay() { - return Calendars.calendar().nextNonBusinessDay(); + return Calendars.calendar().futureNonBusinessDate(); } public static String nextNonBusinessDay(int days) { - return Calendars.calendar().nextNonBusinessDay(days); + return Calendars.calendar().futureNonBusinessDate(days); } public static String nextNonBusinessDay(Instant time) { - return Calendars.calendar().nextNonBusinessDay(time); + return Calendars.calendar().futureNonBusinessDate(time); } public static String nextNonBusinessDay(Instant time, int days) { - return Calendars.calendar().nextNonBusinessDay(time, days); + return Calendars.calendar().futureNonBusinessDate(time, days); } public static String nextNonBusinessDay(String date) { - return Calendars.calendar().nextNonBusinessDay(date); + return Calendars.calendar().futureNonBusinessDate(date); } public static String nextNonBusinessDay(String date, int days) { - return Calendars.calendar().nextNonBusinessDay(date, days); + return Calendars.calendar().futureNonBusinessDate(date, days); } public static String[] businessDaysInRange(Instant start, Instant end) { - return Calendars.calendar().businessDaysInRange(start, end); + return Calendars.calendar().businessDates(start, end); } public static String[] businessDaysInRange(String start, String end) { - return Calendars.calendar().businessDaysInRange(start, end); + return Calendars.calendar().businessDates(start, end); } public static String[] nonBusinessDaysInRange(Instant start, Instant end) { - return Calendars.calendar().nonBusinessDaysInRange(start, end); + return Calendars.calendar().nonBusinessDates(start, end); } public static String[] nonBusinessDaysInRange(String start, String end) { - return Calendars.calendar().nonBusinessDaysInRange(start, end); + return Calendars.calendar().nonBusinessDates(start, end); } public static long standardBusinessDayLengthNanos() { @@ -313,15 +313,15 @@ public static long diffNonBusinessNanos(Instant start, Instant end) { } public static double diffBusinessDay(Instant start, Instant end) { - return Calendars.calendar().diffBusinessDay(start, end); + return Calendars.calendar().diffBusinessDays(start, end); } public static double diffNonBusinessDay(Instant start, Instant end) { - return Calendars.calendar().diffNonBusinessDay(start, end); + return Calendars.calendar().diffNonBusinessDays(start, end); } public static double diffBusinessYear(Instant start, Instant end) { - return Calendars.calendar().diffBusinessYear(start, end); + return Calendars.calendar().diffBusinessYears(start, end); } public static int numberOfBusinessDays(Instant start, Instant end) { @@ -329,7 +329,7 @@ public static int numberOfBusinessDays(Instant start, Instant end) { } public static int numberOfBusinessDays(Instant start, Instant end, boolean endInclusive) { - return Calendars.calendar().numberOfBusinessDays(start, end, endInclusive); + return Calendars.calendar().numberBusinessDates(start, end, endInclusive); } public static int numberOfBusinessDays(String start, String end) { @@ -337,7 +337,7 @@ public static int numberOfBusinessDays(String start, String end) { } public static int numberOfBusinessDays(String start, String end, boolean endInclusive) { - return Calendars.calendar().numberOfBusinessDays(start, end, endInclusive); + return Calendars.calendar().numberBusinessDates(start, end, endInclusive); } public static int numberOfNonBusinessDays(Instant start, Instant end) { @@ -345,7 +345,7 @@ public static int numberOfNonBusinessDays(Instant start, Instant end) { } public static int numberOfNonBusinessDays(Instant start, Instant end, boolean endInclusive) { - return Calendars.calendar().numberOfNonBusinessDays(start, end, endInclusive); + return Calendars.calendar().numberNonBusinessDates(start, end, endInclusive); } public static int numberOfNonBusinessDays(String start, String end) { @@ -353,7 +353,7 @@ public static int numberOfNonBusinessDays(String start, String end) { } public static int numberOfNonBusinessDays(String start, String end, boolean endInclusive) { - return Calendars.calendar().numberOfNonBusinessDays(start, end, endInclusive); + return Calendars.calendar().numberNonBusinessDates(start, end, endInclusive); } public static double fractionOfStandardBusinessDay() { @@ -401,14 +401,14 @@ public static boolean isLastBusinessDayOfWeek(String date) { } public static BusinessSchedule getBusinessSchedule(Instant time) { - return Calendars.calendar().getBusinessSchedule(time); + return Calendars.calendar().businessSchedule(time); } public static BusinessSchedule getBusinessSchedule(String date) { - return Calendars.calendar().getBusinessSchedule(date); + return Calendars.calendar().businessSchedule(date); } public static BusinessSchedule getBusinessSchedule(LocalDate date) { - return Calendars.calendar().getBusinessSchedule(date); + return Calendars.calendar().businessSchedule(date); } } diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java b/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java index 09b55f707fc..a1c1979fee7 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java @@ -71,12 +71,12 @@ public void testBusinessCalendarMethods() { assertEquals(calendar.isBusinessTime(time2), StaticCalendarMethods.isBusinessTime(time2)); - assertEquals(calendar.previousBusinessDay(), StaticCalendarMethods.previousBusinessDay()); - assertEquals(calendar.previousBusinessDay(12), StaticCalendarMethods.previousBusinessDay(12)); - assertEquals(calendar.previousBusinessDay(time1), StaticCalendarMethods.previousBusinessDay(time1)); - assertEquals(calendar.previousBusinessDay(time1, 6), StaticCalendarMethods.previousBusinessDay(time1, 6)); - assertEquals(calendar.previousBusinessDay(date1), StaticCalendarMethods.previousBusinessDay(date1)); - assertEquals(calendar.previousBusinessDay(date1, 16), StaticCalendarMethods.previousBusinessDay(date1, 16)); + assertEquals(calendar.pastBusinessDate(), StaticCalendarMethods.previousBusinessDay()); + assertEquals(calendar.pastBusinessDate(12), StaticCalendarMethods.previousBusinessDay(12)); + assertEquals(calendar.pastBusinessDate(time1), StaticCalendarMethods.previousBusinessDay(time1)); + assertEquals(calendar.pastBusinessDate(time1, 6), StaticCalendarMethods.previousBusinessDay(time1, 6)); + assertEquals(calendar.pastBusinessDate(date1), StaticCalendarMethods.previousBusinessDay(date1)); + assertEquals(calendar.pastBusinessDate(date1, 16), StaticCalendarMethods.previousBusinessDay(date1, 16)); assertEquals(calendar.previousBusinessSchedule(), StaticCalendarMethods.previousBusinessSchedule()); @@ -89,21 +89,21 @@ public void testBusinessCalendarMethods() { StaticCalendarMethods.previousBusinessSchedule(date1, 16)); - assertEquals(calendar.previousNonBusinessDay(), StaticCalendarMethods.previousNonBusinessDay()); - assertEquals(calendar.previousNonBusinessDay(12), StaticCalendarMethods.previousNonBusinessDay(12)); - assertEquals(calendar.previousNonBusinessDay(time1), StaticCalendarMethods.previousNonBusinessDay(time1)); - assertEquals(calendar.previousNonBusinessDay(time1, 6), StaticCalendarMethods.previousNonBusinessDay(time1, 6)); - assertEquals(calendar.previousNonBusinessDay(date1), StaticCalendarMethods.previousNonBusinessDay(date1)); - assertEquals(calendar.previousNonBusinessDay(date1, 16), + assertEquals(calendar.pastNonBusinessDate(), StaticCalendarMethods.previousNonBusinessDay()); + assertEquals(calendar.pastNonBusinessDate(12), StaticCalendarMethods.previousNonBusinessDay(12)); + assertEquals(calendar.pastNonBusinessDate(time1), StaticCalendarMethods.previousNonBusinessDay(time1)); + assertEquals(calendar.pastNonBusinessDate(time1, 6), StaticCalendarMethods.previousNonBusinessDay(time1, 6)); + assertEquals(calendar.pastNonBusinessDate(date1), StaticCalendarMethods.previousNonBusinessDay(date1)); + assertEquals(calendar.pastNonBusinessDate(date1, 16), StaticCalendarMethods.previousNonBusinessDay(date1, 16)); - assertEquals(calendar.nextBusinessDay(), StaticCalendarMethods.nextBusinessDay()); - assertEquals(calendar.nextBusinessDay(12), StaticCalendarMethods.nextBusinessDay(12)); - assertEquals(calendar.nextBusinessDay(time1), StaticCalendarMethods.nextBusinessDay(time1)); - assertEquals(calendar.nextBusinessDay(time1, 6), StaticCalendarMethods.nextBusinessDay(time1, 6)); - assertEquals(calendar.nextBusinessDay(date1), StaticCalendarMethods.nextBusinessDay(date1)); - assertEquals(calendar.nextBusinessDay(date1, 16), StaticCalendarMethods.nextBusinessDay(date1, 16)); + assertEquals(calendar.futureBusinessDate(), StaticCalendarMethods.nextBusinessDay()); + assertEquals(calendar.futureBusinessDate(12), StaticCalendarMethods.nextBusinessDay(12)); + assertEquals(calendar.futureBusinessDate(time1), StaticCalendarMethods.nextBusinessDay(time1)); + assertEquals(calendar.futureBusinessDate(time1, 6), StaticCalendarMethods.nextBusinessDay(time1, 6)); + assertEquals(calendar.futureBusinessDate(date1), StaticCalendarMethods.nextBusinessDay(date1)); + assertEquals(calendar.futureBusinessDate(date1, 16), StaticCalendarMethods.nextBusinessDay(date1, 16)); assertEquals(calendar.nextBusinessSchedule(), StaticCalendarMethods.nextBusinessSchedule()); @@ -114,12 +114,12 @@ public void testBusinessCalendarMethods() { assertEquals(calendar.nextBusinessSchedule(date1, 16), StaticCalendarMethods.nextBusinessSchedule(date1, 16)); - assertEquals(calendar.nextNonBusinessDay(), StaticCalendarMethods.nextNonBusinessDay()); - assertEquals(calendar.nextNonBusinessDay(12), StaticCalendarMethods.nextNonBusinessDay(12)); - assertEquals(calendar.nextNonBusinessDay(time1), StaticCalendarMethods.nextNonBusinessDay(time1)); - assertEquals(calendar.nextNonBusinessDay(time1, 6), StaticCalendarMethods.nextNonBusinessDay(time1, 6)); - assertEquals(calendar.nextNonBusinessDay(date1), StaticCalendarMethods.nextNonBusinessDay(date1)); - assertEquals(calendar.nextNonBusinessDay(date1, 16), StaticCalendarMethods.nextNonBusinessDay(date1, 16)); + assertEquals(calendar.futureNonBusinessDate(), StaticCalendarMethods.nextNonBusinessDay()); + assertEquals(calendar.futureNonBusinessDate(12), StaticCalendarMethods.nextNonBusinessDay(12)); + assertEquals(calendar.futureNonBusinessDate(time1), StaticCalendarMethods.nextNonBusinessDay(time1)); + assertEquals(calendar.futureNonBusinessDate(time1, 6), StaticCalendarMethods.nextNonBusinessDay(time1, 6)); + assertEquals(calendar.futureNonBusinessDate(date1), StaticCalendarMethods.nextNonBusinessDay(date1)); + assertEquals(calendar.futureNonBusinessDate(date1, 16), StaticCalendarMethods.nextNonBusinessDay(date1, 16)); assertEquals(calendar.businessDates(time1, time2), @@ -140,9 +140,9 @@ public void testBusinessCalendarMethods() { assertEquals(calendar.diffBusinessNanos(time1, time2), StaticCalendarMethods.diffBusinessNanos(time1, time2)); assertEquals(calendar.diffNonBusinessNanos(time1, time2), StaticCalendarMethods.diffNonBusinessNanos(time1, time2)); - assertEquals(calendar.diffBusinessDay(time1, time2), StaticCalendarMethods.diffBusinessDay(time1, time2)); - assertEquals(calendar.diffNonBusinessDay(time1, time2), StaticCalendarMethods.diffNonBusinessDay(time1, time2)); - assertEquals(calendar.diffBusinessYear(time1, time2), StaticCalendarMethods.diffBusinessYear(time1, time2)); + assertEquals(calendar.diffBusinessDays(time1, time2), StaticCalendarMethods.diffBusinessDay(time1, time2)); + assertEquals(calendar.diffNonBusinessDays(time1, time2), StaticCalendarMethods.diffNonBusinessDay(time1, time2)); + assertEquals(calendar.diffBusinessYears(time1, time2), StaticCalendarMethods.diffBusinessYear(time1, time2)); assertEquals(calendar.numberOfBusinessDays(time1, time2), @@ -187,9 +187,9 @@ public void testBusinessCalendarMethods() { assertEquals(calendar.isLastBusinessDayOfWeek(time1), StaticCalendarMethods.isLastBusinessDayOfWeek(time1)); assertEquals(calendar.isLastBusinessDayOfWeek(date1), StaticCalendarMethods.isLastBusinessDayOfWeek(date1)); - assertEquals(calendar.getBusinessSchedule(time1), StaticCalendarMethods.getBusinessSchedule(time1)); - assertEquals(calendar.getBusinessSchedule(date1), StaticCalendarMethods.getBusinessSchedule(date1)); - assertEquals(calendar.getBusinessSchedule(LocalDate.now()), + assertEquals(calendar.businessSchedule(time1), StaticCalendarMethods.getBusinessSchedule(time1)); + assertEquals(calendar.businessSchedule(date1), StaticCalendarMethods.getBusinessSchedule(date1)); + assertEquals(calendar.businessSchedule(LocalDate.now()), StaticCalendarMethods.getBusinessSchedule(LocalDate.now())); } } diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java index 32b738159a8..daf4434e29f 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java @@ -573,117 +573,117 @@ public void testIsBusinessDayString() { } public void testNextBusinessDay() { - assertEquals("2017-09-28", test.nextBusinessDay()); - assertEquals("2017-09-29", test.nextBusinessDay(2)); - assertEquals("2017-10-17", test.nextBusinessDay(14)); + assertEquals("2017-09-28", test.futureBusinessDate()); + assertEquals("2017-09-29", test.futureBusinessDate(2)); + assertEquals("2017-10-17", test.futureBusinessDate(14)); Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); Instant day1JP = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); String day2 = "2016-09-01"; - assertNull(USNYSE.nextBusinessDay((Instant) null)); - assertEquals(USNYSE.nextBusinessDay(day1), day2); - assertEquals(JPOSE.nextBusinessDay(day1JP), day2); + assertNull(USNYSE.futureBusinessDate((Instant) null)); + assertEquals(USNYSE.futureBusinessDate(day1), day2); + assertEquals(JPOSE.futureBusinessDate(day1JP), day2); - assertNull(USNYSE.nextBusinessDay((Instant) null, 2)); - assertEquals(USNYSE.nextBusinessDay(day1, 2), "2016-09-02"); - assertEquals(JPOSE.nextBusinessDay(day1JP, 2), "2016-09-02"); + assertNull(USNYSE.futureBusinessDate((Instant) null, 2)); + assertEquals(USNYSE.futureBusinessDate(day1, 2), "2016-09-02"); + assertEquals(JPOSE.futureBusinessDate(day1JP, 2), "2016-09-02"); - assertEquals(USNYSE.nextBusinessDay(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 NY"), -2), + assertEquals(USNYSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 NY"), -2), "2016-08-31"); - assertEquals(JPOSE.nextBusinessDay(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 JP"), -2), + assertEquals(JPOSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 JP"), -2), "2016-08-31"); - assertEquals(USNYSE.nextBusinessDay(DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"), 0), + assertEquals(USNYSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"), 0), "2016-08-30"); - assertNull(USNYSE.nextBusinessDay(DateTimeUtils.parseInstant("2016-08-28T01:00:00.000000000 NY"), 0)); + assertNull(USNYSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-08-28T01:00:00.000000000 NY"), 0)); // leap day day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); day1JP = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 JP"); day2 = "2016-02-29"; - assertEquals(USNYSE.nextBusinessDay(day1), day2); - assertEquals(JPOSE.nextBusinessDay(day1JP), day2); + assertEquals(USNYSE.futureBusinessDate(day1), day2); + assertEquals(JPOSE.futureBusinessDate(day1JP), day2); // new year day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); day1JP = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 JP"); day2 = "2014-01-02"; - assertEquals(USNYSE.nextBusinessDay(day1), day2); + assertEquals(USNYSE.futureBusinessDate(day1), day2); day2 = "2014-01-01"; - assertEquals(JPOSE.nextBusinessDay(day1JP), day2); + assertEquals(JPOSE.futureBusinessDate(day1JP), day2); // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 // Japan doesn't observe day light savings day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); day1JP = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); day2 = "2017-03-13"; - assertEquals(USNYSE.nextBusinessDay(day1), day2); - assertEquals(JPOSE.nextBusinessDay(day1JP), day2); + assertEquals(USNYSE.futureBusinessDate(day1), day2); + assertEquals(JPOSE.futureBusinessDate(day1JP), day2); // outside calendar range, so no day off for new years, but weekend should still be off day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); day1JP = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 JP"); day2 = "2070-01-01"; - assertEquals(USNYSE.nextBusinessDay(day1).compareTo(day2), 0); - assertEquals(JPOSE.nextBusinessDay(day1JP), day2); + assertEquals(USNYSE.futureBusinessDate(day1).compareTo(day2), 0); + assertEquals(JPOSE.futureBusinessDate(day1JP), day2); day1 = DateTimeUtils.parseInstant("2070-01-03T01:00:00.000000000 NY"); day1JP = DateTimeUtils.parseInstant("2070-01-03T01:00:00.000000000 JP"); day2 = "2070-01-06"; - assertEquals(USNYSE.nextBusinessDay(day1), day2); - assertEquals(JPOSE.nextBusinessDay(day1JP), day2); + assertEquals(USNYSE.futureBusinessDate(day1), day2); + assertEquals(JPOSE.futureBusinessDate(day1JP), day2); day1 = null; - assertNull(USNYSE.nextBusinessDay(day1)); - assertNull(JPOSE.nextBusinessDay(day1)); + assertNull(USNYSE.futureBusinessDate(day1)); + assertNull(JPOSE.futureBusinessDate(day1)); } public void testNextBusinessDayString() { String day1 = "2016-08-31"; String day2 = "2016-09-01"; - assertNull(USNYSE.nextBusinessDay((String) null)); - assertEquals(USNYSE.nextBusinessDay(day1), day2); - assertEquals(JPOSE.nextBusinessDay(day1), day2); + assertNull(USNYSE.futureBusinessDate((String) null)); + assertEquals(USNYSE.futureBusinessDate(day1), day2); + assertEquals(JPOSE.futureBusinessDate(day1), day2); - assertNull(USNYSE.nextBusinessDay((String) null, 2)); - assertEquals(USNYSE.nextBusinessDay(day1, 2), "2016-09-02"); - assertEquals(JPOSE.nextBusinessDay(day1, 2), "2016-09-02"); + assertNull(USNYSE.futureBusinessDate((String) null, 2)); + assertEquals(USNYSE.futureBusinessDate(day1, 2), "2016-09-02"); + assertEquals(JPOSE.futureBusinessDate(day1, 2), "2016-09-02"); - assertEquals(USNYSE.nextBusinessDay("2016-09-02", -2), "2016-08-31"); - assertEquals(JPOSE.nextBusinessDay("2016-09-02", -2), "2016-08-31"); + assertEquals(USNYSE.futureBusinessDate("2016-09-02", -2), "2016-08-31"); + assertEquals(JPOSE.futureBusinessDate("2016-09-02", -2), "2016-08-31"); - assertEquals(USNYSE.nextBusinessDay("2016-08-30", 0), "2016-08-30"); - assertNull(USNYSE.nextBusinessDay("2016-08-28", 0)); + assertEquals(USNYSE.futureBusinessDate("2016-08-30", 0), "2016-08-30"); + assertNull(USNYSE.futureBusinessDate("2016-08-28", 0)); // leap day day1 = "2016-02-28"; day2 = "2016-02-29"; - assertEquals(USNYSE.nextBusinessDay(day1), day2); - assertEquals(JPOSE.nextBusinessDay(day1), day2); + assertEquals(USNYSE.futureBusinessDate(day1), day2); + assertEquals(JPOSE.futureBusinessDate(day1), day2); // new year day1 = "2013-12-31"; day2 = "2014-01-02"; - assertEquals(USNYSE.nextBusinessDay(day1), day2); + assertEquals(USNYSE.futureBusinessDate(day1), day2); day1 = "2007-01-01"; day2 = "2007-01-04"; - assertEquals(JPOSE.nextBusinessDay(day1), day2); + assertEquals(JPOSE.futureBusinessDate(day1), day2); // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 day1 = "2017-03-12"; day2 = "2017-03-13"; - assertEquals(USNYSE.nextBusinessDay(day1), day2); - assertEquals(JPOSE.nextBusinessDay(day1), day2); + assertEquals(USNYSE.futureBusinessDate(day1), day2); + assertEquals(JPOSE.futureBusinessDate(day1), day2); day1 = null; - assertNull(USNYSE.nextBusinessDay(day1)); - assertNull(JPOSE.nextBusinessDay(day1)); + assertNull(USNYSE.futureBusinessDate(day1)); + assertNull(JPOSE.futureBusinessDate(day1)); // incorrectly formatted days try { - USNYSE.nextBusinessDay("2018-09-31"); + USNYSE.futureBusinessDate("2018-09-31"); fail(); } catch (IllegalArgumentException e) { // ok @@ -729,7 +729,7 @@ public void testNextBusinessSchedule() { day1JP = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 JP"); day2 = "2014-01-03"; assertEquals( - DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(USNYSE.nextBusinessDay(day1)).getSOBD(), TZ_NY), + DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(USNYSE.futureBusinessDate(day1)).getSOBD(), TZ_NY), day2); day2 = "2014-01-01"; @@ -762,7 +762,7 @@ public void testNextBusinessSchedule() { // holiday - final BusinessSchedule holiday = USNYSE.getBusinessSchedule("2017-12-25"); + final BusinessSchedule holiday = USNYSE.businessSchedule("2017-12-25"); assertEquals(0, holiday.getBusinessPeriods().length); assertEquals(0, holiday.getLengthOfBusinessDay()); try { @@ -826,106 +826,106 @@ public void testNextBusinessScheduleString() { } public void testNextNonBusinessDay() { - assertEquals("2017-09-30", test.nextNonBusinessDay()); - assertEquals("2017-10-01", test.nextNonBusinessDay(2)); - assertEquals("2017-10-08", test.nextNonBusinessDay(4)); + assertEquals("2017-09-30", test.futureNonBusinessDate()); + assertEquals("2017-10-01", test.futureNonBusinessDate(2)); + assertEquals("2017-10-08", test.futureNonBusinessDate(4)); Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); Instant day1JP = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); String day2 = "2016-09-03"; - assertNull(USNYSE.nextNonBusinessDay((Instant) null)); - assertEquals(USNYSE.nextNonBusinessDay(day1), day2); - assertEquals(JPOSE.nextNonBusinessDay(day1JP), day2); + assertNull(USNYSE.futureNonBusinessDate((Instant) null)); + assertEquals(USNYSE.futureNonBusinessDate(day1), day2); + assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); - assertNull(USNYSE.nextNonBusinessDay((Instant) null, 2)); - assertEquals(USNYSE.nextNonBusinessDay(day1, 2), "2016-09-04"); - assertEquals(JPOSE.nextNonBusinessDay(day1JP, 2), "2016-09-04"); + assertNull(USNYSE.futureNonBusinessDate((Instant) null, 2)); + assertEquals(USNYSE.futureNonBusinessDate(day1, 2), "2016-09-04"); + assertEquals(JPOSE.futureNonBusinessDate(day1JP, 2), "2016-09-04"); - assertEquals(USNYSE.nextNonBusinessDay(DateTimeUtils.parseInstant("2016-09-04T01:00:00.000000000 NY"), -2), + assertEquals(USNYSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-09-04T01:00:00.000000000 NY"), -2), "2016-08-28"); - assertEquals(JPOSE.nextNonBusinessDay(DateTimeUtils.parseInstant("2016-09-04T01:00:00.000000000 JP"), -2), + assertEquals(JPOSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-09-04T01:00:00.000000000 JP"), -2), "2016-08-28"); - assertNull(USNYSE.nextNonBusinessDay(DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"), 0)); - assertEquals(USNYSE.nextNonBusinessDay(DateTimeUtils.parseInstant("2016-08-28T01:00:00.000000000 NY"), 0), + assertNull(USNYSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"), 0)); + assertEquals(USNYSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-08-28T01:00:00.000000000 NY"), 0), "2016-08-28"); // leap day day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); day1JP = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 JP"); day2 = "2016-03-05"; - assertEquals(USNYSE.nextNonBusinessDay(day1), day2); - assertEquals(JPOSE.nextNonBusinessDay(day1JP), day2); + assertEquals(USNYSE.futureNonBusinessDate(day1), day2); + assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); // new year day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); day1JP = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 JP"); day2 = "2014-01-01"; - assertEquals(USNYSE.nextNonBusinessDay(day1), day2); + assertEquals(USNYSE.futureNonBusinessDate(day1), day2); day2 = "2014-01-04"; - assertEquals(JPOSE.nextNonBusinessDay(day1JP), day2); + assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); day1JP = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); day2 = "2017-03-18"; - assertEquals(USNYSE.nextNonBusinessDay(day1), day2); - assertEquals(JPOSE.nextNonBusinessDay(day1JP), day2); + assertEquals(USNYSE.futureNonBusinessDate(day1), day2); + assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); // outside calendar range, so no day off for new years, but weekend should still be off day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); day1JP = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 JP"); day2 = "2070-01-04"; - assertEquals(USNYSE.nextNonBusinessDay(day1).compareTo(day2), 0); - assertEquals(JPOSE.nextNonBusinessDay(day1JP), day2); + assertEquals(USNYSE.futureNonBusinessDate(day1).compareTo(day2), 0); + assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); day1 = null; - assertNull(USNYSE.nextNonBusinessDay(day1)); - assertNull(JPOSE.nextNonBusinessDay(day1)); + assertNull(USNYSE.futureNonBusinessDate(day1)); + assertNull(JPOSE.futureNonBusinessDate(day1)); } public void testNextNonBusinessDayString() { String day1 = "2016-08-31"; String day2 = "2016-09-03"; - assertNull(USNYSE.nextNonBusinessDay((String) null)); - assertEquals(USNYSE.nextNonBusinessDay(day1), day2); - assertEquals(JPOSE.nextNonBusinessDay(day1), day2); + assertNull(USNYSE.futureNonBusinessDate((String) null)); + assertEquals(USNYSE.futureNonBusinessDate(day1), day2); + assertEquals(JPOSE.futureNonBusinessDate(day1), day2); - assertNull(USNYSE.nextNonBusinessDay((String) null, 2)); - assertEquals(USNYSE.nextNonBusinessDay(day1, 2), "2016-09-04"); - assertEquals(JPOSE.nextNonBusinessDay(day1, 2), "2016-09-04"); + assertNull(USNYSE.futureNonBusinessDate((String) null, 2)); + assertEquals(USNYSE.futureNonBusinessDate(day1, 2), "2016-09-04"); + assertEquals(JPOSE.futureNonBusinessDate(day1, 2), "2016-09-04"); - assertEquals(USNYSE.nextNonBusinessDay("2016-09-04", -2), "2016-08-28"); - assertEquals(JPOSE.nextNonBusinessDay("2016-09-04", -2), "2016-08-28"); + assertEquals(USNYSE.futureNonBusinessDate("2016-09-04", -2), "2016-08-28"); + assertEquals(JPOSE.futureNonBusinessDate("2016-09-04", -2), "2016-08-28"); - assertNull(USNYSE.nextNonBusinessDay("2016-08-30", 0)); - assertEquals(USNYSE.nextNonBusinessDay("2016-08-28", 0), "2016-08-28"); + assertNull(USNYSE.futureNonBusinessDate("2016-08-30", 0)); + assertEquals(USNYSE.futureNonBusinessDate("2016-08-28", 0), "2016-08-28"); // leap day day1 = "2016-02-28"; day2 = "2016-03-05"; - assertEquals(USNYSE.nextNonBusinessDay(day1), day2); - assertEquals(JPOSE.nextNonBusinessDay(day1), day2); + assertEquals(USNYSE.futureNonBusinessDate(day1), day2); + assertEquals(JPOSE.futureNonBusinessDate(day1), day2); // new year day1 = "2013-12-31"; day2 = "2014-01-01"; - assertEquals(USNYSE.nextNonBusinessDay(day1), day2); + assertEquals(USNYSE.futureNonBusinessDate(day1), day2); // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 day1 = "2017-03-12"; day2 = "2017-03-18"; - assertEquals(USNYSE.nextNonBusinessDay(day1), day2); - assertEquals(JPOSE.nextNonBusinessDay(day1), day2); + assertEquals(USNYSE.futureNonBusinessDate(day1), day2); + assertEquals(JPOSE.futureNonBusinessDate(day1), day2); day1 = null; - assertNull(USNYSE.nextNonBusinessDay(day1)); - assertNull(JPOSE.nextNonBusinessDay(day1)); + assertNull(USNYSE.futureNonBusinessDate(day1)); + assertNull(JPOSE.futureNonBusinessDate(day1)); // incorrectly formatted days try { - USNYSE.nextNonBusinessDay("2018-09-31"); + USNYSE.futureNonBusinessDate("2018-09-31"); fail(); } catch (IllegalArgumentException e) { // ok @@ -933,131 +933,131 @@ public void testNextNonBusinessDayString() { } public void testLastBusinessDay() { - assertEquals("2017-09-26", test.previousBusinessDay()); - assertEquals("2017-09-25", test.previousBusinessDay(2)); - assertEquals("2017-09-07", test.previousBusinessDay(14)); + assertEquals("2017-09-26", test.pastBusinessDate()); + assertEquals("2017-09-25", test.pastBusinessDate(2)); + assertEquals("2017-09-07", test.pastBusinessDate(14)); - assertEquals("2017-09-24", test.previousNonBusinessDay()); - assertEquals("2017-09-23", test.previousNonBusinessDay(2)); - assertEquals("2017-09-16", test.previousNonBusinessDay(4)); + assertEquals("2017-09-24", test.pastNonBusinessDate()); + assertEquals("2017-09-23", test.pastNonBusinessDate(2)); + assertEquals("2017-09-16", test.pastNonBusinessDate(4)); Instant day1 = DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"); Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); - assertNull(USNYSE.previousBusinessDay((Instant) null, 2)); - assertEquals(USNYSE.previousBusinessDay(day2, 2), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(USNYSE.previousBusinessDay(day1, -2), DateTimeUtils.formatDate(day2, TZ_NY)); + assertNull(USNYSE.pastBusinessDate((Instant) null, 2)); + assertEquals(USNYSE.pastBusinessDate(day2, 2), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(USNYSE.pastBusinessDate(day1, -2), DateTimeUtils.formatDate(day2, TZ_NY)); - assertEquals(USNYSE.previousBusinessDay(DateTimeUtils.parseInstant("2016-08-30T15:00:00.000000000 NY"), 0), + assertEquals(USNYSE.pastBusinessDate(DateTimeUtils.parseInstant("2016-08-30T15:00:00.000000000 NY"), 0), "2016-08-30"); - assertNull(USNYSE.previousBusinessDay(DateTimeUtils.parseInstant("2016-08-28T15:00:00.000000000 NY"), 0)); + assertNull(USNYSE.pastBusinessDate(DateTimeUtils.parseInstant("2016-08-28T15:00:00.000000000 NY"), 0)); - assertNull(USNYSE.previousNonBusinessDay((Instant) null, 0)); - assertNull(USNYSE.previousNonBusinessDay(DateTimeUtils.parseInstant("2016-08-30T21:00:00.000000000 NY"), 0)); + assertNull(USNYSE.pastNonBusinessDate((Instant) null, 0)); + assertNull(USNYSE.pastNonBusinessDate(DateTimeUtils.parseInstant("2016-08-30T21:00:00.000000000 NY"), 0)); assertEquals( - USNYSE.previousNonBusinessDay(DateTimeUtils.parseInstant("2016-08-28T21:00:00.000000000 NY"), 0), + USNYSE.pastNonBusinessDate(DateTimeUtils.parseInstant("2016-08-28T21:00:00.000000000 NY"), 0), "2016-08-28"); // leap day day1 = DateTimeUtils.parseInstant("2016-02-29T21:00:00.000000000 NY"); day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 NY"); - assertEquals(USNYSE.previousBusinessDay(day2), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(USNYSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); // new year day1 = DateTimeUtils.parseInstant("2013-12-26T01:00:00.000000000 NY"); day2 = DateTimeUtils.parseInstant("2014-01-02T01:00:00.000000000 NY"); - assertEquals(USNYSE.previousBusinessDay(day2, 4), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(USNYSE.previousBusinessDay(day1, -4), DateTimeUtils.formatDate(day2, TZ_NY)); + assertEquals(USNYSE.pastBusinessDate(day2, 4), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(USNYSE.pastBusinessDate(day1, -4), DateTimeUtils.formatDate(day2, TZ_NY)); // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 day1 = DateTimeUtils.parseInstant("2017-02-26T01:00:00.000000000 NY"); day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 NY"); - assertEquals(USNYSE.previousNonBusinessDay(day2, 5), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(USNYSE.previousNonBusinessDay(day1, -5), "2017-03-18"); + assertEquals(USNYSE.pastNonBusinessDate(day2, 5), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(USNYSE.pastNonBusinessDate(day1, -5), "2017-03-18"); day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 NY"); - assertEquals(USNYSE.previousNonBusinessDay(day2), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(USNYSE.pastNonBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); day1 = DateTimeUtils.parseInstant("2017-07-04T01:00:00.000000000 NY"); day2 = DateTimeUtils.parseInstant("2017-07-07T01:00:00.000000000 NY"); - assertEquals(USNYSE.previousNonBusinessDay(day2), DateTimeUtils.formatDate(day1, TZ_NY)); + assertEquals(USNYSE.pastNonBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); day1 = null; - assertNull(USNYSE.previousBusinessDay(day1)); - assertNull(USNYSE.previousNonBusinessDay(day1)); + assertNull(USNYSE.pastBusinessDate(day1)); + assertNull(USNYSE.pastNonBusinessDate(day1)); day1 = DateTimeUtils.parseInstant("2016-08-31T21:00:00.000000000 JP"); day2 = DateTimeUtils.parseInstant("2016-09-01T21:00:00.000000000 JP"); - assertEquals(JPOSE.previousBusinessDay(day2), DateTimeUtils.formatDate(day1, TZ_JP)); + assertEquals(JPOSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); // leap day day1 = DateTimeUtils.parseInstant("2016-02-29T01:00:00.000000000 JP"); day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 JP"); - assertEquals(JPOSE.previousBusinessDay(day2), DateTimeUtils.formatDate(day1, TZ_JP)); + assertEquals(JPOSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); // new year day1 = DateTimeUtils.parseInstant("2013-12-31T11:00:00.000000000 JP"); day2 = DateTimeUtils.parseInstant("2014-01-01T11:00:00.000000000 JP"); - assertEquals(JPOSE.previousBusinessDay(day2), DateTimeUtils.formatDate(day1, TZ_JP)); + assertEquals(JPOSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); // Daylight savings starts in JP (UTC-7:00) at 2 AM 2017-03-12 day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 JP"); - assertEquals(JPOSE.previousNonBusinessDay(day2), DateTimeUtils.formatDate(day1, TZ_JP)); + assertEquals(JPOSE.pastNonBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); day1 = null; - assertNull(JPOSE.previousBusinessDay(day1)); - assertNull(JPOSE.previousNonBusinessDay(day1)); + assertNull(JPOSE.pastBusinessDate(day1)); + assertNull(JPOSE.pastNonBusinessDate(day1)); } public void testLastBusinessDayString() { String day1 = "2016-08-31"; String day2 = "2016-09-01"; - assertNull(USNYSE.previousBusinessDay((String) null)); - assertEquals(USNYSE.previousBusinessDay(day2), day1); - assertEquals(JPOSE.previousBusinessDay(day2), day1); + assertNull(USNYSE.pastBusinessDate((String) null)); + assertEquals(USNYSE.pastBusinessDate(day2), day1); + assertEquals(JPOSE.pastBusinessDate(day2), day1); - assertNull(USNYSE.previousBusinessDay((String) null, 2)); - assertEquals(USNYSE.previousBusinessDay("2016-08-30", 0), "2016-08-30"); - assertNull(USNYSE.previousBusinessDay("2016-08-28", 0)); + assertNull(USNYSE.pastBusinessDate((String) null, 2)); + assertEquals(USNYSE.pastBusinessDate("2016-08-30", 0), "2016-08-30"); + assertNull(USNYSE.pastBusinessDate("2016-08-28", 0)); day1 = "2016-08-29"; - assertEquals(USNYSE.previousBusinessDay(day2, 3), day1); - assertEquals(JPOSE.previousBusinessDay(day2, 3), day1); - assertEquals(USNYSE.previousBusinessDay(day1, -3), day2); - assertEquals(JPOSE.previousBusinessDay(day1, -3), day2); + assertEquals(USNYSE.pastBusinessDate(day2, 3), day1); + assertEquals(JPOSE.pastBusinessDate(day2, 3), day1); + assertEquals(USNYSE.pastBusinessDate(day1, -3), day2); + assertEquals(JPOSE.pastBusinessDate(day1, -3), day2); // leap day day1 = "2016-02-29"; day2 = "2016-03-01"; - assertEquals(USNYSE.previousBusinessDay(day2), day1); - assertEquals(JPOSE.previousBusinessDay(day2), day1); + assertEquals(USNYSE.pastBusinessDate(day2), day1); + assertEquals(JPOSE.pastBusinessDate(day2), day1); // new year day1 = "2013-12-30"; day2 = "2014-01-01"; - assertEquals(USNYSE.previousBusinessDay(day2, 2), day1); - assertEquals(JPOSE.previousBusinessDay(day2, 2), day1); - assertEquals(USNYSE.previousBusinessDay(day1, -2), "2014-01-02"); - assertEquals(JPOSE.previousBusinessDay(day1, -2), day2); + assertEquals(USNYSE.pastBusinessDate(day2, 2), day1); + assertEquals(JPOSE.pastBusinessDate(day2, 2), day1); + assertEquals(USNYSE.pastBusinessDate(day1, -2), "2014-01-02"); + assertEquals(JPOSE.pastBusinessDate(day1, -2), day2); // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 day1 = "2017-03-10"; day2 = "2017-03-13"; - assertEquals(USNYSE.previousBusinessDay(day2), day1); - assertEquals(JPOSE.previousBusinessDay(day2), day1); + assertEquals(USNYSE.pastBusinessDate(day2), day1); + assertEquals(JPOSE.pastBusinessDate(day2), day1); day1 = null; - assertNull(USNYSE.previousBusinessDay(day1)); - assertNull(JPOSE.previousBusinessDay(day1)); + assertNull(USNYSE.pastBusinessDate(day1)); + assertNull(JPOSE.pastBusinessDate(day1)); // incorrectly formatted days try { - USNYSE.previousBusinessDay("2018-09-31"); + USNYSE.pastBusinessDate("2018-09-31"); fail(); } catch (IllegalArgumentException e) { // ok @@ -1181,43 +1181,43 @@ public void testLastBusinessScheduleString() { public void testLastNonBusinessDayString() { String day1 = "2016-08-28"; String day2 = "2016-09-01"; - assertNull(USNYSE.previousNonBusinessDay((String) null)); - assertEquals(USNYSE.previousNonBusinessDay(day2), day1); - assertEquals(JPOSE.previousNonBusinessDay(day2), day1); + assertNull(USNYSE.pastNonBusinessDate((String) null)); + assertEquals(USNYSE.pastNonBusinessDate(day2), day1); + assertEquals(JPOSE.pastNonBusinessDate(day2), day1); - assertNull(USNYSE.previousNonBusinessDay((String) null, 2)); - assertNull(USNYSE.previousNonBusinessDay("2016-08-30", 0)); - assertEquals(USNYSE.previousNonBusinessDay("2016-08-28", 0), "2016-08-28"); + assertNull(USNYSE.pastNonBusinessDate((String) null, 2)); + assertNull(USNYSE.pastNonBusinessDate("2016-08-30", 0)); + assertEquals(USNYSE.pastNonBusinessDate("2016-08-28", 0), "2016-08-28"); // leap day day1 = "2016-02-27"; day2 = "2016-03-01"; - assertEquals(USNYSE.previousNonBusinessDay(day2, 2), day1); - assertEquals(JPOSE.previousNonBusinessDay(day2, 2), day1); - assertEquals(USNYSE.previousNonBusinessDay(day1, -2), "2016-03-05"); - assertEquals(JPOSE.previousNonBusinessDay(day1, -2), "2016-03-05"); + assertEquals(USNYSE.pastNonBusinessDate(day2, 2), day1); + assertEquals(JPOSE.pastNonBusinessDate(day2, 2), day1); + assertEquals(USNYSE.pastNonBusinessDate(day1, -2), "2016-03-05"); + assertEquals(JPOSE.pastNonBusinessDate(day1, -2), "2016-03-05"); // new year day1 = "2013-12-29"; day2 = "2014-01-01"; - assertEquals(USNYSE.previousNonBusinessDay(day2), day1); - assertEquals(JPOSE.previousNonBusinessDay(day2), day1); + assertEquals(USNYSE.pastNonBusinessDate(day2), day1); + assertEquals(JPOSE.pastNonBusinessDate(day2), day1); // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 day1 = "2017-03-05"; day2 = "2017-03-13"; - assertEquals(USNYSE.previousNonBusinessDay(day2, 3), day1); - assertEquals(JPOSE.previousNonBusinessDay(day2, 3), day1); - assertEquals(USNYSE.previousNonBusinessDay(day1, -3), "2017-03-18"); - assertEquals(JPOSE.previousNonBusinessDay(day1, -3), "2017-03-18"); + assertEquals(USNYSE.pastNonBusinessDate(day2, 3), day1); + assertEquals(JPOSE.pastNonBusinessDate(day2, 3), day1); + assertEquals(USNYSE.pastNonBusinessDate(day1, -3), "2017-03-18"); + assertEquals(JPOSE.pastNonBusinessDate(day1, -3), "2017-03-18"); day1 = null; - assertNull(USNYSE.previousNonBusinessDay(day1)); - assertNull(JPOSE.previousNonBusinessDay(day1)); + assertNull(USNYSE.pastNonBusinessDate(day1)); + assertNull(JPOSE.pastNonBusinessDate(day1)); // incorrectly formatted days try { - USNYSE.previousNonBusinessDay("2018-09-31"); + USNYSE.pastNonBusinessDate("2018-09-31"); fail(); } catch (IllegalArgumentException e) { // ok @@ -1238,17 +1238,17 @@ public void testBusinessTimeDiff() { // standard business day Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); - assertEquals(USNYSE.diffBusinessDay(day1, day2), 1.0); - assertEquals(JPOSE.diffBusinessDay(day1, day2), 1.0); + assertEquals(USNYSE.diffBusinessDays(day1, day2), 1.0); + assertEquals(JPOSE.diffBusinessDays(day1, day2), 1.0); // 2.5 standard business days day1 = DateTimeUtils.parseInstant("2017-01-23T01:00:00.000000000 NY"); day2 = DateTimeUtils.parseInstant("2017-01-25T12:45:00.000000000 NY"); - assertEquals(USNYSE.diffBusinessDay(day1, day2), 2.5); + assertEquals(USNYSE.diffBusinessDays(day1, day2), 2.5); day1 = DateTimeUtils.parseInstant("2017-01-23T01:00:00.000000000 JP"); day2 = DateTimeUtils.parseInstant("2017-01-25T12:45:00.000000000 JP"); - assertEquals(JPOSE.diffBusinessDay(day1, day2), 2.55); + assertEquals(JPOSE.diffBusinessDays(day1, day2), 2.55); // middle of a business period day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); @@ -1268,37 +1268,37 @@ public void testBusinessTimeDiff() { // weekend non business day1 = DateTimeUtils.parseInstant("2017-01-21T01:00:00.000000000 NY"); day2 = DateTimeUtils.parseInstant("2017-01-23T01:00:00.000000000 NY"); - assertEquals(USNYSE.diffBusinessDay(day1, day2), 0.0); + assertEquals(USNYSE.diffBusinessDays(day1, day2), 0.0); // one business year day1 = DateTimeUtils.parseInstant("2016-01-01T01:00:00.000000000 NY"); day2 = DateTimeUtils.parseInstant("2016-12-31T23:59:00.000000000 NY"); - double yearDiff = USNYSE.diffBusinessYear(day1, day2); + double yearDiff = USNYSE.diffBusinessYears(day1, day2); assertTrue(yearDiff < 1.004); assertTrue(yearDiff > 0.996); - yearDiff = JPOSE.diffBusinessYear(day1, day2); + yearDiff = JPOSE.diffBusinessYears(day1, day2); assertTrue(yearDiff < 1.004); assertTrue(yearDiff > 0.996); // half year day1 = DateTimeUtils.parseInstant("2017-01-01T01:00:00.000000000 NY"); day2 = DateTimeUtils.parseInstant("2017-07-02T01:00:00.000000000 NY"); - yearDiff = USNYSE.diffBusinessYear(day1, day2); + yearDiff = USNYSE.diffBusinessYears(day1, day2); assertTrue(yearDiff < 0.503); assertTrue(yearDiff > 0.497); - yearDiff = JPOSE.diffBusinessYear(day1, day2); + yearDiff = JPOSE.diffBusinessYears(day1, day2); assertTrue(yearDiff < 0.503); assertTrue(yearDiff > 0.497); day1 = null; - assertEquals(USNYSE.diffBusinessYear(day1, day2), QueryConstants.NULL_DOUBLE); - assertEquals(USNYSE.diffBusinessDay(day1, day2), QueryConstants.NULL_DOUBLE); + assertEquals(USNYSE.diffBusinessYears(day1, day2), QueryConstants.NULL_DOUBLE); + assertEquals(USNYSE.diffBusinessDays(day1, day2), QueryConstants.NULL_DOUBLE); assertEquals(USNYSE.diffBusinessNanos(day1, day2), QueryConstants.NULL_LONG); day1 = day2; - assertEquals(USNYSE.diffBusinessYear(day1, day2), 0.0); - assertEquals(USNYSE.diffBusinessDay(day1, day2), 0.0); + assertEquals(USNYSE.diffBusinessYears(day1, day2), 0.0); + assertEquals(USNYSE.diffBusinessDays(day1, day2), 0.0); assertEquals(USNYSE.diffBusinessNanos(day1, day2), 0); } @@ -1335,7 +1335,7 @@ public void testNonBusinessTimeDiff() { day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); day2 = DateTimeUtils.parseInstant("2017-01-23T16:00:00.000000000 JP"); assertEquals(JPOSE.diffNonBusinessNanos(day1, day2), 2 * DateTimeUtils.HOUR); - assertEquals(JPOSE.diffNonBusinessDay(day1, day2), + assertEquals(JPOSE.diffNonBusinessDays(day1, day2), ((double) (2 * DateTimeUtils.HOUR)) / (double) JPOSE.standardBusinessDayLengthNanos()); @@ -1347,7 +1347,7 @@ public void testNonBusinessTimeDiff() { assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), 0); day1 = null; - assertEquals(USNYSE.diffNonBusinessDay(day1, day2), QueryConstants.NULL_DOUBLE); + assertEquals(USNYSE.diffNonBusinessDays(day1, day2), QueryConstants.NULL_DOUBLE); } public void testBusinessDateRange() { @@ -1624,12 +1624,12 @@ public void testCurrentBusinessSchedule() { public void testMidnightClose() { assertEquals(DateTimeUtils.DAY, UTC.standardBusinessDayLengthNanos()); assertEquals("2019-04-16", UTC.futureDate("2019-04-15")); - assertEquals("2019-04-16", UTC.nextBusinessDay("2019-04-15")); - assertEquals("2019-04-18", UTC.nextBusinessDay("2019-04-15", 3)); + assertEquals("2019-04-16", UTC.futureBusinessDate("2019-04-15")); + assertEquals("2019-04-18", UTC.futureBusinessDate("2019-04-15", 3)); assertEquals("2019-08-19", - UTC.nextBusinessDay(DateTimeUtils.parseInstant("2019-08-18T00:00:00.000000000 UTC"))); + UTC.futureBusinessDate(DateTimeUtils.parseInstant("2019-08-18T00:00:00.000000000 UTC"))); - assertEquals("2019-05-16", DateTimeUtils.formatDate(UTC.getBusinessSchedule("2019-05-16").getSOBD(), TZ_UTC)); - assertEquals("2019-05-17", DateTimeUtils.formatDate(UTC.getBusinessSchedule("2019-05-16").getEOBD(), TZ_UTC)); + assertEquals("2019-05-16", DateTimeUtils.formatDate(UTC.businessSchedule("2019-05-16").getSOBD(), TZ_UTC)); + assertEquals("2019-05-17", DateTimeUtils.formatDate(UTC.businessSchedule("2019-05-16").getEOBD(), TZ_UTC)); } } diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java index 5f49b464c0a..28f73aeca37 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java @@ -122,37 +122,37 @@ public void testInstance() { public void testNonBusinessDayMethods() { try { - noNonBusinessDays.previousNonBusinessDay(); + noNonBusinessDays.pastNonBusinessDate(); fail(); } catch (UnsupportedOperationException e) { // ok } try { - noNonBusinessDays.previousNonBusinessDay(1); + noNonBusinessDays.pastNonBusinessDate(1); fail(); } catch (UnsupportedOperationException e) { // ok } try { - noNonBusinessDays.previousNonBusinessDay("20190626"); + noNonBusinessDays.pastNonBusinessDate("20190626"); fail(); } catch (UnsupportedOperationException e) { // ok } try { - noNonBusinessDays.nextNonBusinessDay(); + noNonBusinessDays.futureNonBusinessDate(); fail(); } catch (UnsupportedOperationException e) { // ok } try { - noNonBusinessDays.nextNonBusinessDay(1); + noNonBusinessDays.futureNonBusinessDate(1); fail(); } catch (UnsupportedOperationException e) { // ok } try { - noNonBusinessDays.nextNonBusinessDay("20190626"); + noNonBusinessDays.futureNonBusinessDate("20190626"); fail(); } catch (UnsupportedOperationException e) { // ok @@ -171,9 +171,9 @@ public void testNonBusinessDayMethods() { assertEquals(noNonBusinessDays.timeZone(), TZ_NY); assertEquals(noNonBusinessDays.standardBusinessDayLengthNanos(), 6 * DateTimeUtils.HOUR + (30 * DateTimeUtils.MINUTE)); - assertEquals(noNonBusinessDays.getBusinessSchedule("2019-06-26").getSOBD(), - onlyWeekends.getBusinessSchedule("2019-06-26").getSOBD()); - assertEquals(noNonBusinessDays.getBusinessSchedule("2019-06-26").getEOBD(), - onlyWeekends.getBusinessSchedule("2019-06-26").getEOBD()); + assertEquals(noNonBusinessDays.businessSchedule("2019-06-26").getSOBD(), + onlyWeekends.businessSchedule("2019-06-26").getSOBD()); + assertEquals(noNonBusinessDays.businessSchedule("2019-06-26").getEOBD(), + onlyWeekends.businessSchedule("2019-06-26").getEOBD()); } } diff --git a/plugin/figure/src/main/java/io/deephaven/figure/FigureWidgetTranslator.java b/plugin/figure/src/main/java/io/deephaven/figure/FigureWidgetTranslator.java index 41bde1ae202..e3387a44513 100644 --- a/plugin/figure/src/main/java/io/deephaven/figure/FigureWidgetTranslator.java +++ b/plugin/figure/src/main/java/io/deephaven/figure/FigureWidgetTranslator.java @@ -559,7 +559,7 @@ private BusinessCalendarDescriptor translateBusinessCalendar(AxisTransformBusine return businessPeriod; }).forEach(businessCalendarDescriptor::addBusinessPeriods); - businessCalendar.getHolidays().entrySet().stream().sorted(Comparator.comparing(Map.Entry::getKey)) + businessCalendar.holidays().entrySet().stream().sorted(Comparator.comparing(Map.Entry::getKey)) .map(entry -> { final LocalDate.Builder localDate = LocalDate.newBuilder(); localDate.setYear(entry.getKey().getYear()); From ca2040dc21e15056d0e38677587fb1d0bd8b25a4 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Fri, 30 Jun 2023 18:20:04 -0700 Subject: [PATCH 009/150] BusinessCalendar refactoring and cleanup. --- .../time/calendar/BusinessCalendar.java | 165 +++++++++--------- 1 file changed, 83 insertions(+), 82 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index fc906d499fa..7fd3cbda733 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -27,7 +27,8 @@ //TODO: fail on out of range //TODO: interface, abstract class, or class? //TODO should the methods be DB null tolerant -public interface BusinessCalendar extends Calendar { +@SuppressWarnings("unused") //TODO: remove unused annotation +public class BusinessCalendar extends Calendar { // region Business Schedule @@ -37,7 +38,7 @@ public interface BusinessCalendar extends Calendar { * * @return a map of dates and to their business periods */ - default Map holidays() { + public Map holidays() { return Collections.unmodifiableMap(holidays); } @@ -47,7 +48,7 @@ default Map holidays() { * @param date date * @return the corresponding BusinessSchedule of {@code date} */ - default BusinessSchedule businessSchedule(final LocalDate date) { + public BusinessSchedule businessSchedule(final LocalDate date) { return dates.computeIfAbsent(date, this::newBusinessDay); } @@ -57,7 +58,7 @@ default BusinessSchedule businessSchedule(final LocalDate date) { * @param time time * @return the corresponding BusinessSchedule of {@code time}; null if time is null */ - default BusinessSchedule businessSchedule(final ZonedDateTime time) { + public BusinessSchedule businessSchedule(final ZonedDateTime time) { if (time == null) { return null; } @@ -71,7 +72,7 @@ default BusinessSchedule businessSchedule(final ZonedDateTime time) { * @param time time * @return the corresponding BusinessSchedule of {@code time}; null if time is null */ - default BusinessSchedule businessSchedule(final Instant time) { + public BusinessSchedule businessSchedule(final Instant time) { if (time == null) { return null; } @@ -85,7 +86,7 @@ default BusinessSchedule businessSchedule(final Instant time) { * @param date date * @return the corresponding BusinessSchedule of {@code date} */ - default BusinessSchedule businessSchedule(String date) { + public BusinessSchedule businessSchedule(String date) { if (date == null) { return null; } @@ -99,7 +100,7 @@ default BusinessSchedule businessSchedule(String date) { * * @return today's business schedule */ - default BusinessSchedule currentBusinessSchedule() { + public BusinessSchedule currentBusinessSchedule() { return businessSchedule(currentDate()); } @@ -113,7 +114,7 @@ default BusinessSchedule currentBusinessSchedule() { * @param date date * @return true if the date is a business day; false otherwise. */ - default boolean isBusinessDay(final LocalDate date) { + public boolean isBusinessDay(final LocalDate date) { return date != null && businessSchedule(date).isBusinessDay(); } @@ -123,7 +124,7 @@ default boolean isBusinessDay(final LocalDate date) { * @param date date * @return true if the date is a business day; false otherwise. */ - default boolean isBusinessDay(final String date) { + public boolean isBusinessDay(final String date) { if (date == null) { return false; } @@ -138,7 +139,7 @@ default boolean isBusinessDay(final String date) { * @param time time * @return true if the date is a business day; false otherwise. */ - default boolean isBusinessDay(final ZonedDateTime time){ + public boolean isBusinessDay(final ZonedDateTime time){ return fractionOfStandardBusinessDay(time) > 0.0; } @@ -149,7 +150,7 @@ default boolean isBusinessDay(final ZonedDateTime time){ * @param time time * @return true if the date is a business day; false otherwise. */ - default boolean isBusinessDay(final Instant time){ + public boolean isBusinessDay(final Instant time){ return fractionOfStandardBusinessDay(time) > 0.0; } @@ -160,7 +161,7 @@ default boolean isBusinessDay(final Instant time){ * @param day a day of the week * @return true if the day is a business day; false otherwise. */ - default boolean isBusinessDay(DayOfWeek day){ + public boolean isBusinessDay(DayOfWeek day){ return !weekendDays.contains(day); } @@ -170,7 +171,7 @@ default boolean isBusinessDay(DayOfWeek day){ * * @return true if the current day is a business day; false otherwise. */ - default boolean isBusinessDay() { + public boolean isBusinessDay() { return isBusinessDay(currentDate()); } @@ -203,7 +204,7 @@ boolean isLastBusinessDayOfMonth(final LocalDate date) { * @return true if {@code time} is on the last business day of the month with business time remaining; false * otherwise. */ - default boolean isLastBusinessDayOfMonth(final ZonedDateTime time) { + public boolean isLastBusinessDayOfMonth(final ZonedDateTime time) { if(time == null){ ** raise an error; return false; @@ -219,7 +220,7 @@ default boolean isLastBusinessDayOfMonth(final ZonedDateTime time) { * @return true if {@code time} is on the last business day of the month with business time remaining; false * otherwise. */ - default boolean isLastBusinessDayOfMonth(final Instant time) { + public boolean isLastBusinessDayOfMonth(final Instant time) { if(time == null){ ** raise an error; return false; @@ -248,7 +249,7 @@ boolean isLastBusinessDayOfMonth(final String date) { * * @return true if {@code date} is on the last business day of the month; false otherwise. */ - default boolean isLastBusinessDayOfMonth() { + public boolean isLastBusinessDayOfMonth() { return isLastBusinessDayOfMonth(currentDate()); } @@ -258,7 +259,7 @@ default boolean isLastBusinessDayOfMonth() { * @param date date * @return true if {@code date} is on the last business day of the week; false otherwise. */ - default boolean isLastBusinessDayOfWeek(final LocalDate date){ + public boolean isLastBusinessDayOfWeek(final LocalDate date){ if(date == null){ *** error *** return false; @@ -279,7 +280,7 @@ default boolean isLastBusinessDayOfWeek(final LocalDate date){ * @return true if {@code time} is on the last business day of the week with business time remaining; false * otherwise. */ - default boolean isLastBusinessDayOfWeek(final ZonedDateTime time) { + public boolean isLastBusinessDayOfWeek(final ZonedDateTime time) { if(time == null){ *** error ***; return false; @@ -295,7 +296,7 @@ default boolean isLastBusinessDayOfWeek(final ZonedDateTime time) { * @return true if {@code time} is on the last business day of the week with business time remaining; false * otherwise. */ - default boolean isLastBusinessDayOfWeek(final Instant time) { + public boolean isLastBusinessDayOfWeek(final Instant time) { if(time == null){ *** error ***; return false; @@ -310,7 +311,7 @@ default boolean isLastBusinessDayOfWeek(final Instant time) { * @param date date * @return true if {@code date} is on the last business day of the week; false otherwise. */ - default boolean isLastBusinessDayOfWeek(final String date){ + public boolean isLastBusinessDayOfWeek(final String date){ if(date == null){ *** error ***; return false; @@ -324,7 +325,7 @@ default boolean isLastBusinessDayOfWeek(final String date){ * * @return true if {@code date} is on the last business day of the week; false otherwise. */ - default boolean isLastBusinessDayOfWeek() { + public boolean isLastBusinessDayOfWeek() { return isLastBusinessDayOfWeek(currentDate()); } @@ -342,7 +343,7 @@ default boolean isLastBusinessDayOfWeek() { * @param time time * @return true if the specified time is a business time; otherwise, false. */ - default boolean isBusinessTime(final ZonedDateTime time) { + public boolean isBusinessTime(final ZonedDateTime time) { return time != null && businessSchedule(time).isBusinessTime(time); } @@ -354,7 +355,7 @@ default boolean isBusinessTime(final ZonedDateTime time) { * @param time time * @return true if the specified time is a business time; otherwise, false. */ - default boolean isBusinessTime(final Instant time) { + public boolean isBusinessTime(final Instant time) { return time != null && businessSchedule(time).isBusinessTime(time); } @@ -363,7 +364,7 @@ default boolean isBusinessTime(final Instant time) { * * @return length of a standard business day in nanoseconds. */ - default long standardBusinessDayLengthNanos() { + public long standardBusinessDayLengthNanos() { return lengthOfDefaultDayNanos; } @@ -376,7 +377,7 @@ default long standardBusinessDayLengthNanos() { * @param date date; if null, return 0 * @return ratio of the business day length and the standard business day length for the date */ - default double fractionOfStandardBusinessDay(final LocalDate date){ + public double fractionOfStandardBusinessDay(final LocalDate date){ final BusinessSchedule schedule = businessSchedule(date); return schedule == null ? 0.0 : (double) schedule.getLOBD() / (double) standardBusinessDayLengthNanos(); } @@ -390,7 +391,7 @@ default double fractionOfStandardBusinessDay(final LocalDate date){ * @param time time; if null, return 0 * @return ratio of the business day length and the standard business day length for the date */ - default double fractionOfStandardBusinessDay(final Instant time){ + public double fractionOfStandardBusinessDay(final Instant time){ return time == null ? 0.0 : fractionOfStandardBusinessDay(DateTimeUtils.toLocalDate(time, timeZone())); } @@ -403,7 +404,7 @@ default double fractionOfStandardBusinessDay(final Instant time){ * @param time time; if null, return 0 * @return ratio of the business day length and the standard business day length for the date */ - default double fractionOfStandardBusinessDay(final ZonedDateTime time){ + public double fractionOfStandardBusinessDay(final ZonedDateTime time){ return time == null ? 0.0 : fractionOfStandardBusinessDay(DateTimeUtils.toLocalDate(time.toInstant(), timeZone())); } @@ -416,7 +417,7 @@ default double fractionOfStandardBusinessDay(final ZonedDateTime time){ * @see BusinessCalendar#fractionOfBusinessDayRemaining(Instant) * @return ratio of the business day length and the standard business day length for the current day */ - default double fractionOfStandardBusinessDay() { + public double fractionOfStandardBusinessDay() { return fractionOfStandardBusinessDay(currentDate()); } @@ -426,7 +427,7 @@ default double fractionOfStandardBusinessDay() { * @param time time * @return the fraction of the day left after {@code time}; NULL_DOUBLE if time is null */ - default double fractionOfBusinessDayRemaining(final Instant time){ + public double fractionOfBusinessDayRemaining(final Instant time){ final BusinessSchedule businessDate = businessSchedule(time); if (businessDate == null) { return QueryConstants.NULL_DOUBLE; @@ -446,7 +447,7 @@ default double fractionOfBusinessDayRemaining(final Instant time){ * @param time time * @return the fraction of the day left after {@code time}; NULL_DOUBLE if time is null */ - default double fractionOfBusinessDayRemaining(final ZonedDateTime time){ + public double fractionOfBusinessDayRemaining(final ZonedDateTime time){ if(time == null) { return QueryConstants.NULL_DOUBLE; } @@ -461,7 +462,7 @@ default double fractionOfBusinessDayRemaining(final ZonedDateTime time){ * @param time time * @return the fraction of the day complete by {@code time}; NULL_DOUBLE if time is null */ - default double fractionOfBusinessDayComplete(final Instant time) { + public double fractionOfBusinessDayComplete(final Instant time) { if (time == null) { return QueryConstants.NULL_DOUBLE; } @@ -475,7 +476,7 @@ default double fractionOfBusinessDayComplete(final Instant time) { * @param time time * @return the fraction of the day complete by {@code time}; NULL_DOUBLE if time is null */ - default double fractionOfBusinessDayComplete(final ZonedDateTime time) { + public double fractionOfBusinessDayComplete(final ZonedDateTime time) { if (time == null) { return QueryConstants.NULL_DOUBLE; } @@ -498,7 +499,7 @@ default double fractionOfBusinessDayComplete(final ZonedDateTime time) { * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberBusinessDates(final LocalDate start, final LocalDate end, final boolean endInclusive) { + public int numberBusinessDates(final LocalDate start, final LocalDate end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } @@ -508,7 +509,7 @@ default int numberBusinessDates(final LocalDate start, final LocalDate end, fina if (isBusinessDay(start)) { days++; } - start = futureBusinessDate(start); + start = plusBusinessDays(start, 1); } else if (start.isAfter(end)) { //TODO: is this working right? return -numberBusinessDates(end, start, endInclusive); @@ -518,7 +519,7 @@ default int numberBusinessDates(final LocalDate start, final LocalDate end, fina while (day.isBefore(end)) { days++; - day = futureBusinessDate(day); + day = plusBusinessDays(day,1); } return days + (endInclusive && isBusinessDay(end) ? 1 : 0); @@ -534,7 +535,7 @@ default int numberBusinessDates(final LocalDate start, final LocalDate end, fina * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberBusinessDates(Instant start, Instant end, final boolean endInclusive) { + public int numberBusinessDates(Instant start, Instant end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } @@ -551,7 +552,7 @@ default int numberBusinessDates(Instant start, Instant end, final boolean endInc * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberBusinessDates(ZonedDateTime start, ZonedDateTime end, final boolean endInclusive) { + public int numberBusinessDates(ZonedDateTime start, ZonedDateTime end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } @@ -568,7 +569,7 @@ default int numberBusinessDates(ZonedDateTime start, ZonedDateTime end, final bo * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberBusinessDates(String start, String end, final boolean endInclusive) { + public int numberBusinessDates(String start, String end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } @@ -585,7 +586,7 @@ default int numberBusinessDates(String start, String end, final boolean endInclu * @return number of non-business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberNonBusinessDates(final LocalDate start, final LocalDate end, final boolean endInclusive) { + public int numberNonBusinessDates(final LocalDate start, final LocalDate end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } @@ -602,7 +603,7 @@ default int numberNonBusinessDates(final LocalDate start, final LocalDate end, f * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberNonBusinessDates(Instant start, Instant end, final boolean endInclusive) { + public int numberNonBusinessDates(Instant start, Instant end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } @@ -619,7 +620,7 @@ default int numberNonBusinessDates(Instant start, Instant end, final boolean end * @return number of non-business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} * respectively. */ - default int numberNonBusinessDates(final String start, final String end, final boolean endInclusive) { + public int numberNonBusinessDates(final String start, final String end, final boolean endInclusive) { if (start == null || end == null) { return QueryConstants.NULL_INT; } @@ -637,7 +638,7 @@ default int numberNonBusinessDates(final String start, final String end, final b * @param end end time; if null, return empty array * @return inclusive business days between {@code start} and {@code end} */ - default LocalDate[] businessDates(final LocalDate start, final LocalDate end) { + public LocalDate[] businessDates(final LocalDate start, final LocalDate end) { if (start == null || end == null) { return new LocalDate[0]; } @@ -665,7 +666,7 @@ default LocalDate[] businessDates(final LocalDate start, final LocalDate end) { * @param end end time; if null, return empty array * @return inclusive business days between {@code start} and {@code end} */ - default LocalDate[] businessDates(final Instant start, final Instant end) { + public LocalDate[] businessDates(final Instant start, final Instant end) { if (start == null || end == null) { return new LocalDate[0]; } @@ -683,7 +684,7 @@ default LocalDate[] businessDates(final Instant start, final Instant end) { * @param end end time; if null, return empty array * @return inclusive business days between {@code start} and {@code end} */ - default LocalDate[] businessDates(final ZonedDateTime start, final ZonedDateTime end) { + public LocalDate[] businessDates(final ZonedDateTime start, final ZonedDateTime end) { if (start == null || end == null) { return new LocalDate[0]; } @@ -701,7 +702,7 @@ default LocalDate[] businessDates(final ZonedDateTime start, final ZonedDateTime * @param end end time; if null, return empty array * @return inclusive business days between {@code start} and {@code end} */ - default LocalDate[] businessDates(String start, String end){ + public LocalDate[] businessDates(String start, String end){ if (start == null || end == null) { return new LocalDate[0]; } @@ -719,7 +720,7 @@ default LocalDate[] businessDates(String start, String end){ * @param end end time; if null, return empty array * @return inclusive non-business days between {@code start} and {@code end} */ - default LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end){ + public LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end){ if (start == null || end == null) { return new LocalDate[0]; } @@ -747,7 +748,7 @@ default LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end) * @param end end time; if null, return empty array * @return inclusive non-business days between {@code start} and {@code end} */ - default LocalDate[] nonBusinessDates(final Instant start, final Instant end){ + public LocalDate[] nonBusinessDates(final Instant start, final Instant end){ if (start == null || end == null) { return new LocalDate[0]; } @@ -765,7 +766,7 @@ default LocalDate[] nonBusinessDates(final Instant start, final Instant end){ * @param end end time; if null, return empty array * @return inclusive non-business days between {@code start} and {@code end} */ - default LocalDate[] nonBusinessDates(final ZonedDateTime start, final ZonedDateTime end){ + public LocalDate[] nonBusinessDates(final ZonedDateTime start, final ZonedDateTime end){ if (start == null || end == null) { return new LocalDate[0]; } @@ -783,7 +784,7 @@ default LocalDate[] nonBusinessDates(final ZonedDateTime start, final ZonedDateT * @param end end time; if null, return empty array * @return inclusive non-business days between {@code start} and {@code end} */ - default LocalDate[] nonBusinessDates(String start, String end){ + public LocalDate[] nonBusinessDates(String start, String end){ if (start == null || end == null) { return new LocalDate[0]; } @@ -798,7 +799,7 @@ default LocalDate[] nonBusinessDates(String start, String end){ * @param end end time; if null, return NULL_LONG * @return the amount of business time in nanoseconds between the {@code start} and {@code end} */ - default long diffBusinessNanos(final Instant start, final Instant end) { + public long diffBusinessNanos(final Instant start, final Instant end) { if (start == null || end == null) { return QueryConstants.NULL_LONG; } @@ -850,7 +851,7 @@ default long diffBusinessNanos(final Instant start, final Instant end) { * @param end end time; if null, return NULL_LONG * @return the amount of business time in nanoseconds between the {@code start} and {@code end} */ - default long diffBusinessNanos(final ZonedDateTime start, final ZonedDateTime end) { + public long diffBusinessNanos(final ZonedDateTime start, final ZonedDateTime end) { if (start == null || end == null) { return QueryConstants.NULL_LONG; } @@ -865,7 +866,7 @@ default long diffBusinessNanos(final ZonedDateTime start, final ZonedDateTime en * @param end end time; if null, return NULL_LONG * @return the amount of non-business time in nanoseconds between the {@code start} and {@code end} */ - default long diffNonBusinessNanos(final Instant start, final Instant end) { + public long diffNonBusinessNanos(final Instant start, final Instant end) { if (start == null || end == null) { return QueryConstants.NULL_LONG; } @@ -884,7 +885,7 @@ default long diffNonBusinessNanos(final Instant start, final Instant end) { * @param end end time; if null, return NULL_LONG * @return the amount of non-business time in nanoseconds between the {@code start} and {@code end} */ - default long diffNonBusinessNanos(final ZonedDateTime start, final ZonedDateTime end) { + public long diffNonBusinessNanos(final ZonedDateTime start, final ZonedDateTime end) { if (start == null || end == null) { return QueryConstants.NULL_LONG; } @@ -899,7 +900,7 @@ default long diffNonBusinessNanos(final ZonedDateTime start, final ZonedDateTime * @param end end time; if null, return NULL_LONG * @return the amount of business time in standard business days between the {@code start} and {@code end} */ - default double diffBusinessDays(final Instant start, final Instant end) { + public double diffBusinessDays(final Instant start, final Instant end) { if (start == null || end == null) { return QueryConstants.NULL_DOUBLE; } @@ -914,7 +915,7 @@ default double diffBusinessDays(final Instant start, final Instant end) { * @param end end time; if null, return NULL_LONG * @return the amount of business time in standard business days between the {@code start} and {@code end} */ - default double diffBusinessDays(final ZonedDateTime start, final ZonedDateTime end) { + public double diffBusinessDays(final ZonedDateTime start, final ZonedDateTime end) { if (start == null || end == null) { return QueryConstants.NULL_DOUBLE; } @@ -929,7 +930,7 @@ default double diffBusinessDays(final ZonedDateTime start, final ZonedDateTime e * @param end end time; if null, return NULL_LONG * @return the amount of non-business time in standard business days between the {@code start} and {@code end} */ - default double diffNonBusinessDays(final Instant start, final Instant end){ + public double diffNonBusinessDays(final Instant start, final Instant end){ if (start == null || end == null) { return QueryConstants.NULL_DOUBLE; } @@ -944,7 +945,7 @@ default double diffNonBusinessDays(final Instant start, final Instant end){ * @param end end time; if null, return NULL_LONG * @return the amount of non-business time in standard business days between the {@code start} and {@code end} */ - default double diffNonBusinessDays(final ZonedDateTime start, final ZonedDateTime end){ + public double diffNonBusinessDays(final ZonedDateTime start, final ZonedDateTime end){ if (start == null || end == null) { return QueryConstants.NULL_DOUBLE; } @@ -959,7 +960,7 @@ default double diffNonBusinessDays(final ZonedDateTime start, final ZonedDateTim * @param end end; if null, return null * @return the amount of business time in business years between the {@code start} and {@code end} */ - default double diffBusinessYears(final Instant start, final Instant end){ + public double diffBusinessYears(final Instant start, final Instant end){ if (start == null || end == null) { return QueryConstants.NULL_DOUBLE; } @@ -993,7 +994,7 @@ default double diffBusinessYears(final Instant start, final Instant end){ * @param end end; if null, return null * @return the amount of business time in business years between the {@code start} and {@code end} */ - default double diffBusinessYears(final ZonedDateTime start, final ZonedDateTime end) { + public double diffBusinessYears(final ZonedDateTime start, final ZonedDateTime end) { if (start == null || end == null) { return QueryConstants.NULL_DOUBLE; } @@ -1014,7 +1015,7 @@ default double diffBusinessYears(final ZonedDateTime start, final ZonedDateTime * @param days number of days to add. * @return {@code days} business days after {@code date}; null if {@code date} is null or if {@code date} is not a business day and {@code days} is zero. */ - default LocalDate plusBusinessDays(final LocalDate date, int days) { + public LocalDate plusBusinessDays(final LocalDate date, int days) { if (date == null) { return null; } else if(days == 0){ @@ -1040,7 +1041,7 @@ default LocalDate plusBusinessDays(final LocalDate date, int days) { * @param days number of days to add. * @return {@code days} business days after {@code date}; null if {@code date} is null or if {@code date} is not a business day and {@code days} is zero. */ - default LocalDate plusBusinessDays(final String date, int days) { + public LocalDate plusBusinessDays(final String date, int days) { if(date == null){ return null; } @@ -1056,7 +1057,7 @@ default LocalDate plusBusinessDays(final String date, int days) { * @param days number of days to add. * @return {@code days} business days after {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - default LocalDate plusBusinessDays(final Instant time, int days) { + public LocalDate plusBusinessDays(final Instant time, int days) { if(time == null){ return null; } @@ -1071,7 +1072,7 @@ default LocalDate plusBusinessDays(final Instant time, int days) { * @param days number of days to add. * @return {@code days} business days after {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - default LocalDate plusBusinessDays(final ZonedDateTime time, int days) { + public LocalDate plusBusinessDays(final ZonedDateTime time, int days) { if(time == null){ return null; } @@ -1086,7 +1087,7 @@ default LocalDate plusBusinessDays(final ZonedDateTime time, int days) { * @param days number of days to subtract. * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - default LocalDate minusBusinessDays(final LocalDate date, int days) { + public LocalDate minusBusinessDays(final LocalDate date, int days) { return plusBusinessDays(date, -days); } @@ -1097,7 +1098,7 @@ default LocalDate minusBusinessDays(final LocalDate date, int days) { * @param days number of days to subtract. * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - default LocalDate minusBusinessDays(final String date, int days) { + public LocalDate minusBusinessDays(final String date, int days) { return plusBusinessDays(date, -days); } @@ -1108,7 +1109,7 @@ default LocalDate minusBusinessDays(final String date, int days) { * @param days number of days to subtract. * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - default LocalDate minusBusinessDays(final Instant time, int days) { + public LocalDate minusBusinessDays(final Instant time, int days) { return plusBusinessDays(time, -days); } @@ -1119,7 +1120,7 @@ default LocalDate minusBusinessDays(final Instant time, int days) { * @param days number of days to subtract. * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. */ - default LocalDate minusBusinessDays(final ZonedDateTime time, int days) { + public LocalDate minusBusinessDays(final ZonedDateTime time, int days) { return plusBusinessDays(time, -days); } @@ -1130,7 +1131,7 @@ default LocalDate minusBusinessDays(final ZonedDateTime time, int days) { * @param days number of days to add. * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default LocalDate plusNonBusinessDays(final LocalDate date, int days) { + public LocalDate plusNonBusinessDays(final LocalDate date, int days) { if (date == null) { return null; } else if(days == 0){ @@ -1156,7 +1157,7 @@ default LocalDate plusNonBusinessDays(final LocalDate date, int days) { * @param days number of days to add. * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default LocalDate plusNonBusinessDays(final LocalDate date, int days) { + public LocalDate plusNonBusinessDays(final String date, int days) { if(date == null){ return null; } @@ -1171,7 +1172,7 @@ default LocalDate plusNonBusinessDays(final LocalDate date, int days) { * @param days number of days to add. * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default LocalDate plusNonBusinessDays(final Instant time, int days) { + public LocalDate plusNonBusinessDays(final Instant time, int days) { if(time == null){ return null; } @@ -1186,7 +1187,7 @@ default LocalDate plusNonBusinessDays(final Instant time, int days) { * @param days number of days to add. * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default LocalDate plusNonBusinessDays(final ZonedDateTime time, int days) { + public LocalDate plusNonBusinessDays(final ZonedDateTime time, int days) { if(time == null){ return null; } @@ -1201,7 +1202,7 @@ default LocalDate plusNonBusinessDays(final ZonedDateTime time, int days) { * @param days number of days to subtract. * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default LocalDate minusNonBusinessDays(final LocalDate date, int days) { + public LocalDate minusNonBusinessDays(final LocalDate date, int days) { return this.plusNonBusinessDays(date, -days); } @@ -1212,8 +1213,8 @@ default LocalDate minusNonBusinessDays(final LocalDate date, int days) { * @param days number of days to subtract. * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. */ - default LocalDate minusNonBusinessDays(final String date, int days) { - return addNonBusinessDays(date, -days); + public LocalDate minusNonBusinessDays(final String date, int days) { + return plusNonBusinessDays(date, -days); } /** @@ -1223,7 +1224,7 @@ default LocalDate minusNonBusinessDays(final String date, int days) { * @param days number of days to subtract. * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code time} is a business day and {@code days} is zero. */ - default LocalDate minusNonBusinessDays(final Instant time, int days) { + public LocalDate minusNonBusinessDays(final Instant time, int days) { return plusNonBusinessDays(time, -days); } @@ -1234,7 +1235,7 @@ default LocalDate minusNonBusinessDays(final Instant time, int days) { * @param days number of days to subtract. * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code time} is a business day and {@code days} is zero. */ - default LocalDate minusNonBusinessDays(final ZonedDateTime time, int days) { + public LocalDate minusNonBusinessDays(final ZonedDateTime time, int days) { return plusNonBusinessDays(time, -days); } @@ -1244,7 +1245,7 @@ default LocalDate minusNonBusinessDays(final ZonedDateTime time, int days) { * @param days number of days to add. * @return {@code days} business days after the current date; null if the current date is not a business day and {@code days} is zero. */ - default LocalDate futureBusinessDate(int days) { + public LocalDate futureBusinessDate(int days) { return plusBusinessDays(currentDate(), days); } @@ -1254,7 +1255,7 @@ default LocalDate futureBusinessDate(int days) { * @param days number of days to subtract. * @return {@code days} business days before the current date; null if the current date is not a business day and {@code days} is zero. */ - default LocalDate pastBusinessDate(int days) { + public LocalDate pastBusinessDate(int days) { return minusBusinessDays(currentDate(), days); } @@ -1264,7 +1265,7 @@ default LocalDate pastBusinessDate(int days) { * @param days number of days to add. * @return {@code days} non-business days after the current date; null if the current date is a business day and {@code days} is zero. */ - default LocalDate futureNonBusinessDate(int days) { + public LocalDate futureNonBusinessDate(int days) { return this.plusNonBusinessDays(currentDate(), days); } @@ -1274,7 +1275,7 @@ default LocalDate futureNonBusinessDate(int days) { * @param days number of days to subtract. * @return {@code days} non-business days before the current date; null if the current date is a business day and {@code days} is zero. */ - default LocalDate pastNonBusinessDate(int days) { + public LocalDate pastNonBusinessDate(int days) { return minusNonBusinessDays(currentDate(), days); } @@ -1285,11 +1286,11 @@ default LocalDate pastNonBusinessDate(int days) { //TODO: remove from API? //TODO: rename /** - * Gets the business periods for the default days. + * Gets the business periods for the public days. * * @return a list of strings with a comma separating open and close times */ - default List getDefaultBusinessPeriods(){ + public List getDefaultBusinessPeriods(){ return Collections.unmodifiableList(defaultBusinessPeriodStrings); } From b334e2251b27bf5a5fbea6725819a5da31da6a34 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Sun, 2 Jul 2023 13:12:43 -0700 Subject: [PATCH 010/150] BusinessPeriod BusinessSchedule refactoring and cleanup. --- .../AxisTransformBusinessCalendar.java | 40 ++-- .../time/calendar/BusinessPeriod.java | 74 ++++-- .../time/calendar/BusinessSchedule.java | 222 ++++++++---------- .../time/calendar/TestBusinessPeriod.java | 14 +- .../time/calendar/TestBusinessSchedule.java | 112 +++++---- .../calendar/TestDefaultBusinessCalendar.java | 12 +- .../TestDefaultNoHolidayBusinessCalendar.java | 8 +- 7 files changed, 250 insertions(+), 232 deletions(-) diff --git a/Plot/src/main/java/io/deephaven/plot/axistransformations/AxisTransformBusinessCalendar.java b/Plot/src/main/java/io/deephaven/plot/axistransformations/AxisTransformBusinessCalendar.java index 9f77faeb2e9..56d50074268 100644 --- a/Plot/src/main/java/io/deephaven/plot/axistransformations/AxisTransformBusinessCalendar.java +++ b/Plot/src/main/java/io/deephaven/plot/axistransformations/AxisTransformBusinessCalendar.java @@ -70,25 +70,25 @@ private Nugget getNuggetByTime(final double timeNanos) { nuggets.add(nMin); } - while (timeNanos < DateTimeUtils.epochNanos(nMin.businessDay.getSOBD())) { + while (timeNanos < DateTimeUtils.epochNanos(nMin.businessDay.businessStart())) { final BusinessSchedule d = - busCal.businessSchedule(busCal.pastBusinessDate(nMin.businessDay.getSOBD())); - final Nugget n = new Nugget(d, nMin.cumulativeBusinessTimeNanosAtStartOfDay - d.getLOBD()); + busCal.businessSchedule(busCal.pastBusinessDate(nMin.businessDay.businessStart())); + final Nugget n = new Nugget(d, nMin.cumulativeBusinessTimeNanosAtStartOfDay - d.businessNanos()); nuggets.add(0, n); nMin = n; } // noinspection ConstantConditions nMax can't cause NPE (for now! Don't add nulls to nuggets!) - while (timeNanos > DateTimeUtils.epochNanos(nMax.businessDay.getEOBD())) { - final BusinessSchedule d = busCal.businessSchedule(busCal.futureBusinessDate(nMax.businessDay.getEOBD())); - final Nugget n = new Nugget(d, nMax.cumulativeBusinessTimeNanosAtStartOfDay + nMax.businessDay.getLOBD()); + while (timeNanos > DateTimeUtils.epochNanos(nMax.businessDay.businessEnd())) { + final BusinessSchedule d = busCal.businessSchedule(busCal.futureBusinessDate(nMax.businessDay.businessEnd())); + final Nugget n = new Nugget(d, nMax.cumulativeBusinessTimeNanosAtStartOfDay + nMax.businessDay.businessNanos()); nuggets.add(n); nMax = n; } - return findNugget(n -> timeNanos <= DateTimeUtils.epochNanos(n.businessDay.getEOBD())); + return findNugget(n -> timeNanos <= DateTimeUtils.epochNanos(n.businessDay.businessEnd())); } private Nugget getNuggetByValue(final double value) { @@ -105,8 +105,8 @@ private Nugget getNuggetByValue(final double value) { while (value < nMin.cumulativeBusinessTimeNanosAtStartOfDay) { final BusinessSchedule d = - busCal.businessSchedule(busCal.pastBusinessDate(nMin.businessDay.getSOBD())); - final Nugget n = new Nugget(d, nMin.cumulativeBusinessTimeNanosAtStartOfDay - d.getLOBD()); + busCal.businessSchedule(busCal.pastBusinessDate(nMin.businessDay.businessStart())); + final Nugget n = new Nugget(d, nMin.cumulativeBusinessTimeNanosAtStartOfDay - d.businessNanos()); nuggets.add(0, n); nMin = n; @@ -116,15 +116,15 @@ private Nugget getNuggetByValue(final double value) { return null; } - while (value > nMax.cumulativeBusinessTimeNanosAtStartOfDay + nMax.businessDay.getLOBD()) { - final BusinessSchedule d = busCal.businessSchedule(busCal.futureBusinessDate(nMax.businessDay.getEOBD())); - final Nugget n = new Nugget(d, nMax.cumulativeBusinessTimeNanosAtStartOfDay + nMax.businessDay.getLOBD()); + while (value > nMax.cumulativeBusinessTimeNanosAtStartOfDay + nMax.businessDay.businessNanos()) { + final BusinessSchedule d = busCal.businessSchedule(busCal.futureBusinessDate(nMax.businessDay.businessEnd())); + final Nugget n = new Nugget(d, nMax.cumulativeBusinessTimeNanosAtStartOfDay + nMax.businessDay.businessNanos()); nuggets.add(n); nMax = n; } - return findNugget(n -> value < n.cumulativeBusinessTimeNanosAtStartOfDay + n.businessDay.getLOBD()); + return findNugget(n -> value < n.cumulativeBusinessTimeNanosAtStartOfDay + n.businessDay.businessNanos()); } // only getNuggetByTime or getNuggetByValue should call this to ensure that the desired value is in range @@ -172,11 +172,11 @@ public double inverseTransform(final double value) { } double busDayNanos = value - n.cumulativeBusinessTimeNanosAtStartOfDay; - double timeNanos = DateTimeUtils.epochNanos(n.businessDay.getSOBD()); + double timeNanos = DateTimeUtils.epochNanos(n.businessDay.businessStart()); - for (BusinessPeriod period : n.businessDay.getBusinessPeriods()) { - final double start = DateTimeUtils.epochNanos(period.getStartTime()); - final double end = DateTimeUtils.epochNanos(period.getEndTime()); + for (BusinessPeriod period : n.businessDay.periods()) { + final double start = DateTimeUtils.epochNanos(period.start()); + final double end = DateTimeUtils.epochNanos(period.end()); final double length = end - start; if (busDayNanos > 0 && length > 0) { @@ -203,9 +203,9 @@ public double transform(final double timeNanos) { double value = n.cumulativeBusinessTimeNanosAtStartOfDay; - for (BusinessPeriod period : n.businessDay.getBusinessPeriods()) { - final double start = DateTimeUtils.epochNanos(period.getStartTime()); - final double end = DateTimeUtils.epochNanos(period.getEndTime()); + for (BusinessPeriod period : n.businessDay.periods()) { + final double start = DateTimeUtils.epochNanos(period.start()); + final double end = DateTimeUtils.epochNanos(period.end()); if (timeNanos > start) { if (timeNanos < end) { diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java index b4cd9bfcd5d..637e9229702 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java @@ -4,57 +4,68 @@ package io.deephaven.time.calendar; import io.deephaven.time.DateTimeUtils; +import org.jetbrains.annotations.NotNull; -import java.io.Serializable; -import java.time.Instant; +import java.time.*; +import java.time.temporal.ChronoUnit; +import java.time.temporal.Temporal; /** * A period of business time during a business day. + * + * @param time type */ -public class BusinessPeriod implements Serializable { - private static final long serialVersionUID = 8196837269495115196L; - private final Instant startTime; - private final Instant endTime; +public class BusinessPeriod & Temporal> { + private final T start; + private final T end; + private final long nanos; - @SuppressWarnings("ConstantConditions") - BusinessPeriod(final Instant startTime, final Instant endTime) { - this.startTime = startTime; - this.endTime = endTime; + /** + * Create a new business period. + * + * @param startTime start of the business period. + * @param endTime end of the business period. + */ + BusinessPeriod(final T startTime, final T endTime) { + this.start = startTime; + this.end = endTime; if (startTime == null || endTime == null) { throw new IllegalArgumentException("Null argument: startTime=" + startTime + " endTime=" + endTime); } - if (DateTimeUtils.epochNanos(startTime) > DateTimeUtils.epochNanos(endTime)) { + if(startTime.compareTo(endTime) > 0) { throw new IllegalArgumentException("Start is after end: startTime=" + startTime + " endTime=" + endTime); } + + this.nanos = start.until(end, ChronoUnit.NANOS); } /** - * Returns the start of the period. + * start of the period. * - * @return the start of the period + * @return start of the period */ - public Instant getStartTime() { - return startTime; + public T start() { + return start; } /** - * Returns the end of the period. + * End of the period. * - * @return the end of the period + * @return End of the period */ - public Instant getEndTime() { - return endTime; + public T end() { + return end; } /** - * Returns the length of the period in nanoseconds. + * Length of the period in nanoseconds. * * @return length of the period in nanoseconds */ - public long getLength() { - return DateTimeUtils.minus(endTime, startTime); + public long nanos() { + return nanos; } /** @@ -63,9 +74,22 @@ public long getLength() { * @param time time. * @return true if the time is in this period; otherwise, false. */ - public boolean contains(final Instant time) { + public boolean contains(final T time) { return time != null - && DateTimeUtils.epochNanos(startTime) <= DateTimeUtils.epochNanos(time) - && DateTimeUtils.epochNanos(time) <= DateTimeUtils.epochNanos(endTime); + && start.compareTo(time) <= 0 + && time.compareTo(end) <= 0; + } + + /** + * Converts a business period in local time to a specific date and time zone. + * + * @param p business period in local time + * @param date date for the new business period + * @param timeZone time zone for the new business period + * @return new business period in the specified date and time zone + */ + public static BusinessPeriod toInstant(final BusinessPeriod p, final LocalDate date, final ZoneId timeZone){ + return new BusinessPeriod<>(DateTimeUtils.toInstant(date, p.start, timeZone), DateTimeUtils.toInstant(date, p.end, timeZone)); } + } diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java index b0aa38a8fbb..4defd94dc1a 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java @@ -3,122 +3,109 @@ */ package io.deephaven.time.calendar; -import io.deephaven.time.DateTimeUtils; +import io.deephaven.base.verify.Require; +import io.deephaven.base.verify.RequirementFailure; import org.jetbrains.annotations.NotNull; -import java.io.Serializable; import java.time.Instant; -import java.time.ZonedDateTime; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.temporal.ChronoUnit; +import java.time.temporal.Temporal; import java.util.Arrays; +import java.util.Comparator; /** - * Description of a single business day. + * Schedule for a single business day. + * + * @param time type */ -public class BusinessSchedule implements Serializable { +public class BusinessSchedule & Temporal> { - private static final long serialVersionUID = 1118129010491637735L; - private final BusinessPeriod[] openPeriods; - private final Instant startOfDay; - private final Instant endOfDay; - private final long lengthOfDay; + /** + * A holiday with no business periods. + */ + public static final BusinessSchedule HOLIDAY = new BusinessSchedule<>(); + + private final BusinessPeriod[] openPeriods; + private final T businessStart; + private final T businessEnd; + private final long businessNanos; /** - * Creates the BusinessSchedule instance + * Creates a BusinessSchedule instance. * - * @param businessPeriods array of {@link BusinessPeriod} + * @param businessPeriods array of business periods * @throws IllegalArgumentException if {@code businessPeriods} overlaps. + * @throws RequirementFailure if {@code businessPeriods} or any constituent business periods are null. */ - BusinessSchedule(@NotNull final BusinessPeriod... businessPeriods) { - this.openPeriods = businessPeriods.clone(); - - // make sure the periods are in order - Arrays.sort(this.openPeriods, (o1, o2) -> { - final long compared = - DateTimeUtils.epochNanos(o2.getStartTime()) - DateTimeUtils.epochNanos(o1.getStartTime()); - if (compared > 0) { - return -1; - } else if (compared == 0) { - return 0; - } else { - return 1; - } - }); + BusinessSchedule(@NotNull final BusinessPeriod[] businessPeriods) { + Require.neqNull(businessPeriods, "businessPeriods"); - if (businessPeriods.length > 0) { - this.startOfDay = openPeriods[0].getStartTime(); - this.endOfDay = openPeriods[openPeriods.length - 1].getEndTime(); - } else { - this.startOfDay = null; - this.endOfDay = null; + for (int i = 0; i < businessPeriods.length; i++) { + Require.neqNull(businessPeriods[i], "businessPeriods[" + i + "]"); } - long lod = 0; + this.openPeriods = businessPeriods; - for (BusinessPeriod businessPeriod : openPeriods) { - if (businessPeriod == null) { - throw new IllegalArgumentException("Null period."); - } + // Sort the periods + Arrays.sort(this.openPeriods, Comparator.comparing(BusinessPeriod::start)); - lod += DateTimeUtils.minus(businessPeriod.getEndTime(), businessPeriod.getStartTime()); + if (businessPeriods.length > 0) { + this.businessStart = openPeriods[0].start(); + this.businessEnd = openPeriods[openPeriods.length - 1].end(); + } else { + this.businessStart = null; + this.businessEnd = null; } - - this.lengthOfDay = lod; + this.businessNanos = Arrays.stream(businessPeriods).map(BusinessPeriod::nanos).reduce(0L, Long::sum); // make sure the periods don't overlap for (int i = 1; i < this.openPeriods.length; i++) { - final BusinessPeriod p0 = this.openPeriods[i - 1]; - final BusinessPeriod p1 = this.openPeriods[i]; + final BusinessPeriod p0 = this.openPeriods[i - 1]; + final BusinessPeriod p1 = this.openPeriods[i]; - if (DateTimeUtils.epochNanos(p1.getStartTime()) < DateTimeUtils.epochNanos(p0.getEndTime())) { + if (p1.start().compareTo(p0.end()) < 0) { throw new IllegalArgumentException("Periods overlap."); } } } /** - * Gets the business periods for the day. - * - * @return the BusinessPeriods for the day + * Creates a BusinessSchedule instance with no business periods. THis is a holiday. */ - public BusinessPeriod[] getBusinessPeriods() { - return openPeriods; + BusinessSchedule() { + //noinspection unchecked + this(new BusinessPeriod[0]); } /** - * Gets the start of the business day. + * Business periods for the day. * - * @return start of the business day + * @return business periods for the day */ - public Instant getSOBD() { - return startOfDay; - } - - /** - * Gets the start of the business day. - * - * @return start of the business day - */ - public Instant getStartOfBusinessDay() { - return getSOBD(); + public BusinessPeriod[] periods() { + return openPeriods; } /** - * Gets the end of the business day. + * Start of the business day. Equivalent to the start of the first business period. * - * @return end of the business day + * @return start of the business day, or null for a holiday schedule */ - public Instant getEOBD() { - return endOfDay; + public T businessStart() { + return businessStart; } /** - * Gets the end of the business day. + * End of the business day. Equivalent to the end of the last business period. * - * @return end of the business day + * @return end of the business day, or null for a holiday schedule */ - public Instant getEndOfBusinessDay() { - return getEOBD(); + public T businessEnd() { + return businessEnd; } /** @@ -127,27 +114,52 @@ public Instant getEndOfBusinessDay() { * * @return length of the day in nanoseconds */ - public long getLOBD() { - return lengthOfDay; + public long businessNanos() { + return businessNanos; } /** - * Gets the length of the business day in nanoseconds. If the business day has multiple periods, only the time - * during the periods is counted. + * Amount of business time in nanoseconds that has elapsed on the given day by the specified time. * - * @return length of the day in nanoseconds + * @param time time + * @return business time in nanoseconds that has elapsed on the given day by the specified time */ - public long getLengthOfBusinessDay() { - return getLOBD(); + public long businessNanosElapsed(final T time) { + Require.neqNull(time, "time"); + long elapsed = 0; + + for (BusinessPeriod businessPeriod : openPeriods) { + if (time.compareTo(businessPeriod.start()) < 0) { + return elapsed; + } else if (time.compareTo(businessPeriod.end()) > 0) { + elapsed += businessPeriod.nanos(); + } else { + elapsed += businessPeriod.start().until(time, ChronoUnit.NANOS); + return elapsed; + } + } + + return elapsed; } /** - * Is this day a business day? + * Amount of business time in nanoseconds that remains until the end of the day. * - * @return true if it is a business day; false otherwise. + * @param time time + * @return business time in nanoseconds that remains until the end of the day. */ + public long businessNanosRemaining(final T time) { + Require.neqNull(time, "time"); + return businessNanos-businessNanosElapsed(time); + } + + /** + * Is this day a business day? + * + * @return true if it is a business day; false otherwise. + */ public boolean isBusinessDay() { - return openPeriods.length > 0; + return businessNanos > 0; } /** @@ -156,8 +168,8 @@ public boolean isBusinessDay() { * @param time time. * @return true if the time is a business time for the day; otherwise, false. */ - public boolean isBusinessTime(final Instant time) { - for (BusinessPeriod p : openPeriods) { + public boolean isBusinessTime(final T time) { + for (BusinessPeriod p : openPeriods) { if (p.contains(time)) { return true; } @@ -167,45 +179,15 @@ public boolean isBusinessTime(final Instant time) { } /** - * Determines if the specified time is a business time for the day. - * - * @param time time. - * @return true if the time is a business time for the day; otherwise, false. - */ - public boolean isBusinessTime(final ZonedDateTime time) { - return isBusinessTime(time.toInstant()); - } - - /** - * Returns the amount of business time in nanoseconds that has elapsed on the given day by the specified time. + * Converts a business schedule in local time to a specific date and time zone. * - * @param time time - * @return business time in nanoseconds that has elapsed on the given day by the specified time - */ - public long businessTimeElapsed(final Instant time) { - long elapsed = 0; - - for (BusinessPeriod businessPeriod : openPeriods) { - if (DateTimeUtils.isBefore(time, businessPeriod.getStartTime())) { - return elapsed; - } else if (DateTimeUtils.isAfter(time, businessPeriod.getEndTime())) { - elapsed += businessPeriod.getLength(); - } else { - elapsed += DateTimeUtils.minus(time, businessPeriod.getStartTime()); - return elapsed; - } - } - - return elapsed; - } - - /** - * Returns the amount of business time in nanoseconds that has elapsed on the given day by the specified time. - * - * @param time time - * @return business time in nanoseconds that has elapsed on the given day by the specified time + * @param s business schedule in local time + * @param date date for the new business schedule + * @param timeZone time zone for the new business schedule + * @return new business schedule in the specified date and time zone */ - public long businessTimeElapsed(final ZonedDateTime time) { - return businessTimeElapsed(time.toInstant()); + public static BusinessSchedule toInstant(final BusinessSchedule s, final LocalDate date, final ZoneId timeZone){ + //noinspection unchecked + return new BusinessSchedule<>(Arrays.stream(s.periods()).map(p->BusinessPeriod.toInstant(p, date, timeZone)).toArray(BusinessPeriod[]::new)); } } diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessPeriod.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessPeriod.java index 45330ec89e0..1f54de9046e 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessPeriod.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessPeriod.java @@ -16,30 +16,30 @@ public void testBusinessPeriod() { final Instant close1 = DateTimeUtils.parseInstant("2017-03-11T11:00:00.000000000 NY"); try { - new BusinessPeriod(null, close1); + new BusinessPeriod<>(null, close1); TestCase.fail("Expected an exception"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("null")); } try { - new BusinessPeriod(close1, null); + new BusinessPeriod<>(close1, null); TestCase.fail("Expected an exception"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("null")); } try { - new BusinessPeriod(close1, open1); + new BusinessPeriod<>(close1, open1); TestCase.fail("Expected an exception"); } catch (IllegalArgumentException e) { assertTrue(e.getMessage().contains("after")); } - BusinessPeriod period = new BusinessPeriod(open1, close1); - assertEquals(open1, period.getStartTime()); - assertEquals(close1, period.getEndTime()); - assertEquals(DateTimeUtils.HOUR, period.getLength()); + BusinessPeriod period = new BusinessPeriod<>(open1, close1); + assertEquals(open1, period.start()); + assertEquals(close1, period.end()); + assertEquals(DateTimeUtils.HOUR, period.nanos()); assertTrue(period.contains(open1)); assertTrue(period diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessSchedule.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessSchedule.java index 1e4a0b71c38..9b67633b2f3 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessSchedule.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessSchedule.java @@ -13,93 +13,105 @@ public class TestBusinessSchedule extends BaseArrayTestCase { public void testBusinessSchedule() { final Instant open1 = DateTimeUtils.parseInstant("2017-03-11T10:00:00.000000000 NY"); final Instant close1 = DateTimeUtils.parseInstant("2017-03-11T11:00:00.000000000 NY"); - final BusinessPeriod period1 = new BusinessPeriod(open1, close1); + final BusinessPeriod period1 = new BusinessPeriod<>(open1, close1); final Instant open2 = DateTimeUtils.parseInstant("2017-03-11T12:00:00.000000000 NY"); final Instant close2 = DateTimeUtils.parseInstant("2017-03-11T17:00:00.000000000 NY"); - final BusinessPeriod period2 = new BusinessPeriod(open2, close2); + final BusinessPeriod period2 = new BusinessPeriod<>(open2, close2); // empty - final BusinessSchedule empty = new BusinessSchedule(); - assertEquals(new BusinessPeriod[0], empty.getBusinessPeriods()); - assertNull(empty.getSOBD()); - assertNull(empty.getStartOfBusinessDay()); - assertNull(empty.getEOBD()); - assertNull(empty.getEndOfBusinessDay()); - assertEquals(0L, empty.getLOBD()); - assertEquals(0L, empty.getLengthOfBusinessDay()); + final BusinessSchedule empty = new BusinessSchedule<>(); + assertEquals(new BusinessPeriod[0], empty.periods()); + assertNull(empty.businessStart()); + assertNull(empty.businessStart()); + assertNull(empty.businessEnd()); + assertNull(empty.businessEnd()); + assertEquals(0L, empty.businessNanos()); + assertEquals(0L, empty.businessNanos()); assertFalse(empty.isBusinessDay()); assertFalse(empty.isBusinessTime(open1)); assertFalse(empty.isBusinessTime(close1)); - assertEquals(0L, empty.businessTimeElapsed(open1)); - assertEquals(0L, empty.businessTimeElapsed(close1)); - - + assertEquals(0L, empty.businessNanosElapsed(open1)); + assertEquals(0L, empty.businessNanosElapsed(close1)); + assertEquals(0L, empty.businessNanosRemaining(open1)); + assertEquals(0L, empty.businessNanosRemaining(close1)); // single period - final BusinessSchedule single = new BusinessSchedule(period1); - assertEquals(new BusinessPeriod[] {period1}, single.getBusinessPeriods()); - assertEquals(open1, single.getSOBD()); - assertEquals(open1, single.getStartOfBusinessDay()); - assertEquals(close1, single.getEOBD()); - assertEquals(close1, single.getEndOfBusinessDay()); - assertEquals(DateTimeUtils.HOUR, single.getLOBD()); - assertEquals(DateTimeUtils.HOUR, single.getLengthOfBusinessDay()); + //noinspection unchecked,rawtypes + final BusinessSchedule single = new BusinessSchedule<>(new BusinessPeriod[]{period1}); + assertEquals(new BusinessPeriod[] {period1}, single.periods()); + assertEquals(open1, single.businessStart()); + assertEquals(open1, single.businessStart()); + assertEquals(close1, single.businessEnd()); + assertEquals(close1, single.businessEnd()); + assertEquals(DateTimeUtils.HOUR, single.businessNanos()); + assertEquals(DateTimeUtils.HOUR, single.businessNanos()); assertTrue(single.isBusinessDay()); assertTrue(single.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T10:00:00.000000000 NY"))); assertTrue(single.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T10:15:00.000000000 NY"))); assertTrue(single.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T11:00:00.000000000 NY"))); assertFalse(single.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T11:10:00.000000000 NY"))); - assertEquals(0L, single.businessTimeElapsed(DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"))); + assertEquals(0L, single.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"))); assertEquals(DateTimeUtils.MINUTE * 30, - single.businessTimeElapsed(DateTimeUtils.parseInstant("2017-03-11T10:30:00.000000000 NY"))); + single.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T10:30:00.000000000 NY"))); assertEquals(DateTimeUtils.HOUR, - single.businessTimeElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); - + single.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); + assertEquals(DateTimeUtils.MINUTE * 30, + single.businessNanosRemaining(DateTimeUtils.parseInstant("2017-03-11T10:30:00.000000000 NY"))); + assertEquals(0L, + single.businessNanosRemaining(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); // multi period - final BusinessSchedule multi = new BusinessSchedule(period1, period2); - assertEquals(new BusinessPeriod[] {period1, period2}, multi.getBusinessPeriods()); - assertEquals(open1, multi.getSOBD()); - assertEquals(open1, multi.getStartOfBusinessDay()); - assertEquals(close2, multi.getEOBD()); - assertEquals(close2, multi.getEndOfBusinessDay()); - assertEquals(DateTimeUtils.HOUR * 6, multi.getLOBD()); - assertEquals(DateTimeUtils.HOUR * 6, multi.getLengthOfBusinessDay()); + //noinspection unchecked,rawtypes + final BusinessSchedule multi = new BusinessSchedule<>(new BusinessPeriod[]{period1, period2}); + assertEquals(new BusinessPeriod[] {period1, period2}, multi.periods()); + assertEquals(open1, multi.businessStart()); + assertEquals(open1, multi.businessStart()); + assertEquals(close2, multi.businessEnd()); + assertEquals(close2, multi.businessEnd()); + assertEquals(DateTimeUtils.HOUR * 6, multi.businessNanos()); + assertEquals(DateTimeUtils.HOUR * 6, multi.businessNanos()); assertTrue(multi.isBusinessDay()); assertTrue(multi.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T10:00:00.000000000 NY"))); assertTrue(multi.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T10:15:00.000000000 NY"))); assertTrue(multi.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T11:00:00.000000000 NY"))); assertFalse(multi.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T11:10:00.000000000 NY"))); assertTrue(multi.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T12:10:00.000000000 NY"))); - assertEquals(0L, multi.businessTimeElapsed(DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"))); + assertEquals(0L, multi.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"))); assertEquals(DateTimeUtils.MINUTE * 30, - multi.businessTimeElapsed(DateTimeUtils.parseInstant("2017-03-11T10:30:00.000000000 NY"))); + multi.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T10:30:00.000000000 NY"))); assertEquals(DateTimeUtils.HOUR * 2, - multi.businessTimeElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); + multi.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); assertEquals(DateTimeUtils.HOUR * 2, - multi.businessTimeElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); + multi.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); + assertEquals(DateTimeUtils.HOUR*2, multi.businessNanosRemaining(DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"))); + assertEquals(DateTimeUtils.HOUR*5+DateTimeUtils.MINUTE * 30, + multi.businessNanosRemaining(DateTimeUtils.parseInstant("2017-03-11T10:30:00.000000000 NY"))); + assertEquals(DateTimeUtils.HOUR * 4, + multi.businessNanosRemaining(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); + - final BusinessSchedule multi2 = new BusinessSchedule(period2, period1); - assertEquals(new BusinessPeriod[] {period1, period2}, multi2.getBusinessPeriods()); - assertEquals(open1, multi2.getSOBD()); - assertEquals(open1, multi2.getStartOfBusinessDay()); - assertEquals(close2, multi2.getEOBD()); - assertEquals(close2, multi2.getEndOfBusinessDay()); - assertEquals(DateTimeUtils.HOUR * 6, multi2.getLOBD()); - assertEquals(DateTimeUtils.HOUR * 6, multi2.getLengthOfBusinessDay()); + //noinspection unchecked,rawtypes + final BusinessSchedule multi2 = new BusinessSchedule<>(new BusinessPeriod[]{period2, period1}); + assertEquals(new BusinessPeriod[] {period1, period2}, multi2.periods()); + assertEquals(open1, multi2.businessStart()); + assertEquals(open1, multi2.businessStart()); + assertEquals(close2, multi2.businessEnd()); + assertEquals(close2, multi2.businessEnd()); + assertEquals(DateTimeUtils.HOUR * 6, multi2.businessNanos()); + assertEquals(DateTimeUtils.HOUR * 6, multi2.businessNanos()); assertTrue(multi2.isBusinessDay()); assertTrue(multi2.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T10:00:00.000000000 NY"))); assertTrue(multi2.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T10:15:00.000000000 NY"))); assertTrue(multi2.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T11:00:00.000000000 NY"))); assertFalse(multi2.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T11:10:00.000000000 NY"))); assertTrue(multi2.isBusinessTime(DateTimeUtils.parseInstant("2017-03-11T12:10:00.000000000 NY"))); - assertEquals(0L, multi2.businessTimeElapsed(DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"))); + assertEquals(0L, multi2.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"))); assertEquals(DateTimeUtils.MINUTE * 30, - multi2.businessTimeElapsed(DateTimeUtils.parseInstant("2017-03-11T10:30:00.000000000 NY"))); + multi2.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T10:30:00.000000000 NY"))); assertEquals(DateTimeUtils.HOUR * 2, - multi2.businessTimeElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); + multi2.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); assertEquals(DateTimeUtils.HOUR * 2, - multi2.businessTimeElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); + multi2.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); } } diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java index daf4434e29f..90a05200413 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java @@ -763,18 +763,18 @@ public void testNextBusinessSchedule() { // holiday final BusinessSchedule holiday = USNYSE.businessSchedule("2017-12-25"); - assertEquals(0, holiday.getBusinessPeriods().length); - assertEquals(0, holiday.getLengthOfBusinessDay()); + assertEquals(0, holiday.periods().length); + assertEquals(0, holiday.businessNanos()); try { // noinspection ResultOfMethodCallIgnored - holiday.getEOBD(); + holiday.businessEnd(); fail("Expected an exception!"); } catch (UnsupportedOperationException e) { // pass } try { // noinspection ResultOfMethodCallIgnored - holiday.getSOBD(); + holiday.businessStart(); fail("Expected an exception!"); } catch (UnsupportedOperationException e) { // pass @@ -1629,7 +1629,7 @@ public void testMidnightClose() { assertEquals("2019-08-19", UTC.futureBusinessDate(DateTimeUtils.parseInstant("2019-08-18T00:00:00.000000000 UTC"))); - assertEquals("2019-05-16", DateTimeUtils.formatDate(UTC.businessSchedule("2019-05-16").getSOBD(), TZ_UTC)); - assertEquals("2019-05-17", DateTimeUtils.formatDate(UTC.businessSchedule("2019-05-16").getEOBD(), TZ_UTC)); + assertEquals("2019-05-16", DateTimeUtils.formatDate(UTC.businessSchedule("2019-05-16").businessStart(), TZ_UTC)); + assertEquals("2019-05-17", DateTimeUtils.formatDate(UTC.businessSchedule("2019-05-16").businessEnd(), TZ_UTC)); } } diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java index 28f73aeca37..031b14e3e27 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java @@ -171,9 +171,9 @@ public void testNonBusinessDayMethods() { assertEquals(noNonBusinessDays.timeZone(), TZ_NY); assertEquals(noNonBusinessDays.standardBusinessDayLengthNanos(), 6 * DateTimeUtils.HOUR + (30 * DateTimeUtils.MINUTE)); - assertEquals(noNonBusinessDays.businessSchedule("2019-06-26").getSOBD(), - onlyWeekends.businessSchedule("2019-06-26").getSOBD()); - assertEquals(noNonBusinessDays.businessSchedule("2019-06-26").getEOBD(), - onlyWeekends.businessSchedule("2019-06-26").getEOBD()); + assertEquals(noNonBusinessDays.businessSchedule("2019-06-26").businessStart(), + onlyWeekends.businessSchedule("2019-06-26").businessStart()); + assertEquals(noNonBusinessDays.businessSchedule("2019-06-26").businessEnd(), + onlyWeekends.businessSchedule("2019-06-26").businessEnd()); } } From 91cc545f294d463c80c18df79afefef278118352 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Sun, 2 Jul 2023 14:18:47 -0700 Subject: [PATCH 011/150] BusinessCalendar refactoring and cleanup: * Exceptions --- .../time/calendar/BusinessCalendar.java | 308 ++++++++++++------ 1 file changed, 213 insertions(+), 95 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index 7fd3cbda733..c4d93f665c3 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -1,44 +1,175 @@ /** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending + * Copyright (c) 2016-2023 Deephaven Data Labs and Patent Pending */ package io.deephaven.time.calendar; +import io.deephaven.base.verify.Require; import io.deephaven.time.DateTimeUtils; import io.deephaven.util.QueryConstants; -import java.time.DayOfWeek; -import java.time.Instant; -import java.time.LocalDate; -import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.time.*; +import java.util.*; //TODO: update all headers //TODO: review all docs /** - * A business calendar. Calendar is extended with the concept of business and non-business time. + * A business calendar, with the concept of business and non-business time. * - * To comply with the ISO-8601 standard for dates, Strings should be of the form "yyyy-MM-dd", + * Methods that take strings as arguments will generally be lower performance than non-string methods, + * since strings must first be parsed into dates or times. */ //TODO: fail on out of range -//TODO: interface, abstract class, or class? //TODO should the methods be DB null tolerant + //TODO: add null annotations @SuppressWarnings("unused") //TODO: remove unused annotation public class BusinessCalendar extends Calendar { + private final LocalDate firstValidDate; + private final LocalDate lastValidDate; + private final BusinessSchedule standardBusinessSchedule; + private final Set weekendDays; + private final Map> holidays; + + // region Exceptions + + /** + * A runtime exception that is thrown when a date is invalid. + */ + public static class InvalidDateException extends RuntimeException { + /** + * Creates a new exception. + * + * @param message exception message. + */ + private InvalidDateException(String message) { + super(message); + } + + /** + * Creates a new exception. + * + * @param message exception message. + * @param cause cause of the exception. + */ + public InvalidDateException(String message, Throwable cause) { + super(message, cause); + } + } + + // endregion + + ** + + // region Cache + + private final Map> cachedSchedules = new HashMap<>(); + + private void populateSchedules() { + LocalDate date = firstValidDate; + + while(date.compareTo(lastValidDate) <= 0) { + + final BusinessSchedule s = holidays.get(date); + + if( s != null){ + cachedSchedules.put(date, s); + } else if(weekendDays.contains(date.getDayOfWeek())) { + cachedSchedules.put(date, BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone())); + } else { + cachedSchedules.put(date, BusinessSchedule.toInstant(standardBusinessSchedule, date, timeZone())); + } + + date = date.plusDays(1); + } + } + + //TODO: populate year data + private final Map cachedYearData = new HashMap<>(); + + private static class YearData { + private final ZonedDateTime start; //TODO: type? + private final ZonedDateTime end; //TODO: type? + private final long businessTimeNanos; + + public YearData(final ZonedDateTime start, final ZonedDateTime end, final long businessTimeNanos) { + this.start = start; + this.end = end; + this.businessTimeNanos = businessTimeNanos; + } + } + + private void populateCachedYearData() { + // Only cache complete years, since incomplete years can not be fully computed. + + final int yearStart = firstValidDate.getDayOfYear() == 1 ? firstValidDate.getYear() : firstValidDate.getYear() + 1; + final int yearEnd = ((lastValidDate.isLeapYear() && lastValidDate.getDayOfYear() == 366) || lastValidDate.getDayOfYear() == 365) ? lastValidDate.getYear() : lastValidDate.getYear() - 1; + + for(int year=yearStart; year<= yearEnd; year++){ + final LocalDate startDate = LocalDate.ofYearDay(year, 0); + final LocalDate endDate = LocalDate.ofYearDay(year+1, 0); + final ZonedDateTime start =startDate.atTime(0,0).atZone(timeZone()); + final ZonedDateTime end = endDate.atTime(0,0).atZone(timeZone()); + + LocalDate date = startDate; + long businessTimeNanos = 0; + + while (date.isBefore(endDate)) { + final BusinessSchedule bs = businessSchedule(date); + businessTimeNanos += bs.businessNanos(); + date = date.plusDays(1); + } + + final YearData yd = new YearData(start, end, businessTimeNanos); + cachedYearData.put(year, yd); + } + } + + // endregion + + // region Constructors + + public BusinessCalendar(String name, String description, ZoneId timeZone, LocalDate firstValidDate, LocalDate lastValidDate, BusinessSchedule standardBusinessSchedule, Set weekendDays, Map> holidays) { + super(name, description, timeZone); + this.firstValidDate = firstValidDate; + this.lastValidDate = lastValidDate; + this.standardBusinessSchedule = standardBusinessSchedule; + this.weekendDays = weekendDays; + this.holidays = holidays; + populateSchedules(); + populateCachedYearData(); + } + + // endregion + // region Business Schedule + /** + * Gets the business schedule for a standard business day. + * + * @return business schedule for a standard business day. + */ + public BusinessSchedule standardBusinessSchedule() { + return standardBusinessSchedule; + } + + /** + * Returns the length of a standard business day in nanoseconds. + * + * @return length of a standard business day in nanoseconds. + */ + public long standardBusinessDayLengthNanos() { + return standardBusinessSchedule.businessNanos(); + } + /** * Gets business schedules for dates that are different from the defaults. This returns all dates that are defined * as a holiday for the calendar. * * @return a map of dates and to their business periods */ - public Map holidays() { + public Map> holidays() { return Collections.unmodifiableMap(holidays); } @@ -48,8 +179,16 @@ public Map holidays() { * @param date date * @return the corresponding BusinessSchedule of {@code date} */ - public BusinessSchedule businessSchedule(final LocalDate date) { - return dates.computeIfAbsent(date, this::newBusinessDay); + public BusinessSchedule businessSchedule(final LocalDate date) { + Require.neqNull(date, "date"); + + if(date.isBefore(firstValidDate)){ + throw new InvalidDateException("Date is before the first valid business calendar date: date=" + date + " firstValidDate=" + firstValidDate); + } else if(date.isAfter(lastValidDate)){ + throw new InvalidDateException("Date is after the last valid business calendar date: date=" + date + " lastValidDate=" + lastValidDate); + } + + return cachedSchedules.get(date); } /** @@ -58,12 +197,9 @@ public BusinessSchedule businessSchedule(final LocalDate date) { * @param time time * @return the corresponding BusinessSchedule of {@code time}; null if time is null */ - public BusinessSchedule businessSchedule(final ZonedDateTime time) { - if (time == null) { - return null; - } - - return businessSchedule(time.withZoneSameInstant(timeZone())); + public BusinessSchedule businessSchedule(final ZonedDateTime time) { + Require.neqNull(time, "time"); + return businessSchedule(time.withZoneSameInstant(timeZone()).toLocalDate()); } /** @@ -72,11 +208,8 @@ public BusinessSchedule businessSchedule(final ZonedDateTime time) { * @param time time * @return the corresponding BusinessSchedule of {@code time}; null if time is null */ - public BusinessSchedule businessSchedule(final Instant time) { - if (time == null) { - return null; - } - + public BusinessSchedule businessSchedule(final Instant time) { + Require.neqNull(time, "time"); return businessSchedule(time.atZone(timeZone())); } @@ -86,11 +219,8 @@ public BusinessSchedule businessSchedule(final Instant time) { * @param date date * @return the corresponding BusinessSchedule of {@code date} */ - public BusinessSchedule businessSchedule(String date) { - if (date == null) { - return null; - } - + public BusinessSchedule businessSchedule(String date) { + Require.neqNull(date, "date"); return businessSchedule(DateTimeUtils.parseLocalDate(date)); } @@ -100,7 +230,7 @@ public BusinessSchedule businessSchedule(String date) { * * @return today's business schedule */ - public BusinessSchedule currentBusinessSchedule() { + public BusinessSchedule currentBusinessSchedule() { return businessSchedule(currentDate()); } @@ -115,7 +245,7 @@ public BusinessSchedule currentBusinessSchedule() { * @return true if the date is a business day; false otherwise. */ public boolean isBusinessDay(final LocalDate date) { - return date != null && businessSchedule(date).isBusinessDay(); + return businessSchedule(date).isBusinessDay(); } /** @@ -125,14 +255,9 @@ public boolean isBusinessDay(final LocalDate date) { * @return true if the date is a business day; false otherwise. */ public boolean isBusinessDay(final String date) { - if (date == null) { - return false; - } - - return isBusinessDay(DateTimeUtils.parseLocalDate(date)); + return businessSchedule(date).isBusinessDay(); } - //TODO: review func /** * Does time occur on a business day? * @@ -140,10 +265,9 @@ public boolean isBusinessDay(final String date) { * @return true if the date is a business day; false otherwise. */ public boolean isBusinessDay(final ZonedDateTime time){ - return fractionOfStandardBusinessDay(time) > 0.0; + return businessSchedule(time).isBusinessDay(); } - //TODO: review func /** * Does time occur on a business day? * @@ -151,7 +275,7 @@ public boolean isBusinessDay(final ZonedDateTime time){ * @return true if the date is a business day; false otherwise. */ public boolean isBusinessDay(final Instant time){ - return fractionOfStandardBusinessDay(time) > 0.0; + return businessSchedule(time).isBusinessDay(); } /** @@ -165,7 +289,6 @@ public boolean isBusinessDay(DayOfWeek day){ return !weekendDays.contains(day); } - //TODO: base on the current day or time? /** * Is the current day a business day? * @@ -187,10 +310,10 @@ boolean isLastBusinessDayOfMonth(final LocalDate date) { return false; } - final LocalDate nextBusAfterDate = futureBusinessDate(date); + final LocalDate nextBusAfterDate = plusBusinessDays(date, 1); if(nextBusAfterDate == null){ - ** raise an error; + //TODO ** raise an error; return false; } @@ -206,7 +329,7 @@ boolean isLastBusinessDayOfMonth(final LocalDate date) { */ public boolean isLastBusinessDayOfMonth(final ZonedDateTime time) { if(time == null){ - ** raise an error; + //TODO ** raise an error; return false; } @@ -222,7 +345,7 @@ public boolean isLastBusinessDayOfMonth(final ZonedDateTime time) { */ public boolean isLastBusinessDayOfMonth(final Instant time) { if(time == null){ - ** raise an error; + //TODO ** raise an error; return false; } @@ -237,7 +360,7 @@ public boolean isLastBusinessDayOfMonth(final Instant time) { */ boolean isLastBusinessDayOfMonth(final String date) { if(date == null){ - ** raise an error; + //TODO ** raise an error; return false; } @@ -261,7 +384,7 @@ public boolean isLastBusinessDayOfMonth() { */ public boolean isLastBusinessDayOfWeek(final LocalDate date){ if(date == null){ - *** error *** + //TODO: *** error *** return false; } @@ -269,8 +392,8 @@ public boolean isLastBusinessDayOfWeek(final LocalDate date){ return false; } - final LocalDate nextBusinessDay = futureBusinessDate(date); - return dayOfWeek(date).compareTo(dayOfWeek(nextBusinessDay)) > 0 || numberCalendarDates(date, nextBusinessDay) > 6; + final LocalDate nextBusinessDay = plusBusinessDays(date, 1); + return date.getDayOfWeek().compareTo(nextBusinessDay.getDayOfWeek()) > 0 || numberCalendarDates(date, nextBusinessDay) > 6; } /** @@ -282,7 +405,7 @@ public boolean isLastBusinessDayOfWeek(final LocalDate date){ */ public boolean isLastBusinessDayOfWeek(final ZonedDateTime time) { if(time == null){ - *** error ***; + //TODO: *** error ***; return false; } @@ -298,7 +421,7 @@ public boolean isLastBusinessDayOfWeek(final ZonedDateTime time) { */ public boolean isLastBusinessDayOfWeek(final Instant time) { if(time == null){ - *** error ***; + //TODO: *** error ***; return false; } @@ -313,7 +436,7 @@ public boolean isLastBusinessDayOfWeek(final Instant time) { */ public boolean isLastBusinessDayOfWeek(final String date){ if(date == null){ - *** error ***; + //TODO: *** error ***; return false; } @@ -359,14 +482,6 @@ public boolean isBusinessTime(final Instant time) { return time != null && businessSchedule(time).isBusinessTime(time); } - /** - * Returns the length of a standard business day in nanoseconds. - * - * @return length of a standard business day in nanoseconds. - */ - public long standardBusinessDayLengthNanos() { - return lengthOfDefaultDayNanos; - } /** * For the given date, returns the ratio of the business day length and the standard business day length. For @@ -378,8 +493,8 @@ public long standardBusinessDayLengthNanos() { * @return ratio of the business day length and the standard business day length for the date */ public double fractionOfStandardBusinessDay(final LocalDate date){ - final BusinessSchedule schedule = businessSchedule(date); - return schedule == null ? 0.0 : (double) schedule.getLOBD() / (double) standardBusinessDayLengthNanos(); + final BusinessSchedule schedule = businessSchedule(date); + return schedule == null ? 0.0 : (double) schedule.businessNanos() / (double) standardBusinessDayLengthNanos(); } /** @@ -428,17 +543,17 @@ public double fractionOfStandardBusinessDay() { * @return the fraction of the day left after {@code time}; NULL_DOUBLE if time is null */ public double fractionOfBusinessDayRemaining(final Instant time){ - final BusinessSchedule businessDate = businessSchedule(time); + final BusinessSchedule businessDate = businessSchedule(time); if (businessDate == null) { return QueryConstants.NULL_DOUBLE; } - if (businessDate.getLOBD() == 0) { + if (businessDate.businessNanos() == 0) { return 0; } - final long businessDaySoFar = businessDate.businessTimeElapsed(time); - return (double) (businessDate.getLOBD() - businessDaySoFar) / (double) businessDate.getLOBD(); + final long businessDaySoFar = businessDate.businessNanosElapsed(time); + return (double) (businessDate.businessNanos() - businessDaySoFar) / (double) businessDate.businessNanos(); } /** @@ -813,12 +928,12 @@ public long diffBusinessNanos(final Instant start, final Instant end) { while (!DateTimeUtils.isAfter(day, end)) { if (isBusinessDay(day)) { - BusinessSchedule businessDate = businessSchedule(day); + BusinessSchedule businessDate = businessSchedule(day); if (businessDate != null) { - for (BusinessPeriod businessPeriod : businessDate.getBusinessPeriods()) { - Instant endOfPeriod = businessPeriod.getEndTime(); - Instant startOfPeriod = businessPeriod.getStartTime(); + for (BusinessPeriod businessPeriod : businessDate.periods()) { + Instant endOfPeriod = businessPeriod.end(); + Instant startOfPeriod = businessPeriod.start(); // noinspection StatementWithEmptyBody if (DateTimeUtils.isAfter(day, endOfPeriod) || DateTimeUtils.isBefore(end, startOfPeriod)) { @@ -827,7 +942,7 @@ public long diffBusinessNanos(final Instant start, final Instant end) { if (DateTimeUtils.isBefore(end, endOfPeriod)) { dayDiffNanos += DateTimeUtils.minus(end, startOfPeriod); } else { - dayDiffNanos += businessPeriod.getLength(); + dayDiffNanos += businessPeriod.nanos(); } } else { if (DateTimeUtils.isAfter(end, endOfPeriod)) { @@ -839,7 +954,7 @@ public long diffBusinessNanos(final Instant start, final Instant end) { } } } - day = businessSchedule(futureBusinessDate(day)).getSOBD(); + day = businessSchedule(plusBusinessDays(day,1)).businessStart(); } return dayDiffNanos; } @@ -950,7 +1065,29 @@ public double diffNonBusinessDays(final ZonedDateTime start, final ZonedDateTime return QueryConstants.NULL_DOUBLE; } - return diffNonBusinessDays(start.toInstant(), end.toInstant()); + double businessYearDiff = 0.0; + ZonedDateTime time = start; + + while (!DateTimeUtils.isAfter(time, end)) { + final int year = time.getYear(); + final YearData yd = cachedYearData.get(year); + + if(yd == null){ + throw new InvalidDateException("Business calendar does not contain a complete year for: year=" + year); + } + + final long yearDiff; + if (DateTimeUtils.isAfter(yd.end, end)) { + yearDiff = diffBusinessNanos(time, end); + } else { + yearDiff = diffBusinessNanos(time, yd.end); + } + + businessYearDiff += (double) yearDiff / (double) yd.businessTimeNanos; + time = yd.end; + } + + return businessYearDiff; } /** @@ -965,26 +1102,7 @@ public double diffBusinessYears(final Instant start, final Instant end){ return QueryConstants.NULL_DOUBLE; } - double businessYearDiff = 0.0; - Instant time = start; - while (!DateTimeUtils.isAfter(time, end)) { - // get length of the business year - final int startYear = DateTimeUtils.year(start, timeZone()); - final long businessYearLength = cachedYearLengths.computeIfAbsent(startYear, this::getBusinessYearLength); - - final Instant endOfYear = getFirstBusinessDateTimeOfYear(startYear + 1); - final long yearDiff; - if (DateTimeUtils.isAfter(endOfYear, end)) { - yearDiff = diffBusinessNanos(time, end); - } else { - yearDiff = diffBusinessNanos(time, endOfYear); - } - - businessYearDiff += (double) yearDiff / (double) businessYearLength; - time = endOfYear; - } - - return businessYearDiff; + return diffBusinessYears(DateTimeUtils.toZonedDateTime(start, timeZone()), DateTimeUtils.toZonedDateTime(end, timeZone())); } /** From 185a014957b835c1d072398db1906ff8d1e7ebb6 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Mon, 3 Jul 2023 20:51:49 -0700 Subject: [PATCH 012/150] BusinessCalendar refactoring and cleanup: * Business Schedule --- .../time/calendar/BusinessCalendar.java | 90 +++++++++++++------ 1 file changed, 63 insertions(+), 27 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index c4d93f665c3..d19b49d5e27 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -4,6 +4,7 @@ package io.deephaven.time.calendar; import io.deephaven.base.verify.Require; +import io.deephaven.base.verify.RequirementFailure; import io.deephaven.time.DateTimeUtils; import io.deephaven.util.QueryConstants; @@ -60,11 +61,10 @@ public InvalidDateException(String message, Throwable cause) { // endregion - ** - // region Cache private final Map> cachedSchedules = new HashMap<>(); + private final Map cachedYearData = new HashMap<>(); private void populateSchedules() { LocalDate date = firstValidDate; @@ -85,9 +85,6 @@ private void populateSchedules() { } } - //TODO: populate year data - private final Map cachedYearData = new HashMap<>(); - private static class YearData { private final ZonedDateTime start; //TODO: type? private final ZonedDateTime end; //TODO: type? @@ -106,11 +103,11 @@ private void populateCachedYearData() { final int yearStart = firstValidDate.getDayOfYear() == 1 ? firstValidDate.getYear() : firstValidDate.getYear() + 1; final int yearEnd = ((lastValidDate.isLeapYear() && lastValidDate.getDayOfYear() == 366) || lastValidDate.getDayOfYear() == 365) ? lastValidDate.getYear() : lastValidDate.getYear() - 1; - for(int year=yearStart; year<= yearEnd; year++){ - final LocalDate startDate = LocalDate.ofYearDay(year, 0); - final LocalDate endDate = LocalDate.ofYearDay(year+1, 0); - final ZonedDateTime start =startDate.atTime(0,0).atZone(timeZone()); - final ZonedDateTime end = endDate.atTime(0,0).atZone(timeZone()); + for (int year = yearStart; year <= yearEnd; year++) { + final LocalDate startDate = LocalDate.ofYearDay(year, 0); + final LocalDate endDate = LocalDate.ofYearDay(year + 1, 0); + final ZonedDateTime start = startDate.atTime(0, 0).atZone(timeZone()); + final ZonedDateTime end = endDate.atTime(0, 0).atZone(timeZone()); LocalDate date = startDate; long businessTimeNanos = 0; @@ -145,8 +142,9 @@ public BusinessCalendar(String name, String description, ZoneId timeZone, LocalD // region Business Schedule + //TODO: rename? /** - * Gets the business schedule for a standard business day. + * Business schedule for a standard business day. * * @return business schedule for a standard business day. */ @@ -154,30 +152,33 @@ public BusinessSchedule standardBusinessSchedule() { return standardBusinessSchedule; } + //TODO: rename? /** - * Returns the length of a standard business day in nanoseconds. + * Length of a standard business day in nanoseconds. * - * @return length of a standard business day in nanoseconds. + * @return length of a standard business day in nanoseconds */ public long standardBusinessDayLengthNanos() { return standardBusinessSchedule.businessNanos(); } /** - * Gets business schedules for dates that are different from the defaults. This returns all dates that are defined - * as a holiday for the calendar. + * Business schedules for all holidays. A holiday is a date that has a schedule that is different from + * the schedule for a standard business day or weekend. * - * @return a map of dates and to their business periods + * @return a map of holiday dates and their business periods */ public Map> holidays() { return Collections.unmodifiableMap(holidays); } /** - * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. + * Gets the indicated business day's schedule. * * @param date date * @return the corresponding BusinessSchedule of {@code date} + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ public BusinessSchedule businessSchedule(final LocalDate date) { Require.neqNull(date, "date"); @@ -192,10 +193,12 @@ public BusinessSchedule businessSchedule(final LocalDate date) { } /** - * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. + * Gets the indicated business day's schedule. * * @param time time - * @return the corresponding BusinessSchedule of {@code time}; null if time is null + * @return the corresponding BusinessSchedule of {@code date} + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ public BusinessSchedule businessSchedule(final ZonedDateTime time) { Require.neqNull(time, "time"); @@ -203,10 +206,12 @@ public BusinessSchedule businessSchedule(final ZonedDateTime time) { } /** - * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. + * Gets the indicated business day's schedule. * * @param time time - * @return the corresponding BusinessSchedule of {@code time}; null if time is null + * @return the corresponding BusinessSchedule of {@code date} + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ public BusinessSchedule businessSchedule(final Instant time) { Require.neqNull(time, "time"); @@ -214,10 +219,13 @@ public BusinessSchedule businessSchedule(final Instant time) { } /** - * Gets the indicated business day's schedule. {@code getBusinessSchedule(null)} returns {@code null}. + * Gets the indicated business day's schedule. * * @param date date * @return the corresponding BusinessSchedule of {@code date} + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public BusinessSchedule businessSchedule(String date) { Require.neqNull(date, "date"); @@ -236,13 +244,17 @@ public BusinessSchedule currentBusinessSchedule() { // endregion + *** + // region Business Day /** * Does time occur on a business day? * * @param date date - * @return true if the date is a business day; false otherwise. + * @return true if the date is a business day; false otherwise + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range. */ public boolean isBusinessDay(final LocalDate date) { return businessSchedule(date).isBusinessDay(); @@ -252,8 +264,11 @@ public boolean isBusinessDay(final LocalDate date) { * Is the date a business day? * * @param date date - * @return true if the date is a business day; false otherwise. + * @return true if the date is a business day; false otherwise + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range. */ + ** public boolean isBusinessDay(final String date) { return businessSchedule(date).isBusinessDay(); } @@ -262,7 +277,9 @@ public boolean isBusinessDay(final String date) { * Does time occur on a business day? * * @param time time - * @return true if the date is a business day; false otherwise. + * @return true if the date is a business day; false otherwise + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range. */ public boolean isBusinessDay(final ZonedDateTime time){ return businessSchedule(time).isBusinessDay(); @@ -272,12 +289,16 @@ public boolean isBusinessDay(final ZonedDateTime time){ * Does time occur on a business day? * * @param time time - * @return true if the date is a business day; false otherwise. + * @return true if the date is a business day; false otherwise + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range. */ public boolean isBusinessDay(final Instant time){ return businessSchedule(time).isBusinessDay(); } + ** + /** * Is the day of the week a business day? A business day is a day that has a business schedule with one or more * business periods defined. @@ -286,6 +307,7 @@ public boolean isBusinessDay(final Instant time){ * @return true if the day is a business day; false otherwise. */ public boolean isBusinessDay(DayOfWeek day){ + ** null return !weekendDays.contains(day); } @@ -298,14 +320,18 @@ public boolean isBusinessDay() { return isBusinessDay(currentDate()); } + *** /** * Is the time on the last business day of the month with business time remaining? * * @param date date * @return true if {@code date} is on the last business day of the month with business time remaining; false * otherwise. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range. */ boolean isLastBusinessDayOfMonth(final LocalDate date) { + *** null if (!isBusinessDay(date)) { return false; } @@ -320,14 +346,18 @@ boolean isLastBusinessDayOfMonth(final LocalDate date) { return date.getMonth() != nextBusAfterDate.getMonth(); } + *** /** * Is the time on the last business day of the month with business time remaining? * * @param time time * @return true if {@code time} is on the last business day of the month with business time remaining; false * otherwise. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range. */ public boolean isLastBusinessDayOfMonth(final ZonedDateTime time) { + *** null if(time == null){ //TODO ** raise an error; return false; @@ -336,12 +366,15 @@ public boolean isLastBusinessDayOfMonth(final ZonedDateTime time) { return isLastBusinessDayOfMonth(DateTimeUtils.toLocalDate(time.withZoneSameInstant(timeZone()))); } + *** /** * Is the time on the last business day of the month with business time remaining? * * @param time time * @return true if {@code time} is on the last business day of the month with business time remaining; false * otherwise. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range. */ public boolean isLastBusinessDayOfMonth(final Instant time) { if(time == null){ @@ -352,11 +385,14 @@ public boolean isLastBusinessDayOfMonth(final Instant time) { return isLastBusinessDayOfMonth(DateTimeUtils.toLocalDate(time, timeZone())); } + *** /** * Is the date the last business day of the month? * * @param date date - * @return true if {@code date} is on the last business day of the month; false otherwise. + * @return true if {@code date} is on the last business day of the month; false otherwise + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range. */ boolean isLastBusinessDayOfMonth(final String date) { if(date == null){ From 82d04be58521f827879e7460a53d6bad29a95ecc Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 4 Jul 2023 16:34:41 -0700 Subject: [PATCH 013/150] BusinessCalendar refactoring and cleanup: * Business Day --- .../time/calendar/BusinessCalendar.java | 216 +++++++++++------- 1 file changed, 130 insertions(+), 86 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index d19b49d5e27..bf3ec94074c 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -244,17 +244,15 @@ public BusinessSchedule currentBusinessSchedule() { // endregion - *** - // region Business Day /** - * Does time occur on a business day? + * Is the date a business day? * * @param date date * @return true if the date is a business day; false otherwise * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range. + * @throws InvalidDateException if the date is not in the valid range */ public boolean isBusinessDay(final LocalDate date) { return businessSchedule(date).isBusinessDay(); @@ -266,72 +264,70 @@ public boolean isBusinessDay(final LocalDate date) { * @param date date * @return true if the date is a business day; false otherwise * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range. + * @throws InvalidDateException if the date is not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - ** public boolean isBusinessDay(final String date) { return businessSchedule(date).isBusinessDay(); } /** - * Does time occur on a business day? + * Is the time on a business day? * * @param time time * @return true if the date is a business day; false otherwise * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range. + * @throws InvalidDateException if the date is not in the valid range */ public boolean isBusinessDay(final ZonedDateTime time){ return businessSchedule(time).isBusinessDay(); } /** - * Does time occur on a business day? + * Is the time on a business day? * * @param time time * @return true if the date is a business day; false otherwise * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range. + * @throws InvalidDateException if the date is not in the valid range */ public boolean isBusinessDay(final Instant time){ return businessSchedule(time).isBusinessDay(); } - ** - + //TODO: rename? /** - * Is the day of the week a business day? A business day is a day that has a business schedule with one or more - * business periods defined. + * Is the day of the week a normal business day? * * @param day a day of the week - * @return true if the day is a business day; false otherwise. + * @return true if the day is a business day; false otherwise + * @throws RequirementFailure if the input is null */ public boolean isBusinessDay(DayOfWeek day){ - ** null + Require.neqNull(day, "day"); return !weekendDays.contains(day); } /** * Is the current day a business day? * - * @return true if the current day is a business day; false otherwise. + * @return true if the current day is a business day; false otherwise */ public boolean isBusinessDay() { return isBusinessDay(currentDate()); } - *** /** - * Is the time on the last business day of the month with business time remaining? + * Is the date the last business day of the month? * * @param date date - * @return true if {@code date} is on the last business day of the month with business time remaining; false - * otherwise. + * @return true if {@code date} is the last business day of the month; false otherwise * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range. + * @throws InvalidDateException if the date is not in the valid range */ boolean isLastBusinessDayOfMonth(final LocalDate date) { - *** null + Require.neqNull(date, "date"); + if (!isBusinessDay(date)) { return false; } @@ -346,67 +342,50 @@ boolean isLastBusinessDayOfMonth(final LocalDate date) { return date.getMonth() != nextBusAfterDate.getMonth(); } - *** /** - * Is the time on the last business day of the month with business time remaining? + * Is the time on the last business day of the month? * * @param time time - * @return true if {@code time} is on the last business day of the month with business time remaining; false - * otherwise. + * @return true if {@code time} is on the last business day of the month; false otherwise * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range. + * @throws InvalidDateException if the date is not in the valid range */ public boolean isLastBusinessDayOfMonth(final ZonedDateTime time) { - *** null - if(time == null){ - //TODO ** raise an error; - return false; - } - + Require.neqNull(time, "time"); return isLastBusinessDayOfMonth(DateTimeUtils.toLocalDate(time.withZoneSameInstant(timeZone()))); } - *** /** - * Is the time on the last business day of the month with business time remaining? + * Is the time on the last business day of the month? * * @param time time - * @return true if {@code time} is on the last business day of the month with business time remaining; false - * otherwise. + * @return true if {@code time} is on the last business day of the month; false otherwise * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range. + * @throws InvalidDateException if the date is not in the valid range */ public boolean isLastBusinessDayOfMonth(final Instant time) { - if(time == null){ - //TODO ** raise an error; - return false; - } - + Require.neqNull(time, "time"); return isLastBusinessDayOfMonth(DateTimeUtils.toLocalDate(time, timeZone())); } - *** /** * Is the date the last business day of the month? * * @param date date - * @return true if {@code date} is on the last business day of the month; false otherwise + * @return true if {@code time} is on the last business day of the month; false otherwise * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range. + * @throws InvalidDateException if the date is not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ boolean isLastBusinessDayOfMonth(final String date) { - if(date == null){ - //TODO ** raise an error; - return false; - } - + Require.neqNull(date, "date"); return isLastBusinessDayOfMonth(DateTimeUtils.parseLocalDate(date)); } /** - * Is the current day the last business day of the month? + * Is the current date the last business day of the month? * - * @return true if {@code date} is on the last business day of the month; false otherwise. + * @return true if the current date is the last business day of the month; false otherwise. */ public boolean isLastBusinessDayOfMonth() { return isLastBusinessDayOfMonth(currentDate()); @@ -416,13 +395,12 @@ public boolean isLastBusinessDayOfMonth() { * Is the date the last business day of the week? * * @param date date - * @return true if {@code date} is on the last business day of the week; false otherwise. + * @return true if {@code date} is on the last business day of the week; false otherwise + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ public boolean isLastBusinessDayOfWeek(final LocalDate date){ - if(date == null){ - //TODO: *** error *** - return false; - } + Require.neqNull(date, "date"); if (!isBusinessDay(date)) { return false; @@ -433,66 +411,132 @@ public boolean isLastBusinessDayOfWeek(final LocalDate date){ } /** - * Is the time on the last business day of the week with business time remaining? + * Is the time on the last business day of the week? * * @param time time - * @return true if {@code time} is on the last business day of the week with business time remaining; false - * otherwise. + * @return true if {@code time} is on the last business day of the week; false otherwise + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ public boolean isLastBusinessDayOfWeek(final ZonedDateTime time) { - if(time == null){ - //TODO: *** error ***; - return false; - } - + Require.neqNull(time, "time"); return isLastBusinessDayOfWeek(DateTimeUtils.toLocalDate(time, timeZone())); } /** - * Is the time on the last business day of the week with business time remaining? + * Is the time on the last business day of the week? * * @param time time - * @return true if {@code time} is on the last business day of the week with business time remaining; false - * otherwise. + * @return true if {@code time} is on the last business day of the week; false otherwise + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ public boolean isLastBusinessDayOfWeek(final Instant time) { - if(time == null){ - //TODO: *** error ***; - return false; - } - + Require.neqNull(time, "time"); return isLastBusinessDayOfWeek(DateTimeUtils.toLocalDate(time, timeZone())); } /** - * Is the date the last business day of the week? + * Is the date is last business day of the week? * * @param date date - * @return true if {@code date} is on the last business day of the week; false otherwise. + * @return true if {@code date} is the last business day of the week; false otherwise + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public boolean isLastBusinessDayOfWeek(final String date){ - if(date == null){ - //TODO: *** error ***; - return false; - } - + Require.neqNull(date, "date"); return isLastBusinessDayOfWeek(DateTimeUtils.parseLocalDate(date)); } /** - * Is the current day the last business day of the week? + * Is the current date the last business day of the week? * - * @return true if {@code date} is on the last business day of the week; false otherwise. + * @return true if the current date is the last business day of the week; false otherwise. */ public boolean isLastBusinessDayOfWeek() { return isLastBusinessDayOfWeek(currentDate()); } - //TODO: isLastBusinessDayOfYear() - //TODO: isLastNonBusinessDayOfYear() -> and other non business day equivalents + /** + * Is the date the last business day of the year? + * + * @param date date + * @return true if {@code date} is the last business day of the year; false otherwise + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + */ + boolean isLastBusinessDayOfYear(final LocalDate date) { + Require.neqNull(date, "date"); + + if (!isBusinessDay(date)) { + return false; + } + + final LocalDate nextBusAfterDate = plusBusinessDays(date, 1); + + if(nextBusAfterDate == null){ + //TODO ** raise an error; + return false; + } + + return date.getYear() != nextBusAfterDate.getYear(); + } + + /** + * Is the time on the last business day of the year? + * + * @param time time + * @return true if {@code time} is on the last business day of the year; false otherwise + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + */ + public boolean isLastBusinessDayOfYear(final ZonedDateTime time) { + Require.neqNull(time, "time"); + return isLastBusinessDayOfYear(DateTimeUtils.toLocalDate(time.withZoneSameInstant(timeZone()))); + } + + /** + * Is the time on the last business day of the year? + * + * @param time time + * @return true if {@code time} is on the last business day of the year; false otherwise + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + */ + public boolean isLastBusinessDayOfYear(final Instant time) { + Require.neqNull(time, "time"); + return isLastBusinessDayOfYear(DateTimeUtils.toLocalDate(time, timeZone())); + } + + /** + * Is the date the last business day of the year? + * + * @param date date + * @return true if {@code time} is on the last business day of the year; false otherwise + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed + */ + boolean isLastBusinessDayOfYear(final String date) { + Require.neqNull(date, "date"); + return isLastBusinessDayOfYear(DateTimeUtils.parseLocalDate(date)); + } + + /** + * Is the current date the last business day of the year? + * + * @return true if the current date is the last business day of the year; false otherwise. + */ + public boolean isLastBusinessDayOfYear() { + return isLastBusinessDayOfYear(currentDate()); + } // endregion + *** + // region Business Time /** From 83e3b9d929300494564943e091eb2fa940f521ff Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 4 Jul 2023 16:58:42 -0700 Subject: [PATCH 014/150] BusinessCalendar refactoring and cleanup: * Business Time --- .../time/calendar/BusinessCalendar.java | 197 ++++++++++++------ 1 file changed, 130 insertions(+), 67 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index bf3ec94074c..7a4ef8ebccd 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -535,152 +535,215 @@ public boolean isLastBusinessDayOfYear() { // endregion - *** - // region Business Time /** - * Determines if the specified time is a business time. If the time falls between business periods, false will be - * returned. + * Determines if the specified time is a business time. + * Business times fall within business periods of the day's business schedule. * * @param time time * @return true if the specified time is a business time; otherwise, false. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ public boolean isBusinessTime(final ZonedDateTime time) { - return time != null && businessSchedule(time).isBusinessTime(time); + Require.neqNull(time, "time"); + return businessSchedule(time).isBusinessTime(time.toInstant()); } - //TODO: zero arg version? /** - * Determines if the specified time is a business time. If the time falls between business periods, false will be - * returned. + * Determines if the specified time is a business time. + * Business times fall within business periods of the day's business schedule. * * @param time time * @return true if the specified time is a business time; otherwise, false. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ public boolean isBusinessTime(final Instant time) { - return time != null && businessSchedule(time).isBusinessTime(time); + Require.neqNull(time, "time"); + return businessSchedule(time).isBusinessTime(time); } + /** + * Determines if the current time is a business time. + * Business times fall within business periods of the day's business schedule. + * + * @return true if the specified time is a business time; otherwise, false. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + */ + public boolean isBusinessTime() { + return isBusinessTime(DateTimeUtils.now()); + } /** - * For the given date, returns the ratio of the business day length and the standard business day length. For - * example, a holiday has zero business time and will therefore return 0.0. A normal business day will be of the - * standard length and will therefore return 1.0. A half day holiday will return 0.5. + * Returns the ratio of the business day length and the standard business day length. + * For example, a holiday has zero business time and will therefore return 0.0. + * A normal business day will be of the standard length and will therefore return 1.0. + * A half day holiday will return 0.5. * - * @see BusinessCalendar#fractionOfBusinessDayRemaining(Instant) - * @param date date; if null, return 0 + * @param date date * @return ratio of the business day length and the standard business day length for the date + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ public double fractionOfStandardBusinessDay(final LocalDate date){ + Require.neqNull(date, "date"); final BusinessSchedule schedule = businessSchedule(date); - return schedule == null ? 0.0 : (double) schedule.businessNanos() / (double) standardBusinessDayLengthNanos(); + return (double) schedule.businessNanos() / (double) standardBusinessDayLengthNanos(); + } + + /** + * Returns the ratio of the business day length and the standard business day length. + * For example, a holiday has zero business time and will therefore return 0.0. + * A normal business day will be of the standard length and will therefore return 1.0. + * A half day holiday will return 0.5. + * + * @param date date + * @return ratio of the business day length and the standard business day length for the date + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed + */ + public double fractionOfStandardBusinessDay(final String date){ + Require.neqNull(date, "date"); + return fractionOfStandardBusinessDay(DateTimeUtils.parseLocalDate(date)); } /** - * For the given date, returns the ratio of the business day length and the standard business day length. For - * example, a holiday has zero business time and will therefore return 0.0. A normal business day will be of the - * standard length and will therefore return 1.0. A half day holiday will return 0.5. + * Returns the ratio of the business day length and the standard business day length. + * For example, a holiday has zero business time and will therefore return 0.0. + * A normal business day will be of the standard length and will therefore return 1.0. + * A half day holiday will return 0.5. * - * @see BusinessCalendar#fractionOfBusinessDayRemaining(Instant) - * @param time time; if null, return 0 + * @param time time * @return ratio of the business day length and the standard business day length for the date + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ public double fractionOfStandardBusinessDay(final Instant time){ - return time == null ? 0.0 : fractionOfStandardBusinessDay(DateTimeUtils.toLocalDate(time, timeZone())); + Require.neqNull(time, "time"); + return fractionOfStandardBusinessDay(DateTimeUtils.toLocalDate(time, timeZone())); } /** - * For the given date, returns the ratio of the business day length and the standard business day length. For - * example, a holiday has zero business time and will therefore return 0.0. A normal business day will be of the - * standard length and will therefore return 1.0. A half day holiday will return 0.5. + * Returns the ratio of the business day length and the standard business day length. + * For example, a holiday has zero business time and will therefore return 0.0. + * A normal business day will be of the standard length and will therefore return 1.0. + * A half day holiday will return 0.5. * - * @see BusinessCalendar#fractionOfBusinessDayRemaining(Instant) - * @param time time; if null, return 0 + * @param time time * @return ratio of the business day length and the standard business day length for the date + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ public double fractionOfStandardBusinessDay(final ZonedDateTime time){ - return time == null ? 0.0 : fractionOfStandardBusinessDay(DateTimeUtils.toLocalDate(time.toInstant(), timeZone())); + Require.neqNull(time, "time"); + return fractionOfStandardBusinessDay(DateTimeUtils.toLocalDate(time.toInstant(), timeZone())); } - //TODO: add zero arg methods for other funcs /** - * Returns the ratio of the current day's business day length and the standard business day length. For example, a - * holiday has zero business time and will therefore return 0.0. A normal business day will be of the standard - * length and will therefore return 1.0. A half day holiday will return 0.5. + * Returns the ratio of the business day length and the standard business day length. + * For example, a holiday has zero business time and will therefore return 0.0. + * A normal business day will be of the standard length and will therefore return 1.0. + * A half day holiday will return 0.5. * - * @see BusinessCalendar#fractionOfBusinessDayRemaining(Instant) - * @return ratio of the business day length and the standard business day length for the current day + * @return ratio of the business day length and the standard business day length for the date + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ public double fractionOfStandardBusinessDay() { return fractionOfStandardBusinessDay(currentDate()); } + //TODO: remove Of from function names! /** - * Returns the fraction of the business day remaining after the given time. + * Fraction of the business day complete. * * @param time time - * @return the fraction of the day left after {@code time}; NULL_DOUBLE if time is null + * @return the fraction of the business day complete, or 1.0 if the day is not a business day + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfBusinessDayRemaining(final Instant time){ - final BusinessSchedule businessDate = businessSchedule(time); - if (businessDate == null) { - return QueryConstants.NULL_DOUBLE; - } + public double fractionOfBusinessDayComplete(final Instant time) { + Require.neqNull(time, "time"); + + final BusinessSchedule schedule = businessSchedule(time); - if (businessDate.businessNanos() == 0) { - return 0; + if(!schedule.isBusinessDay()) { + return 1.0; } - final long businessDaySoFar = businessDate.businessNanosElapsed(time); - return (double) (businessDate.businessNanos() - businessDaySoFar) / (double) businessDate.businessNanos(); + final long businessDaySoFar = schedule.businessNanosElapsed(time); + return (double) businessDaySoFar / (double) schedule.businessNanos(); } /** - * Returns the fraction of the business day remaining after the given time. + * Fraction of the business day complete. * * @param time time - * @return the fraction of the day left after {@code time}; NULL_DOUBLE if time is null + * @return the fraction of the business day complete, or 1.0 if the day is not a business day + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfBusinessDayRemaining(final ZonedDateTime time){ - if(time == null) { - return QueryConstants.NULL_DOUBLE; - } + public double fractionOfBusinessDayComplete(final ZonedDateTime time) { + Require.neqNull(time, "time"); + return fractionOfBusinessDayComplete(time.toInstant()); + } - return fractionOfBusinessDayRemaining(time.toInstant()); + /** + * Fraction of the current business day complete. + * + * @return the fraction of the business day complete, or 1.0 if the day is not a business day + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + */ + public double fractionOfBusinessDayComplete() { + return fractionOfBusinessDayComplete(DateTimeUtils.now()); } - //TODO: remove Of from function names! /** - * Returns the fraction of the business day complete by the given time. + * Fraction of the business day remaining. * * @param time time - * @return the fraction of the day complete by {@code time}; NULL_DOUBLE if time is null + * @return the fraction of the business day complete, or 0.0 if the day is not a business day + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfBusinessDayComplete(final Instant time) { - if (time == null) { - return QueryConstants.NULL_DOUBLE; - } - - return 1.0 - fractionOfBusinessDayRemaining(time); + public double fractionOfBusinessDayRemaining(final Instant time){ + Require.neqNull(time, "time"); + return 1.0 - fractionOfBusinessDayComplete(time); } /** - * Returns the fraction of the business day complete by the given time. + * Fraction of the business day remaining. * * @param time time - * @return the fraction of the day complete by {@code time}; NULL_DOUBLE if time is null + * @return the fraction of the business day complete, or 0.0 if the day is not a business day + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfBusinessDayComplete(final ZonedDateTime time) { - if (time == null) { - return QueryConstants.NULL_DOUBLE; - } + public double fractionOfBusinessDayRemaining(final ZonedDateTime time){ + Require.neqNull(time, "time"); + return 1.0 - fractionOfBusinessDayComplete(time); + } - return fractionOfBusinessDayComplete(time.toInstant()); + /** + * Fraction of the business day remaining. + * + * @return the fraction of the business day complete, or 0.0 if the day is not a business day + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + */ + public double fractionOfBusinessDayRemaining(){ + return fractionOfBusinessDayRemaining(DateTimeUtils.now()); } // endregion + *** + // region Ranges //TODO: consistently handle inclusive / exclusive in these ranges From 9bade1c0afeebf1c7919e368bf76d56655c01633 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 4 Jul 2023 20:39:47 -0700 Subject: [PATCH 015/150] BusinessCalendar refactoring and cleanup: * Arithmetic --- .../time/calendar/BusinessCalendar.java | 209 ++++++++++-------- 1 file changed, 115 insertions(+), 94 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index 7a4ef8ebccd..1e022f4b595 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -13,7 +13,7 @@ //TODO: update all headers //TODO: review all docs - +//TODO: add final to all methods /** * A business calendar, with the concept of business and non-business time. @@ -542,7 +542,7 @@ public boolean isLastBusinessDayOfYear() { * Business times fall within business periods of the day's business schedule. * * @param time time - * @return true if the specified time is a business time; otherwise, false. + * @return true if the specified time is a business time; otherwise, false * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ @@ -556,7 +556,7 @@ public boolean isBusinessTime(final ZonedDateTime time) { * Business times fall within business periods of the day's business schedule. * * @param time time - * @return true if the specified time is a business time; otherwise, false. + * @return true if the specified time is a business time; otherwise, false * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ @@ -569,7 +569,7 @@ public boolean isBusinessTime(final Instant time) { * Determines if the current time is a business time. * Business times fall within business periods of the day's business schedule. * - * @return true if the specified time is a business time; otherwise, false. + * @return true if the specified time is a business time; otherwise, false * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ @@ -1274,12 +1274,14 @@ public double diffBusinessYears(final ZonedDateTime start, final ZonedDateTime e * * @param date date * @param days number of days to add. - * @return {@code days} business days after {@code date}; null if {@code date} is null or if {@code date} is not a business day and {@code days} is zero. + * @return {@code days} business days after {@code date}; null if {@code date} is not a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate plusBusinessDays(final LocalDate date, int days) { - if (date == null) { - return null; - } else if(days == 0){ + public LocalDate plusBusinessDays(final LocalDate date, final int days) { + Require.neqNull(date, "date"); + + if(days == 0){ return isBusinessDay() ? date : null; } @@ -1300,44 +1302,41 @@ public LocalDate plusBusinessDays(final LocalDate date, int days) { * * @param date date * @param days number of days to add. - * @return {@code days} business days after {@code date}; null if {@code date} is null or if {@code date} is not a business day and {@code days} is zero. + * @return {@code days} business days after {@code date}; null if {@code date} is not a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public LocalDate plusBusinessDays(final String date, int days) { - if(date == null){ - return null; - } - - //TODO: should the date parsing be quiet? Document exceptions? + public LocalDate plusBusinessDays(final String date, final int days) { + Require.neqNull(date, "date"); return plusBusinessDays(DateTimeUtils.parseLocalDate(date), days); } /** - * Adds a specified number of business days to an input time. Adding negative days is equivalent to subtracting days. - * - * @param time time - * @param days number of days to add. - * @return {@code days} business days after {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. + * Adds a specified number of business days to an input date. Adding negative days is equivalent to subtracting days. + * + * @param time time + * @param days number of days to add. + * @return {@code days} business days after {@code time}; null if {@code time} is not a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate plusBusinessDays(final Instant time, int days) { - if(time == null){ - return null; - } - + public LocalDate plusBusinessDays(final Instant time, final int days) { + Require.neqNull(time, "time"); return plusBusinessDays(DateTimeUtils.toLocalDate(time, timeZone()), days); } /** - * Adds a specified number of business days to an input time. Adding negative days is equivalent to subtracting days. + * Adds a specified number of business days to an input date. Adding negative days is equivalent to subtracting days. * * @param time time * @param days number of days to add. - * @return {@code days} business days after {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. + * @return {@code days} business days after {@code time}; null if {@code time} is not a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate plusBusinessDays(final ZonedDateTime time, int days) { - if(time == null){ - return null; - } - + public LocalDate plusBusinessDays(final ZonedDateTime time, final int days) { + Require.neqNull(time, "time"); return plusBusinessDays(time.toInstant(), days); } @@ -1345,10 +1344,12 @@ public LocalDate plusBusinessDays(final ZonedDateTime time, int days) { * Subtracts a specified number of business days from an input date. Subtracting negative days is equivalent to adding days. * * @param date date - * @param days number of days to subtract. - * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. + * @param days number of days to add. + * @return {@code days} business days before {@code date}; null if {@code date} is not a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate minusBusinessDays(final LocalDate date, int days) { + public LocalDate minusBusinessDays(final LocalDate date, final int days) { return plusBusinessDays(date, -days); } @@ -1356,32 +1357,39 @@ public LocalDate minusBusinessDays(final LocalDate date, int days) { * Subtracts a specified number of business days from an input date. Subtracting negative days is equivalent to adding days. * * @param date date - * @param days number of days to subtract. - * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. + * @param days number of days to add. + * @return {@code days} business days before {@code date}; null if {@code date} is not a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public LocalDate minusBusinessDays(final String date, int days) { + public LocalDate minusBusinessDays(final String date, final int days) { return plusBusinessDays(date, -days); } /** - * Subtracts a specified number of business days from an input time. Subtracting negative days is equivalent to adding days. + * Subtracts a specified number of business days from an input date. Subtracting negative days is equivalent to adding days. * * @param time time - * @param days number of days to subtract. - * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. + * @param days number of days to add. + * @return {@code days} business days before {@code time}; null if {@code time} is not a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate minusBusinessDays(final Instant time, int days) { + public LocalDate minusBusinessDays(final Instant time, final int days) { return plusBusinessDays(time, -days); } /** - * Subtracts a specified number of business days from an input time. Subtracting negative days is equivalent to adding days. + * Subtracts a specified number of business days from an input date. Subtracting negative days is equivalent to adding days. * * @param time time - * @param days number of days to subtract. - * @return {@code days} business days before {@code time}; null if {@code date} is null or if {@code time} is not a business day and {@code days} is zero. + * @param days number of days to add. + * @return {@code days} business days before {@code time}; null if {@code time} is not a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate minusBusinessDays(final ZonedDateTime time, int days) { + public LocalDate minusBusinessDays(final ZonedDateTime time, final int days) { return plusBusinessDays(time, -days); } @@ -1390,12 +1398,14 @@ public LocalDate minusBusinessDays(final ZonedDateTime time, int days) { * * @param date date * @param days number of days to add. - * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. + * @return {@code days} non-business days after {@code date}; null if {@code date} is not a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate plusNonBusinessDays(final LocalDate date, int days) { - if (date == null) { - return null; - } else if(days == 0){ + public LocalDate plusNonBusinessDays(final LocalDate date, final int days) { + Require.neqNull(date, "date"); + + if(days == 0){ return isBusinessDay() ? null : date; } @@ -1416,43 +1426,41 @@ public LocalDate plusNonBusinessDays(final LocalDate date, int days) { * * @param date date * @param days number of days to add. - * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. + * @return {@code days} non-business days after {@code date}; null if {@code date} is not a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public LocalDate plusNonBusinessDays(final String date, int days) { - if(date == null){ - return null; - } - + public LocalDate plusNonBusinessDays(final String date, final int days) { + Require.neqNull(date, "date"); return this.plusNonBusinessDays(DateTimeUtils.parseLocalDate(date), days); } /** - * Adds a specified number of non-business days to an input time. Adding negative days is equivalent to subtracting days. + * Adds a specified number of non-business days to an input date. Adding negative days is equivalent to subtracting days. * * @param time time * @param days number of days to add. - * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. + * @return {@code days} non-business days after {@code time}; null if {@code time} is not a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate plusNonBusinessDays(final Instant time, int days) { - if(time == null){ - return null; - } - + public LocalDate plusNonBusinessDays(final Instant time, final int days) { + Require.neqNull(time, "time"); return this.plusNonBusinessDays(DateTimeUtils.toLocalDate(time, timeZone()), days); } /** - * Adds a specified number of non-business days to an input time. Adding negative days is equivalent to subtracting days. + * Adds a specified number of non-business days to an input date. Adding negative days is equivalent to subtracting days. * * @param time time * @param days number of days to add. - * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. + * @return {@code days} non-business days after {@code time}; null if {@code time} is not a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate plusNonBusinessDays(final ZonedDateTime time, int days) { - if(time == null){ - return null; - } - + public LocalDate plusNonBusinessDays(final ZonedDateTime time, final int days) { + Require.neqNull(time, "time"); return plusNonBusinessDays(time.toInstant(), days); } @@ -1460,10 +1468,12 @@ public LocalDate plusNonBusinessDays(final ZonedDateTime time, int days) { * Subtracts a specified number of non-business days to an input date. Subtracting negative days is equivalent to adding days. * * @param date date - * @param days number of days to subtract. - * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. + * @param days number of days to add. + * @return {@code days} non-business days before {@code date}; null if {@code date} is a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate minusNonBusinessDays(final LocalDate date, int days) { + public LocalDate minusNonBusinessDays(final LocalDate date, final int days) { return this.plusNonBusinessDays(date, -days); } @@ -1471,32 +1481,39 @@ public LocalDate minusNonBusinessDays(final LocalDate date, int days) { * Subtracts a specified number of non-business days to an input date. Subtracting negative days is equivalent to adding days. * * @param date date - * @param days number of days to subtract. - * @return {@code days} non-business days after {@code date}; null if {@code date} is null or if {@code date} is a business day and {@code days} is zero. + * @param days number of days to add. + * @return {@code days} non-business days before {@code date}; null if {@code date} is a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public LocalDate minusNonBusinessDays(final String date, int days) { + public LocalDate minusNonBusinessDays(final String date, final int days) { return plusNonBusinessDays(date, -days); } /** - * Subtracts a specified number of non-business days to an input time. Subtracting negative days is equivalent to adding days. + * Subtracts a specified number of non-business days to an input date. Subtracting negative days is equivalent to adding days. * * @param time time - * @param days number of days to subtract. - * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code time} is a business day and {@code days} is zero. + * @param days number of days to add. + * @return {@code days} non-business days before {@code time}; null if {@code time} is a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate minusNonBusinessDays(final Instant time, int days) { + public LocalDate minusNonBusinessDays(final Instant time, final int days) { return plusNonBusinessDays(time, -days); } /** - * Subtracts a specified number of non-business days to an input time. Subtracting negative days is equivalent to adding days. + * Subtracts a specified number of non-business days to an input date. Subtracting negative days is equivalent to adding days. * * @param time time - * @param days number of days to subtract. - * @return {@code days} non-business days after {@code time}; null if {@code date} is null or if {@code time} is a business day and {@code days} is zero. + * @param days number of days to add. + * @return {@code days} non-business days before {@code time}; null if {@code time} is a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate minusNonBusinessDays(final ZonedDateTime time, int days) { + public LocalDate minusNonBusinessDays(final ZonedDateTime time, final int days) { return plusNonBusinessDays(time, -days); } @@ -1504,9 +1521,10 @@ public LocalDate minusNonBusinessDays(final ZonedDateTime time, int days) { * Adds a specified number of business days to the current date. Adding negative days is equivalent to subtracting days. * * @param days number of days to add. - * @return {@code days} business days after the current date; null if the current date is not a business day and {@code days} is zero. + * @return {@code days} business days after the current date; null if the current date is not a business day and {@code days} is zero + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate futureBusinessDate(int days) { + public LocalDate futureBusinessDate(final int days) { return plusBusinessDays(currentDate(), days); } @@ -1514,9 +1532,10 @@ public LocalDate futureBusinessDate(int days) { * Subtracts a specified number of business days from the current date. Subtracting negative days is equivalent to adding days. * * @param days number of days to subtract. - * @return {@code days} business days before the current date; null if the current date is not a business day and {@code days} is zero. + * @return {@code days} business days before the current date; null if the current date is not a business day and {@code days} is zero + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate pastBusinessDate(int days) { + public LocalDate pastBusinessDate(final int days) { return minusBusinessDays(currentDate(), days); } @@ -1524,9 +1543,10 @@ public LocalDate pastBusinessDate(int days) { * Adds a specified number of non-business days to the current date. Adding negative days is equivalent to subtracting days. * * @param days number of days to add. - * @return {@code days} non-business days after the current date; null if the current date is a business day and {@code days} is zero. + * @return {@code days} non-business days after the current date; null if the current date is a business day and {@code days} is zero + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate futureNonBusinessDate(int days) { + public LocalDate futureNonBusinessDate(final int days) { return this.plusNonBusinessDays(currentDate(), days); } @@ -1534,9 +1554,10 @@ public LocalDate futureNonBusinessDate(int days) { * Subtracts a specified number of non-business days to the current date. Subtracting negative days is equivalent to adding days. * * @param days number of days to subtract. - * @return {@code days} non-business days before the current date; null if the current date is a business day and {@code days} is zero. + * @return {@code days} non-business days before the current date; null if the current date is a business day and {@code days} is zero + * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate pastNonBusinessDate(int days) { + public LocalDate pastNonBusinessDate(final int days) { return minusNonBusinessDays(currentDate(), days); } From 611a2ecd747e442ea15589e6d14bc1fab77986da Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 4 Jul 2023 20:49:01 -0700 Subject: [PATCH 016/150] BusinessCalendar refactoring and cleanup: * Misc --- .../time/calendar/BusinessCalendar.java | 13 ---------- .../figure/FigureWidgetTranslator.java | 25 +++++++++++-------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index 1e022f4b595..a7c3226ec67 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -1563,17 +1563,4 @@ public LocalDate pastNonBusinessDate(final int days) { // endregion - //TODO: add to a region - //TODO: relocate - //TODO: remove from API? - //TODO: rename - /** - * Gets the business periods for the public days. - * - * @return a list of strings with a comma separating open and close times - */ - public List getDefaultBusinessPeriods(){ - return Collections.unmodifiableList(defaultBusinessPeriodStrings); - } - } diff --git a/plugin/figure/src/main/java/io/deephaven/figure/FigureWidgetTranslator.java b/plugin/figure/src/main/java/io/deephaven/figure/FigureWidgetTranslator.java index e3387a44513..8c9c0726d6f 100644 --- a/plugin/figure/src/main/java/io/deephaven/figure/FigureWidgetTranslator.java +++ b/plugin/figure/src/main/java/io/deephaven/figure/FigureWidgetTranslator.java @@ -78,7 +78,7 @@ import java.util.stream.Stream; public class FigureWidgetTranslator { - private static final DateTimeFormatter HOLIDAY_TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm"); + private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm"); private final List errorList = new ArrayList<>(); private final Map tablePositionMap = new HashMap<>(); @@ -551,11 +551,16 @@ private BusinessCalendarDescriptor translateBusinessCalendar(AxisTransformBusine final DayOfWeek day = DayOfWeek.valueOf(dayOfWeek.name()); return businessCalendar.isBusinessDay(day); }).forEach(businessCalendarDescriptor::addBusinessDays); - businessCalendar.getDefaultBusinessPeriods().stream().map(period -> { - final String[] array = period.split(","); + Arrays.stream(businessCalendar.standardBusinessSchedule().periods()).map(period -> { + // noinspection ConstantConditions + final String open = TIME_FORMATTER.withZone(businessCalendar.timeZone()) + .format(period.start()); + // noinspection ConstantConditions + final String close = TIME_FORMATTER.withZone(businessCalendar.timeZone()) + .format(period.end()); final BusinessPeriod.Builder businessPeriod = BusinessPeriod.newBuilder(); - businessPeriod.setOpen(array[0]); - businessPeriod.setClose(array[1]); + businessPeriod.setOpen(open); + businessPeriod.setClose(close); return businessPeriod; }).forEach(businessCalendarDescriptor::addBusinessPeriods); @@ -566,13 +571,13 @@ private BusinessCalendarDescriptor translateBusinessCalendar(AxisTransformBusine localDate.setMonth(entry.getKey().getMonthValue()); localDate.setDay(entry.getKey().getDayOfMonth()); final Holiday.Builder holiday = Holiday.newBuilder(); - Arrays.stream(entry.getValue().getBusinessPeriods()).map(bp -> { + Arrays.stream(entry.getValue().periods()).map(bp -> { // noinspection ConstantConditions - final String open = HOLIDAY_TIME_FORMAT.withZone(businessCalendar.timeZone()) - .format(bp.getStartTime()); + final String open = TIME_FORMATTER.withZone(businessCalendar.timeZone()) + .format(bp.start()); // noinspection ConstantConditions - final String close = HOLIDAY_TIME_FORMAT.withZone(businessCalendar.timeZone()) - .format(bp.getEndTime()); + final String close = TIME_FORMATTER.withZone(businessCalendar.timeZone()) + .format(bp.end()); final BusinessPeriod.Builder businessPeriod = BusinessPeriod.newBuilder(); businessPeriod.setOpen(open); businessPeriod.setClose(close); From 720df959bfa738a6226355d9ce4a7147d7d319a5 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Thu, 6 Jul 2023 17:40:23 -0700 Subject: [PATCH 017/150] BusinessCalendar refactoring and cleanup: * BusinessCalendarParser --- .../time/calendar/BusinessCalendarParser.java | 202 ++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendarParser.java diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendarParser.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendarParser.java new file mode 100644 index 00000000000..1266f48ccbe --- /dev/null +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendarParser.java @@ -0,0 +1,202 @@ +/** + * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending + */ +package io.deephaven.time.calendar; + +import io.deephaven.base.verify.Require; +import io.deephaven.time.DateTimeUtils; +import io.deephaven.time.TimeZoneAliases; +import io.deephaven.util.annotations.VisibleForTesting; +import org.jdom2.Document; +import org.jdom2.Element; +import org.jdom2.JDOMException; +import org.jdom2.input.SAXBuilder; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.io.IOException; +import java.time.*; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; + +//TODO: document + +/** + * A parser for reading business calendar files. + * + * Business calendar files should be formatted as: + * + * + * USNYSE + * New York Stock Exchange Calendar + * America/New_York + * + * 09:30,16:00 + * Saturday + * Sunday + * + * 1999-01-01 + * 2003-12-31 + * + * 19990101 + * + * + * 20020705 + * 09:30,13:00 + * + * + */ +public class BusinessCalendarParser { + + @VisibleForTesting + static class BusinessCalendarInputs { + private String calendarName; + private String description; + private ZoneId timeZone; + private LocalDate firstValidDate; + private LocalDate lastValidDate; + private BusinessSchedule standardBusinessSchedule; + private Set weekendDays; + private Map> holidays; + } + + /** + * Loads a business calendar from a file. + * + * @param file file + * @return business calendar. + */ + public static BusinessCalendar loadBusinessCalendar(@NotNull final File file) { + final BusinessCalendarInputs in = parseBusinessCalendarInputs(file); + + return new BusinessCalendar(in.calendarName, in.description, + in.timeZone, in.firstValidDate, in.lastValidDate, + in.standardBusinessSchedule, in.weekendDays, in.holidays); + } + + @VisibleForTesting + static BusinessCalendarInputs parseBusinessCalendarInputs(@NotNull final File file) { + Require.neqNull(file, "file"); + try { + final BusinessCalendarInputs calendarElements = new BusinessCalendarInputs(); + + Element root = loadXMLRootElement(file); + calendarElements.calendarName = getText(getRequiredChild(root, "name")); + calendarElements.timeZone = TimeZoneAliases.zoneId(getText(getRequiredChild(root, "timeZone"))); + calendarElements.description = getText(getRequiredChild(root, "description")); + calendarElements.firstValidDate = DateTimeUtils.parseLocalDate(getText(getRequiredChild(root, "firstValidDate"))); + calendarElements.lastValidDate = DateTimeUtils.parseLocalDate(getText(getRequiredChild(root, "lastValidDate"))); + calendarElements.holidays = parseHolidays(root, calendarElements.timeZone); + + // Set the default values + final Element defaultElement = getRequiredChild(root, "default"); + calendarElements.weekendDays = parseWeekendDays(defaultElement); + calendarElements.standardBusinessSchedule = parseBusinessSchedule(defaultElement); + + return calendarElements; + }catch (Exception e) { + throw new RuntimeException("Unable to load calendar file: file=" + file.getPath(), e); + } + } + + private static Element loadXMLRootElement(File calendarFile) throws Exception{ + final Document doc; + + try { + final SAXBuilder builder = new SAXBuilder(); + doc = builder.build(calendarFile); + } catch (JDOMException e) { + throw new Exception("Error parsing business calendar: file=" + calendarFile, e); + } catch (IOException e) { + throw new Exception("Error loading business calendar: file=" + calendarFile, e); + } + + return doc.getRootElement(); + } + + private static Element getRequiredChild(@NotNull final Element root, final String child) throws Exception { + Element element = root.getChild(child); + if (element != null) { + return element; + } else { + throw new Exception("Missing the '" + child + "' tag in calendar file"); + } + } + + private static String getText(Element element) { + return element == null ? null : element.getTextTrim(); + } + + private static BusinessSchedule parseBusinessSchedule(final Element element) throws Exception { + final List businessPeriodStrings = element + .getChildren("businessPeriod") + .stream() + .map(bp->getText(bp).trim()) + .collect(Collectors.toList()); + + return businessPeriodStrings.isEmpty() ? BusinessSchedule.HOLIDAY : new BusinessSchedule<>(parseBusinessPeriods(businessPeriodStrings)); + } + + private static BusinessPeriod[] parseBusinessPeriods(final List businessPeriodStrings) throws Exception { + //noinspection unchecked + final BusinessPeriod[] businessPeriods = new BusinessPeriod[businessPeriodStrings.size()]; + + for(int i=0; i(open, close); + } + + return businessPeriods; + } + + private static Map> parseHolidays(final Element root, final ZoneId timeZone) throws Exception{ + final Map> holidays = new ConcurrentHashMap<>(); + final List holidayElements = root.getChildren("holiday"); + + for (Element holidayElement : holidayElements) { + final Element dateElement = getRequiredChild(holidayElement, "date"); + final LocalDate date = DateTimeUtils.parseLocalDate(getText(dateElement)); + final BusinessSchedule schedule = parseBusinessSchedule(holidayElement); + holidays.put(date, BusinessSchedule.toInstant(schedule,date, timeZone)); + } + + return holidays; + } + + private static Set parseWeekendDays(@NotNull final Element defaultElement) throws Exception{ + final Set weekendDays = new HashSet<>(); + + final List weekends = defaultElement.getChildren("weekend"); + if (weekends != null) { + for (Element weekendElement : weekends) { + final String weekend = getText(weekendElement); + final String dows = weekend.trim().toUpperCase(); + final DayOfWeek dow; + + try { + dow = DayOfWeek.valueOf(dows); + } catch (IllegalArgumentException e){ + throw new Exception("Invalid day of week: day=" + dows, e); + } + + weekendDays.add(dow); + } + } + + return weekendDays; + } + +} From 14fb2345933b2faee593594eeb6aeba5d2ec4bb2 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Thu, 6 Jul 2023 17:46:58 -0700 Subject: [PATCH 018/150] BusinessCalendar refactoring and cleanup: * BusinessCalendarParser --- .../time/calendar/BusinessCalendarParser.java | 38 ++++++------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendarParser.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendarParser.java index 1266f48ccbe..ead1a20ad79 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendarParser.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendarParser.java @@ -21,9 +21,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; - -//TODO: document /** * A parser for reading business calendar files. @@ -35,7 +32,7 @@ * New York Stock Exchange Calendar * America/New_York * - * 09:30,16:00 + * 09:3016:00 * Saturday * Sunday * @@ -46,7 +43,7 @@ * * * 20020705 - * 09:30,13:00 + * 09:3013:00 * * */ @@ -132,34 +129,21 @@ private static String getText(Element element) { } private static BusinessSchedule parseBusinessSchedule(final Element element) throws Exception { - final List businessPeriodStrings = element - .getChildren("businessPeriod") - .stream() - .map(bp->getText(bp).trim()) - .collect(Collectors.toList()); - - return businessPeriodStrings.isEmpty() ? BusinessSchedule.HOLIDAY : new BusinessSchedule<>(parseBusinessPeriods(businessPeriodStrings)); + final List businessPeriods = element.getChildren("businessPeriod"); + return businessPeriods.isEmpty() ? BusinessSchedule.HOLIDAY : new BusinessSchedule<>(parseBusinessPeriods(businessPeriods)); } - private static BusinessPeriod[] parseBusinessPeriods(final List businessPeriodStrings) throws Exception { + private static BusinessPeriod[] parseBusinessPeriods(final List businessPeriods) throws Exception { //noinspection unchecked - final BusinessPeriod[] businessPeriods = new BusinessPeriod[businessPeriodStrings.size()]; - - for(int i=0; i[] rst = new BusinessPeriod[businessPeriods.size()]; - //TODO: change the period open/close format? - final LocalTime open = DateTimeUtils.parseLocalTime(openClose[0]); - final LocalTime close = DateTimeUtils.parseLocalTime(openClose[1]); - businessPeriods[i] = new BusinessPeriod<>(open, close); + for(int i=0; i(open, close); } - return businessPeriods; + return rst; } private static Map> parseHolidays(final Element root, final ZoneId timeZone) throws Exception{ From 591b8febf6e6aae8c701de5a303285983b4fc5ef Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Thu, 6 Jul 2023 17:47:44 -0700 Subject: [PATCH 019/150] BusinessCalendar refactoring and cleanup: * DefaultBusinessCalendar --- .../calendar/DefaultBusinessCalendar.java | 439 ------------------ 1 file changed, 439 deletions(-) delete mode 100644 engine/time/src/main/java/io/deephaven/time/calendar/DefaultBusinessCalendar.java diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/DefaultBusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/DefaultBusinessCalendar.java deleted file mode 100644 index b7c02cefec1..00000000000 --- a/engine/time/src/main/java/io/deephaven/time/calendar/DefaultBusinessCalendar.java +++ /dev/null @@ -1,439 +0,0 @@ -/** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending - */ -package io.deephaven.time.calendar; - -import io.deephaven.base.Pair; -import io.deephaven.time.DateTimeUtils; -import io.deephaven.time.TimeZoneAliases; -import io.deephaven.util.annotations.VisibleForTesting; -import org.jdom2.Document; -import org.jdom2.Element; -import org.jdom2.JDOMException; -import org.jdom2.input.SAXBuilder; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.IOException; -import java.io.Serializable; -import java.time.DayOfWeek; -import java.time.Instant; -import java.time.LocalDate; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.Calendar; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Pattern; - -/** - * Default implementation for a {@link BusinessCalendar}. This implementation is thread safe. - * - * Overrides many default {@link Calendar} and BusinessCalendar methods for improved performance. See the documentation - * of Calendar for details. - */ -public class DefaultBusinessCalendar extends BusinessCalendar implements Serializable { - - private static final long serialVersionUID = -5887343387358189382L; - - // our "null" holder for holidays - private static final BusinessSchedule HOLIDAY = new Holiday(); - private static final DateTimeFormatter HOLIDAY_PARSER = - DateTimeFormatter.ofPattern("yyyyMMdd").withLocale(new Locale("en", "US")); - - // each calendar has a name, timezone, and date string format - private final String calendarName; - private final ZoneId timeZone; - - // length, in nanos, that a default day is open - private final long lengthOfDefaultDayNanos; - - // holds the open hours for a standard business day - private final List defaultBusinessPeriodStrings; - private final Set weekendDays; - - private final Map dates; - private final Map holidays; - private final Map cachedYearLengths = new ConcurrentHashMap<>(); - - @VisibleForTesting - DefaultBusinessCalendar(final CalendarElements calendarElements) { - this(calendarElements.calendarName, calendarElements.timeZone, calendarElements.lengthOfDefaultDayNanos, - calendarElements.defaultBusinessPeriodStrings, calendarElements.weekendDays, calendarElements.dates, - calendarElements.holidays); - } - - private DefaultBusinessCalendar(final String calendarName, final ZoneId timeZone, - final long lengthOfDefaultDayNanos, final List defaultBusinessPeriodStrings, - final Set weekendDays, final Map dates, - final Map holidays) { - this.calendarName = calendarName; - this.timeZone = timeZone; - this.lengthOfDefaultDayNanos = lengthOfDefaultDayNanos; - this.defaultBusinessPeriodStrings = defaultBusinessPeriodStrings; - this.weekendDays = weekendDays; - this.dates = dates; - this.holidays = holidays; - } - - static BusinessCalendar getInstance(@NotNull final File calendarFile) { - final CalendarElements calendarElements = constructCalendarElements(calendarFile); - final BusinessCalendar calendar = new DefaultBusinessCalendar(calendarElements); - - if (!calendarElements.hasHolidays && calendarElements.weekendDays.isEmpty()) { - return new DefaultNoHolidayBusinessCalendar(calendar); - } - - return calendar; - } - - @VisibleForTesting - static CalendarElements constructCalendarElements(@NotNull final File calendarFile) { - final CalendarElements calendarElements = new CalendarElements(); - - final String filePath = calendarFile.getPath(); - - Element root = getRootElement(calendarFile); - - calendarElements.calendarName = getCalendarName(root, filePath); - calendarElements.timeZone = getTimeZone(root, filePath); - - // Set the default values - final Element defaultElement = getRequiredChild(root, "default", filePath); - - calendarElements.defaultBusinessPeriodStrings = getDefaultBusinessPeriodStrings(defaultElement, filePath); - calendarElements.weekendDays = getWeekendDays(defaultElement); - - // get the holidays/half days - final Pair, Map> datePair = - getDates(root, calendarElements); - calendarElements.dates = datePair.getFirst(); - calendarElements.holidays = datePair.getSecond(); - - calendarElements.lengthOfDefaultDayNanos = - parseStandardBusinessDayLengthNanos(calendarElements.defaultBusinessPeriodStrings); - - return calendarElements; - } - - private static Pair, Map> getDates(final Element root, - final CalendarElements calendarElements) { - final Map holidays = new ConcurrentHashMap<>(); - // initialize the calendar to the years placed in the calendar file - int minYear = Integer.MAX_VALUE; - int maxYear = Integer.MIN_VALUE; - - - final List holidayElements = root.getChildren("holiday"); - calendarElements.hasHolidays = !holidayElements.isEmpty(); - - for (Element holidayElement : holidayElements) { - final Element date = holidayElement.getChild("date"); - if (date != null) { - final String dateStr = getText(date); - final LocalDate localDate = parseLocalDate(dateStr); - final int holidayYear = localDate.getYear(); - if (holidayYear < minYear) { - minYear = holidayYear; - } - if (holidayYear > maxYear) { - maxYear = holidayYear; - } - - final List businessPeriodsList = holidayElement.getChildren("businessPeriod"); - final List businessPeriodStrings = new ArrayList<>(); - for (Element busPeriod : businessPeriodsList) { - String businessPeriod = getText(busPeriod); - businessPeriodStrings.add(businessPeriod.trim()); - } - - if (businessPeriodStrings.isEmpty()) { - holidays.put(localDate, HOLIDAY); - } else { - holidays.put(localDate, new BusinessSchedule( - parseBusinessPeriods(calendarElements.timeZone, localDate, businessPeriodStrings))); - } - } - } - - final Map dates = new ConcurrentHashMap<>(holidays); - if (minYear != Integer.MAX_VALUE && maxYear != Integer.MIN_VALUE) { - for (int i = 0; i < maxYear - minYear; i++) { - int year = i + minYear; - boolean isLeap = DateStringUtils.isLeapYear(year); - int numDays = 365 + (isLeap ? 1 : 0); - for (int j = 0; j < numDays; j++) { - dates.computeIfAbsent(LocalDate.ofYearDay(year, j + 1), - date -> newBusinessDay(date, calendarElements.weekendDays, calendarElements.timeZone, - calendarElements.defaultBusinessPeriodStrings)); - } - } - } - - return new Pair<>(dates, holidays); - } - - private static Set getWeekendDays(@NotNull final Element defaultElement) { - final Set weekendDays = new HashSet<>(); - - final List weekends = defaultElement.getChildren("weekend"); - if (weekends != null) { - for (Element weekendElement : weekends) { - String weekend = getText(weekendElement); - weekendDays.add(DayOfWeek.valueOf(weekend.trim().toUpperCase())); - } - } - - return weekendDays; - } - - private static List getDefaultBusinessPeriodStrings(@NotNull final Element defaultElement, - final String filePath) { - final List defaultBusinessPeriodStrings = new ArrayList<>(); - final List businessPeriods = defaultElement.getChildren("businessPeriod"); - if (businessPeriods != null) { - for (Element businessPeriod1 : businessPeriods) { - String businessPeriod = getText(businessPeriod1); - defaultBusinessPeriodStrings.add(businessPeriod); - } - } else { - throw new IllegalArgumentException( - "Missing the 'businessPeriod' tag in the 'default' section in calendar file " + filePath); - } - - return defaultBusinessPeriodStrings; - } - - private static Element getRootElement(File calendarFile) { - final Document doc; - try { - final SAXBuilder builder = new SAXBuilder(); - doc = builder.build(calendarFile); - } catch (JDOMException e) { - throw new IllegalArgumentException( - "Could not initialize business calendar: Error parsing " + calendarFile.getName()); - } catch (IOException e) { - throw new RuntimeException( - "Could not initialize business calendar: " + calendarFile.getName() + " could not be loaded"); - } - - return doc.getRootElement(); - } - - private static String getCalendarName(@NotNull final Element root, final String filePath) { - final Element element = getRequiredChild(root, "name", filePath); - return getText(element); - } - - private static ZoneId getTimeZone(@NotNull final Element root, final String filePath) { - final Element element = getRequiredChild(root, "timeZone", filePath); - return TimeZoneAliases.zoneId(getText(element)); - } - - // throws an error if the child is missing - private static Element getRequiredChild(@NotNull final Element root, final String child, final String filePath) { - Element element = root.getChild(child); - if (element != null) { - return element; - } else { - throw new IllegalArgumentException("Missing the " + child + " tag in calendar file " + filePath); - } - } - - private static LocalDate parseLocalDate(final String date) { - try { - return DateStringUtils.parseLocalDate(date); - } catch (Exception e) { - try { - return LocalDate.parse(date, HOLIDAY_PARSER); - } catch (Exception ee) { - throw new IllegalArgumentException( - "Malformed date string. Acceptable formats are yyyy-MM-dd and yyyyMMdd. s=" + date); - } - } - } - - private static long parseStandardBusinessDayLengthNanos(final List defaultBusinessPeriodStrings) { - long lengthOfDefaultDayNanos = 0; - Pattern hhmm = Pattern.compile("\\d{2}:\\d{2}"); - for (String businessPeriodString : defaultBusinessPeriodStrings) { - String[] openClose = businessPeriodString.split(","); - boolean wellFormed = false; - if (openClose.length == 2) { - String open = openClose[0]; - String close = openClose[1]; - if (hhmm.matcher(open).matches() && hhmm.matcher(close).matches()) { - String[] openingTimeHHMM = open.split(":"); - String[] closingTimeHHMM = close.split(":"); - long defOpenTimeNanos = (Integer.parseInt(openingTimeHHMM[0]) * DateTimeUtils.HOUR) - + (Integer.parseInt(openingTimeHHMM[1]) * DateTimeUtils.MINUTE); - long defClosingTimeNanos = (Integer.parseInt(closingTimeHHMM[0]) * DateTimeUtils.HOUR) - + (Integer.parseInt(closingTimeHHMM[1]) * DateTimeUtils.MINUTE); - lengthOfDefaultDayNanos += defClosingTimeNanos - defOpenTimeNanos; - wellFormed = true; - } - } - if (!wellFormed) { - throw new UnsupportedOperationException("Could not parse business period " + businessPeriodString); - } - } - - return lengthOfDefaultDayNanos; - } - - private static BusinessPeriod[] parseBusinessPeriods(final ZoneId timeZone, final LocalDate date, - final List businessPeriodStrings) { - final BusinessPeriod[] businessPeriods = new BusinessPeriod[businessPeriodStrings.size()]; - final Pattern hhmm = Pattern.compile("\\d{2}[:]\\d{2}"); - int i = 0; - for (String businessPeriodString : businessPeriodStrings) { - final String[] openClose = businessPeriodString.split(","); - if (openClose.length == 2) { - final String open = openClose[0]; - String close = openClose[1]; - if (hhmm.matcher(open).matches() && hhmm.matcher(close).matches()) { - final String tz = TimeZoneAliases.zoneName(timeZone); - final LocalDate closeDate; - - if (close.equals("24:00")) { // midnight closing time - closeDate = date.plusDays(1); - close = "00:00"; - } else if (Integer.parseInt(open.replaceAll(":", "")) > Integer - .parseInt(close.replaceAll(":", ""))) { - throw new IllegalArgumentException( - "Can not parse business periods; open = " + open + " is greater than close = " + close); - } else { - closeDate = date; - } - - final String openDateStr = date.toString() + "T" + open + " " + tz; - final String closeDateStr = closeDate.toString() + "T" + close + " " + tz; - - businessPeriods[i++] = new BusinessPeriod(DateTimeUtils.parseInstant(openDateStr), - DateTimeUtils.parseInstant(closeDateStr)); - } - } - } - - return businessPeriods; - } - - private static String getText(Element element) { - return element == null ? null : element.getTextTrim(); - } - - private BusinessSchedule newBusinessDay(final LocalDate date) { - return newBusinessDay(date, weekendDays, timeZone(), defaultBusinessPeriodStrings); - } - - private static BusinessSchedule newBusinessDay(final LocalDate date, final Set weekendDays, - final ZoneId timeZone, final List businessPeriodStrings) { - if (date == null) { - return null; - } - - // weekend - final DayOfWeek dayOfWeek = date.getDayOfWeek(); - if (weekendDays.contains(dayOfWeek)) { - return HOLIDAY; - } - return new BusinessSchedule(parseBusinessPeriods(timeZone, date, businessPeriodStrings)); - } - - - private long getBusinessYearLength(final int year) { - int numDays = 365 + (DateStringUtils.isLeapYear(year) ? 1 : 0); - long yearLength = 0; - - for (int j = 0; j < numDays; j++) { - final int day = j + 1; - final BusinessSchedule businessDate = businessSchedule(LocalDate.ofYearDay(year, day)); - yearLength += businessDate.getLOBD(); - } - - return yearLength; - } - - private Instant getFirstBusinessDateTimeOfYear(final int year) { - boolean isLeap = DateStringUtils.isLeapYear(year); - int numDays = 365 + (isLeap ? 1 : 0); - for (int j = 0; j < numDays; j++) { - final BusinessSchedule businessDate = businessSchedule(LocalDate.ofYearDay(year, j + 1)); - if (!(businessDate instanceof Holiday)) { - return businessDate.getSOBD(); - } - } - - return null; - } - - @Override - public String toString() { - return "DefaultBusinessCalendar{" + - "name='" + calendarName + '\'' + - ", timeZone=" + timeZone + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - DefaultBusinessCalendar that = (DefaultBusinessCalendar) o; - return lengthOfDefaultDayNanos == that.lengthOfDefaultDayNanos && - Objects.equals(calendarName, that.calendarName) && - timeZone == that.timeZone && - Objects.equals(defaultBusinessPeriodStrings, that.defaultBusinessPeriodStrings) && - Objects.equals(weekendDays, that.weekendDays) && - Objects.equals(holidays, that.holidays); - } - - @Override - public int hashCode() { - return Objects.hash(calendarName, timeZone, lengthOfDefaultDayNanos, defaultBusinessPeriodStrings, weekendDays, - holidays); - } - - static class CalendarElements { - private String calendarName; - private ZoneId timeZone; - private long lengthOfDefaultDayNanos; - private List defaultBusinessPeriodStrings; - private Set weekendDays; - private Map dates; - private Map holidays; - private boolean hasHolidays; - } - - private static class Holiday extends BusinessSchedule implements Serializable { - - private static final long serialVersionUID = 5226852380875996172L; - - @Override - public BusinessPeriod[] getBusinessPeriods() { - return new BusinessPeriod[0]; - } - - @Override - public Instant getSOBD() { - throw new UnsupportedOperationException("This is a holiday"); - } - - @Override - public Instant getEOBD() { - throw new UnsupportedOperationException("This is a holiday"); - } - - @Override - public long getLOBD() { - return 0; - } - - @Override - public boolean isBusinessDay() { - return false; - } - } -} From e0f5d2c332fe39f9ac78aa7fb40da99a5f904c91 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Thu, 6 Jul 2023 17:57:51 -0700 Subject: [PATCH 020/150] BusinessCalendar refactoring and cleanup: * Calendars --- .../io/deephaven/time/calendar/Calendars.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java index 1b51bdbead3..cf398940be0 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java @@ -4,6 +4,7 @@ package io.deephaven.time.calendar; import io.deephaven.base.verify.Require; +import io.deephaven.base.verify.RequirementFailure; import io.deephaven.configuration.Configuration; import io.deephaven.io.logger.Logger; import io.deephaven.api.util.NameValidator; @@ -49,6 +50,7 @@ static Calendars getInstance() { * @param name name of the calendar * @return business calendar * @throws IllegalArgumentException no calendar matching {@code name} + * @throws RequirementFailure if the input is null */ public static BusinessCalendar calendar(final String name) { Require.neqNull(name, "name"); @@ -63,7 +65,7 @@ public static BusinessCalendar calendar(final String name) { } /** - * Returns a business calendar. + * Returns the default business calendar. * * @return default business calendar. The deault is specified by the {@code Calendar.default} property. */ @@ -72,11 +74,11 @@ public static BusinessCalendar calendar() { } /** - * Returns the default calendar name + * Returns the default business calendar name * * @return default business calendar name */ - public static String getDefaultName() { + public static String defaultCalendarName() { return defaultName; } @@ -128,8 +130,9 @@ private void load(final String businessCalendarConfig) final InputStream inputStream = this.getClass().getResourceAsStream(filePath); if (inputStream != null) { final File calendarFile = inputStreamToFile(inputStream); - final BusinessCalendar businessCalendar = DefaultBusinessCalendar.getInstance(calendarFile); + final BusinessCalendar businessCalendar = BusinessCalendarParser.loadBusinessCalendar(calendarFile); addCalendar(businessCalendar); + //noinspection ResultOfMethodCallIgnored calendarFile.delete(); } else { logger.warn("Could not open " + filePath + " from classpath"); @@ -170,22 +173,22 @@ private void addCalendar(final BusinessCalendar cal) { } /** - * Adds a calendar to the collection from the {@code filePath} + * Adds a calendar to the collection from a file. * - * @param filePath must be xml format + * @param file business calendar file */ - public void addCalendarFromFile(final String filePath) { - addCalendarFromFile(new File(filePath)); + public void addCalendarFromFile(final String file) { + addCalendarFromFile(new File(file)); } /** - * Adds a calendar to the collection from the {@code file} + * Adds a calendar to the collection from a file. * - * @param file must be xml format + * @param file business calendar file */ public void addCalendarFromFile(final File file) { if (file.getAbsolutePath().endsWith(".calendar")) { - final BusinessCalendar cal = DefaultBusinessCalendar.getInstance(file); + final BusinessCalendar cal = BusinessCalendarParser.loadBusinessCalendar(file); addCalendar(cal); } else { throw new UnsupportedOperationException("Calendar file must be in .calendar format"); From ce255f9e37dae5c4f45ea168f8faf84aa2ddbd71 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Thu, 6 Jul 2023 18:01:30 -0700 Subject: [PATCH 021/150] BusinessCalendar refactoring and cleanup: * DateStringUtils --- .../time/calendar/DateStringUtils.java | 220 ------------ .../time/calendar/TestDateStringUtils.java | 322 ------------------ 2 files changed, 542 deletions(-) delete mode 100644 engine/time/src/main/java/io/deephaven/time/calendar/DateStringUtils.java delete mode 100644 engine/time/src/test/java/io/deephaven/time/calendar/TestDateStringUtils.java diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/DateStringUtils.java b/engine/time/src/main/java/io/deephaven/time/calendar/DateStringUtils.java deleted file mode 100644 index 73d39dec183..00000000000 --- a/engine/time/src/main/java/io/deephaven/time/calendar/DateStringUtils.java +++ /dev/null @@ -1,220 +0,0 @@ -/** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending - */ -package io.deephaven.time.calendar; - -import io.deephaven.util.QueryConstants; - -import java.time.LocalDate; -import java.time.chrono.IsoChronology; -import java.time.format.DateTimeFormatter; -import java.time.format.ResolverStyle; -import java.util.Locale; -import java.util.regex.Pattern; - -/** - * Basic utilities for Date Strings. - * - * To comply with the ISO-8601 standard for dates, Strings should be of the form "yyyy-MM-dd" - * - * Quiet methods are functionally equivalent to their counterparts, but assume Date String validity to remove the - * overhead of checking. - */ -@SuppressWarnings("WeakerAccess") -public class DateStringUtils { - private DateStringUtils() {} - - private static final Locale DATE_STRING_LOCALE = new Locale("en", "US"); - private static final DateTimeFormatter DATE_STRING_FORMATTER = DateTimeFormatter.ofPattern("uuuu-MM-dd") - .withLocale(DATE_STRING_LOCALE) - .withChronology(IsoChronology.INSTANCE) - .withResolverStyle(ResolverStyle.STRICT); - private static final Pattern DATE_STRING_PATTERN = Pattern.compile("\\d{4}-\\d{2}-\\d{2}"); - - /** - * Subtract a number of days from a given date. - * - * @param date date - * @param days days to subtract - * @return the day {@code days} before {@code date} - */ - public static String minusDays(final String date, final int days) { - return plusDays(date, -days); - } - - /** - * Subtract a number of days from a given date. - * - * This does not check that dates are formatted correctly. - * - * @param date date - * @param days days to subtract - * @return the day {@code days} before {@code date} - */ - public static String minusDaysQuiet(final String date, final int days) { - return plusDaysQuiet(date, -days); - } - - /** - * Add a number of days from a given date. - * - * @param date date - * @param days days to add - * @return the day {@code days} after {@code date} - */ - public static String plusDays(final String date, final int days) { - if (date == null) { - return null; - } - - LocalDate localDate = parseLocalDate(date); - localDate = localDate.plusDays(days); - return localDate.toString(); - } - - /** - * Add a number of days from a given date. - * - * This does not check that dates are formatted correctly. - * - * @param date date - * @param days days to add - * @return the day {@code days} after {@code date} - */ - public static String plusDaysQuiet(final String date, final int days) { - if (date == null) { - return null; - } - - LocalDate localDate = LocalDate.parse(date); - localDate = localDate.plusDays(days); - return localDate.toString(); - } - - /** - * Is the year a leap year? - * - * @param year year - * @return true if {@code year} is a leap year; false otherwise. - */ - static boolean isLeapYear(final int year) { - return ((year % 4 == 0) && - (!(year % 100 == 0) || (year % 400) == 0)); - } - - /** - * Is one date before another? - * - * @param date1 if {@code null} return false - * @param date2 if {@code null} return false - * @return true if {@code date1} is chronologically before {@code date2}; false otherwise. - */ - public static boolean isBefore(final String date1, final String date2) { - if (date1 == null || date2 == null) { - return false; - } - - LocalDate localDate1 = parseLocalDate(date1); - LocalDate localDate2 = parseLocalDate(date2); - - return localDate1.isBefore(localDate2); - } - - /** - * Is one date before another? - * - * This does not check that dates are formatted correctly. Could be disastrous if {@code date1} and {@code date2} - * are not ISO-8601 compliant! - * - * @param date1 if {@code null} return false - * @param date2 if {@code null} return false - * @return true if {@code date1} is chronologically before {@code date2}; false otherwise. - */ - public static boolean isBeforeQuiet(final String date1, final String date2) { - return !(date1 == null || date2 == null) && date1.compareTo(date2) < 0; - - } - - /** - * Is one date after another? - * - * @param date1 if {@code null} return false - * @param date2 if {@code null} return false - * @return true if {@code date1} is chronologically after {@code date2}; false otherwise. - */ - public static boolean isAfter(final String date1, final String date2) { - if (date1 == null || date2 == null) { - return false; - } - - LocalDate localDate1 = parseLocalDate(date1); - LocalDate localDate2 = parseLocalDate(date2); - - return localDate1.isAfter(localDate2); - } - - /** - * Is one date after another? - * - * This does not check that dates are formatted correctly. Could be disastrous if {@code date1} and {@code date2} - * are not ISO-8601 compliant! - * - * @param date1 if {@code null} return false - * @param date2 if {@code null} return false - * @return true if {@code date1} is chronologically after {@code date2}; false otherwise. - */ - public static boolean isAfterQuiet(final String date1, final String date2) { - return !(date1 == null || date2 == null) && date1.compareTo(date2) > 0; - - } - - /** - * Gets the month of the year for the date. - * - * @param date date; if {@code null} return {@code NULL_INT} - * @return month of the year for the date. Jan = 1, Dec = 12 - */ - public static int monthOfYear(final String date) { - if (date == null) { - return QueryConstants.NULL_INT; - } - - return parseLocalDate(date).getMonthValue(); - } - - /** - * Parses a string as a local date. If the string is not a valid ISO-8601 Date String, throws an exception. - * - * This method can beused to verify that a date string is properly formed. - * - * @param date date - * @throws IllegalArgumentException improper date string - */ - static LocalDate parseLocalDate(final String date) { - if (date == null) { - throw new IllegalArgumentException("Date can not be null"); - } - - final boolean matchesPattern = DATE_STRING_PATTERN.matcher(date).matches(); - if (!matchesPattern) { - throw new IllegalArgumentException( - "Text '" + date + "' could not be parsed as a date: format must be yyyy-MM-dd"); - } - - try { - return LocalDate.parse(date, DATE_STRING_FORMATTER); - } catch (Exception e) { - throw new IllegalArgumentException("Text '" + date + "' could not be parsed as a date: " + e.getMessage()); - } - } - - /** - * Formats a date as an ISO-8601 Date String (yyyy-MM-dd). - * - * @param date date - * @return ISO-8601 formatted string (yyyy-MM-dd) - */ - static String format(final LocalDate date) { - return DATE_STRING_FORMATTER.format(date); - } -} diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestDateStringUtils.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestDateStringUtils.java deleted file mode 100644 index f02e19e0b79..00000000000 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestDateStringUtils.java +++ /dev/null @@ -1,322 +0,0 @@ -/** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending - */ -package io.deephaven.time.calendar; - -import io.deephaven.base.testing.BaseArrayTestCase; -import io.deephaven.util.QueryConstants; - -public class TestDateStringUtils extends BaseArrayTestCase { - - public void testParse() { - // ok dates - DateStringUtils.parseLocalDate("2018-09-05"); - DateStringUtils.parseLocalDate("2018-09-06"); - DateStringUtils.parseLocalDate("2018-09-30"); - DateStringUtils.parseLocalDate("2018-02-01"); - DateStringUtils.parseLocalDate("2018-02-28"); - - // leap year - DateStringUtils.parseLocalDate("2016-02-29"); - - - // bad dates - // bad year format - try { - DateStringUtils.parseLocalDate("2018243-09-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - - - // bad month format - try { - DateStringUtils.parseLocalDate("2018-093-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - // bad month number - try { - DateStringUtils.parseLocalDate("2018-14-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - - - // bad day format - try { - DateStringUtils.parseLocalDate("2018-09-5421"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - - // bad day number - try { - DateStringUtils.parseLocalDate("2018-12-32"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - - // bad day number which would be valid in other months - try { - DateStringUtils.parseLocalDate("2018-02-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testPlusDays() { - String day1 = "2016-08-31"; - String day2 = "2016-09-01"; - assertEquals(DateStringUtils.plusDays(day1, 1), day2); - - // leap day - day1 = "2016-02-28"; - day2 = "2016-03-01"; - assertEquals(DateStringUtils.plusDays(day1, 2), day2); - - // new year - day1 = "2013-12-31"; - day2 = "2014-01-01"; - assertEquals(DateStringUtils.plusDays(day1, 1), day2); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-12"; - day2 = "2017-03-17"; - assertEquals(DateStringUtils.plusDays(day1, 5), day2); - - assertNull(DateStringUtils.plusDays(null, 6)); - - - // bad date - try { - DateStringUtils.plusDays("2018-02-31", 7); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testPlusDaysQuiet() { - String day1 = "2016-08-31"; - String day2 = "2016-09-01"; - assertEquals(DateStringUtils.plusDaysQuiet(day1, 1), day2); - - // leap day - day1 = "2016-02-28"; - day2 = "2016-03-01"; - assertEquals(DateStringUtils.plusDaysQuiet(day1, 2), day2); - - // new year - day1 = "2013-12-31"; - day2 = "2014-01-01"; - assertEquals(DateStringUtils.plusDaysQuiet(day1, 1), day2); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-12"; - day2 = "2017-03-17"; - assertEquals(DateStringUtils.plusDaysQuiet(day1, 5), day2); - - assertNull(DateStringUtils.plusDaysQuiet(null, 6)); - } - - public void testMinusDays() { - String day1 = "2016-08-31"; - String day2 = "2016-09-01"; - assertEquals(DateStringUtils.minusDays(day2, 1), day1); - - // leap day - day1 = "2016-02-28"; - day2 = "2016-03-01"; - assertEquals(DateStringUtils.minusDays(day2, 2), day1); - - // new year - day1 = "2013-12-31"; - day2 = "2014-01-01"; - assertEquals(DateStringUtils.minusDays(day2, 1), day1); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-11"; - day2 = "2017-03-17"; - assertEquals(DateStringUtils.minusDays(day2, 6), day1); - - assertNull(DateStringUtils.minusDays(null, 6)); - - - // bad date - try { - DateStringUtils.minusDays("2018-09-31", 7); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testMinusDaysQuiet() { - String day1 = "2016-08-31"; - String day2 = "2016-09-01"; - assertEquals(DateStringUtils.minusDaysQuiet(day2, 1), day1); - - // leap day - day1 = "2016-02-28"; - day2 = "2016-03-01"; - assertEquals(DateStringUtils.minusDaysQuiet(day2, 2), day1); - - // new year - day1 = "2013-12-31"; - day2 = "2014-01-01"; - assertEquals(DateStringUtils.minusDaysQuiet(day2, 1), day1); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-11"; - day2 = "2017-03-17"; - assertEquals(DateStringUtils.minusDaysQuiet(day2, 6), day1); - - assertNull(DateStringUtils.minusDaysQuiet(null, 6)); - } - - public void testIsAfter() { - String day1 = "2016-08-31"; - String day2 = "2016-09-01"; - assertTrue(DateStringUtils.isAfter(day2, day1)); - - // leap day - day1 = "2016-02-28"; - day2 = "2016-03-01"; - assertTrue(DateStringUtils.isAfter(day2, day1)); - - // new year - day1 = "2013-12-31"; - day2 = "2014-01-01"; - assertTrue(DateStringUtils.isAfter(day2, day1)); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-11"; - day2 = "2017-03-17"; - assertTrue(DateStringUtils.isAfter(day2, day1)); - - assertFalse(DateStringUtils.isAfter(day1, null)); - assertFalse(DateStringUtils.isAfter(null, null)); - - // bad date - try { - DateStringUtils.isAfter("2018-12-31", "2018-12-32"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testIsAfterQuiet() { - String day1 = "2016-08-31"; - String day2 = "2016-09-01"; - assertTrue(DateStringUtils.isAfterQuiet(day2, day1)); - - // leap day - day1 = "2016-02-28"; - day2 = "2016-03-01"; - assertTrue(DateStringUtils.isAfterQuiet(day2, day1)); - - // new year - day1 = "2013-12-31"; - day2 = "2014-01-01"; - assertTrue(DateStringUtils.isAfterQuiet(day2, day1)); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-11"; - day2 = "2017-03-17"; - assertTrue(DateStringUtils.isAfterQuiet(day2, day1)); - - assertFalse(DateStringUtils.isAfterQuiet(day1, null)); - assertFalse(DateStringUtils.isAfterQuiet(null, null)); - } - - public void testIsBefore() { - String day1 = "2016-08-31"; - String day2 = "2016-09-01"; - assertTrue(DateStringUtils.isBefore(day1, day2)); - - // leap day - day1 = "2016-02-28"; - day2 = "2016-03-01"; - assertTrue(DateStringUtils.isBefore(day1, day2)); - - // new year - day1 = "2013-12-31"; - day2 = "2014-01-01"; - assertTrue(DateStringUtils.isBefore(day1, day2)); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-11"; - day2 = "2017-03-17"; - assertTrue(DateStringUtils.isBefore(day1, day2)); - - assertFalse(DateStringUtils.isBefore(day1, null)); - assertFalse(DateStringUtils.isBefore(null, null)); - - // bad date - try { - DateStringUtils.isBefore("2018-02-31", "2018-02-19"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testIsBeforeQuiet() { - String day1 = "2016-08-31"; - String day2 = "2016-09-01"; - assertTrue(DateStringUtils.isBeforeQuiet(day1, day2)); - - // leap day - day1 = "2016-02-28"; - day2 = "2016-03-01"; - assertTrue(DateStringUtils.isBeforeQuiet(day1, day2)); - - // new year - day1 = "2013-12-31"; - day2 = "2014-01-01"; - assertTrue(DateStringUtils.isBeforeQuiet(day1, day2)); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-11"; - day2 = "2017-03-17"; - assertTrue(DateStringUtils.isBeforeQuiet(day1, day2)); - - assertFalse(DateStringUtils.isBeforeQuiet(day1, null)); - assertFalse(DateStringUtils.isBeforeQuiet(null, null)); - } - - public void testMonthOfYear() { - String day1 = "2016-08-31"; - assertEquals(DateStringUtils.monthOfYear(day1), 8); - - // leap day - day1 = "2016-02-28"; - assertEquals(DateStringUtils.monthOfYear(day1), 2); - - // new year - day1 = "2013-12-31"; - assertEquals(DateStringUtils.monthOfYear(day1), 12); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-12"; - assertEquals(DateStringUtils.monthOfYear(day1), 3); - - assertEquals(DateStringUtils.monthOfYear(null), QueryConstants.NULL_INT); - - // bad date - try { - DateStringUtils.monthOfYear("2018-02-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } -} From 01755769982f8bf71521c25297cfe676e7235d59 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Thu, 6 Jul 2023 18:03:36 -0700 Subject: [PATCH 022/150] BusinessCalendar refactoring and cleanup: * DefaultNoHolidayBusinessCalendar --- .../DefaultNoHolidayBusinessCalendar.java | 200 ------------------ .../TestDefaultNoHolidayBusinessCalendar.java | 179 ---------------- 2 files changed, 379 deletions(-) delete mode 100644 engine/time/src/main/java/io/deephaven/time/calendar/DefaultNoHolidayBusinessCalendar.java delete mode 100644 engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/DefaultNoHolidayBusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/DefaultNoHolidayBusinessCalendar.java deleted file mode 100644 index 8e5682811aa..00000000000 --- a/engine/time/src/main/java/io/deephaven/time/calendar/DefaultNoHolidayBusinessCalendar.java +++ /dev/null @@ -1,200 +0,0 @@ -/** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending - */ -package io.deephaven.time.calendar; - -import java.time.DayOfWeek; -import java.time.Instant; -import java.time.LocalDate; -import java.time.ZoneId; -import java.util.List; -import java.util.Map; - -/** - * A {@link BusinessCalendar} with no non-business days. - */ -public class DefaultNoHolidayBusinessCalendar extends AbstractBusinessCalendar { - - private final BusinessCalendar calendar; - - /** - * Creates a new Default24HourBusinessCalendar instance. Assumes that {@code calendar} is a {@link BusinessCalendar} - * with no holidays and a 24 hour business day. - * - * @param calendar {@link BusinessCalendar} with no holidays and a 24 hour business day - */ - protected DefaultNoHolidayBusinessCalendar(final BusinessCalendar calendar) { - this.calendar = calendar; - } - - @Override - public List getDefaultBusinessPeriods() { - return calendar.getDefaultBusinessPeriods(); - } - - @Override - public Map getHolidays() { - return calendar.holidays(); - } - - @Override - public boolean isBusinessDay(DayOfWeek day) { - return true; - } - - @Override - public String name() { - return calendar.name(); - } - - @Override - public ZoneId timeZone() { - return calendar.timeZone(); - } - - @Override - public long standardBusinessDayLengthNanos() { - return calendar.standardBusinessDayLengthNanos(); - } - - @Override - public BusinessSchedule getBusinessSchedule(final Instant time) { - return calendar.businessSchedule(time); - } - - @Override - public BusinessSchedule getBusinessSchedule(final String date) { - return calendar.businessSchedule(date); - } - - @Override - public BusinessSchedule getBusinessSchedule(final LocalDate date) { - return calendar.businessSchedule(date); - } - - @Override - public long diffBusinessNanos(final Instant start, final Instant end) { - return calendar.diffBusinessNanos(start, end); - } - - @Override - public double diffBusinessYear(final Instant startTime, final Instant endTime) { - return calendar.diffBusinessYears(startTime, endTime); - } - - @Override - public String toString() { - return calendar.toString(); - } - - @Override - public boolean equals(Object obj) { - return calendar.equals(obj); - } - - @Override - public int hashCode() { - return calendar.hashCode(); - } - - ////////////////////////////////// NonBusinessDay methods ////////////////////////////////// - @Override - public String previousNonBusinessDay() { - throw new UnsupportedOperationException("Calendar has no non-business days."); - } - - @Override - public String previousNonBusinessDay(int days) { - throw new UnsupportedOperationException("Calendar has no non-business days."); - } - - @Override - public String previousNonBusinessDay(Instant time) { - throw new UnsupportedOperationException("Calendar has no non-business days."); - } - - @Override - public String previousNonBusinessDay(Instant time, int days) { - throw new UnsupportedOperationException("Calendar has no non-business days."); - } - - @Override - public String previousNonBusinessDay(String date) { - throw new UnsupportedOperationException("Calendar has no non-business days."); - } - - @Override - public String previousNonBusinessDay(String date, int days) { - throw new UnsupportedOperationException("Calendar has no non-business days."); - } - - @Override - public String nextNonBusinessDay() { - throw new UnsupportedOperationException("Calendar has no non-business days."); - } - - @Override - public String nextNonBusinessDay(int days) { - throw new UnsupportedOperationException("Calendar has no non-business days."); - } - - @Override - public String nextNonBusinessDay(Instant time) { - throw new UnsupportedOperationException("Calendar has no non-business days."); - } - - @Override - public String nextNonBusinessDay(Instant time, int days) { - throw new UnsupportedOperationException("Calendar has no non-business days."); - } - - @Override - public String nextNonBusinessDay(String date) { - throw new UnsupportedOperationException("Calendar has no non-business days."); - } - - @Override - public String nextNonBusinessDay(String date, int days) { - throw new UnsupportedOperationException("Calendar has no non-business days."); - } - - @Override - public String[] nonBusinessDaysInRange(Instant start, Instant end) { - return new String[0]; - } - - @Override - public String[] nonBusinessDaysInRange(String start, String end) { - return new String[0]; - } - - @Override - public long diffNonBusinessNanos(Instant start, Instant end) { - return 0; - } - - @Override - public double diffNonBusinessDay(Instant start, Instant end) { - return 0; - } - - @Override - public int numberOfNonBusinessDays(Instant start, Instant end) { - return 0; - } - - @Override - public int numberOfNonBusinessDays(Instant start, Instant end, boolean endInclusive) { - return 0; - } - - @Override - public int numberOfNonBusinessDays(String start, String end) { - return 0; - } - - @Override - public int numberOfNonBusinessDays(String start, String end, boolean endInclusive) { - return 0; - } -} diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java deleted file mode 100644 index 031b14e3e27..00000000000 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultNoHolidayBusinessCalendar.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending - */ -package io.deephaven.time.calendar; - -import io.deephaven.base.testing.BaseArrayTestCase; -import io.deephaven.time.DateTimeUtils; - -import java.io.File; -import java.io.FileWriter; -import java.time.ZoneId; - -public class TestDefaultNoHolidayBusinessCalendar extends BaseArrayTestCase { - - private static final ZoneId TZ_NY = ZoneId.of("America/New_York"); - - private BusinessCalendar noNonBusinessDays; - private BusinessCalendar onlyWeekends; - private BusinessCalendar onlyHolidays; - private BusinessCalendar weekendsAndHolidays; - - @Override - public void setUp() throws Exception { - super.setUp(); - final File noNonBusinessDaysFile = File.createTempFile("noNonBusinessDays", ".calendar"); - FileWriter fw = new FileWriter(noNonBusinessDaysFile); - fw.write("\n" + - "\n" + - "\n" + - " noNonBusinessDays\n" + - " NY\n" + - " en\n" + - " US\n" + - " \n" + - " 09:30,16:00\n" + - " \n" + - ""); - fw.flush(); - fw.close(); - - noNonBusinessDays = DefaultBusinessCalendar.getInstance(noNonBusinessDaysFile); - - final File onlyWeekendsFile = File.createTempFile("onlyWeekends", ".calendar"); - fw = new FileWriter(onlyWeekendsFile); - fw.write("\n" + - "\n" + - "\n" + - " onlyWeekends\n" + - " NY\n" + - " en\n" + - " US\n" + - " \n" + - " 09:30,16:00\n" + - " Saturday\n" + - " Sunday\n" + - " \n" + - ""); - fw.flush(); - fw.close(); - - onlyWeekends = DefaultBusinessCalendar.getInstance(onlyWeekendsFile); - - final File onlyHolidaysFile = File.createTempFile("onlyHolidays", ".calendar"); - fw = new FileWriter(onlyHolidaysFile); - fw.write("\n" + - "\n" + - "\n" + - " onlyHolidays\n" + - " NY\n" + - " en\n" + - " US\n" + - " \n" + - " 09:30,16:00\n" + - " \n" + - " \n" + - " 20210215\n" + - " " + - ""); - fw.flush(); - fw.close(); - - onlyHolidays = DefaultBusinessCalendar.getInstance(onlyWeekendsFile); - - final File weekendsAndHolidaysFile = File.createTempFile("weekendsAndHolidays", ".calendar"); - fw = new FileWriter(weekendsAndHolidaysFile); - fw.write("\n" + - "\n" + - "\n" + - " weekendsAndHolidays\n" + - " NY\n" + - " en\n" + - " US\n" + - " \n" + - " 09:30,16:00\n" + - " Saturday\n" + - " Sunday\n" + - " \n" + - " \n" + - " 20210215\n" + - " " + - ""); - fw.flush(); - fw.close(); - - weekendsAndHolidays = DefaultBusinessCalendar.getInstance(weekendsAndHolidaysFile); - } - - public void testInstance() { - assertTrue(noNonBusinessDays instanceof DefaultNoHolidayBusinessCalendar); - assertFalse(onlyHolidays instanceof DefaultNoHolidayBusinessCalendar); - assertFalse(onlyWeekends instanceof DefaultNoHolidayBusinessCalendar); - assertFalse(weekendsAndHolidays instanceof DefaultNoHolidayBusinessCalendar); - } - - public void testNonBusinessDayMethods() { - try { - noNonBusinessDays.pastNonBusinessDate(); - fail(); - } catch (UnsupportedOperationException e) { - // ok - } - try { - noNonBusinessDays.pastNonBusinessDate(1); - fail(); - } catch (UnsupportedOperationException e) { - // ok - } - try { - noNonBusinessDays.pastNonBusinessDate("20190626"); - fail(); - } catch (UnsupportedOperationException e) { - // ok - } - try { - noNonBusinessDays.futureNonBusinessDate(); - fail(); - } catch (UnsupportedOperationException e) { - // ok - } - try { - noNonBusinessDays.futureNonBusinessDate(1); - fail(); - } catch (UnsupportedOperationException e) { - // ok - } - try { - noNonBusinessDays.futureNonBusinessDate("20190626"); - fail(); - } catch (UnsupportedOperationException e) { - // ok - } - - assertEquals(noNonBusinessDays.nonBusinessDates("2010-01-01", "2019-01-01"), new String[0]); - assertEquals( - noNonBusinessDays.diffNonBusinessNanos( - DateTimeUtils.parseInstant("2010-01-01T01:00:00.000000000 NY"), - DateTimeUtils.parseInstant("2019-01-01T01:00:00.000000000 NY")), - 0); - assertEquals(noNonBusinessDays.numberOfNonBusinessDays("2010-01-01", "2019-01-01"), 0); - - - assertEquals(noNonBusinessDays.name(), "noNonBusinessDays"); - assertEquals(noNonBusinessDays.timeZone(), TZ_NY); - assertEquals(noNonBusinessDays.standardBusinessDayLengthNanos(), - 6 * DateTimeUtils.HOUR + (30 * DateTimeUtils.MINUTE)); - assertEquals(noNonBusinessDays.businessSchedule("2019-06-26").businessStart(), - onlyWeekends.businessSchedule("2019-06-26").businessStart()); - assertEquals(noNonBusinessDays.businessSchedule("2019-06-26").businessEnd(), - onlyWeekends.businessSchedule("2019-06-26").businessEnd()); - } -} From decb87bbf397b1e88785c0a42762cd013c47d5aa Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Mon, 10 Jul 2023 13:40:58 -0600 Subject: [PATCH 023/150] BusinessCalendar refactoring and cleanup: * Ranges --- .../time/calendar/BusinessCalendar.java | 614 ++++++++++++------ .../io/deephaven/time/calendar/Calendar.java | 298 ++++++--- 2 files changed, 614 insertions(+), 298 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index a7c3226ec67..cad71a267c7 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -742,314 +742,540 @@ public double fractionOfBusinessDayRemaining(){ // endregion - *** - // region Ranges - //TODO: consistently handle inclusive / exclusive in these ranges - /** - * Returns the number of business days between {@code start} and {@code end}. + * Returns the number of business dates in a given range. * - * @param start start time; if null, return NULL_INT - * @param end end time; if null, return NULL_INT - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} - * respectively. + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return number of business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ - public int numberBusinessDates(final LocalDate start, final LocalDate end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } + public int numberBusinessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); int days = 0; - if (start.isBefore(end)) { - if (isBusinessDay(start)) { + + for (LocalDate day = start; !day.isAfter(end); day = day.plusDays(1)) { + final boolean skip = (!startInclusive && day.equals(start)) || (!endInclusive && day.equals(end)); + + if(!skip && isBusinessDay(day)) { days++; } - start = plusBusinessDays(start, 1); - } else if (start.isAfter(end)) { - //TODO: is this working right? - return -numberBusinessDates(end, start, endInclusive); } - LocalDate day = start; + return days; + } - while (day.isBefore(end)) { - days++; - day = plusBusinessDays(day,1); - } + /** + * Returns the number of business dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return number of business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed + */ + public int numberBusinessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return numberBusinessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive, endInclusive); + } - return days + (endInclusive && isBusinessDay(end) ? 1 : 0); + /** + * Returns the number of business dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return number of business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public int numberBusinessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return numberBusinessDates(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate(), startInclusive, endInclusive); } - //TODO: add endInclusive on all methods /** - * Returns the number of business days between {@code start} and {@code end}. + * Returns the number of business dates in a given range. * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} - * respectively. + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return number of business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ - public int numberBusinessDates(Instant start, Instant end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } + public int numberBusinessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return numberBusinessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), startInclusive, endInclusive); + } - return numberBusinessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), endInclusive); + /** + * Returns the number of business dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @return number of business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public int numberBusinessDates(final LocalDate start, final LocalDate end) { + return numberBusinessDates(start,end, true, true); } /** - * Returns the number of business days between {@code start} and {@code end}. + * Returns the number of business dates in a given range. * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} - * respectively. + * @param start start of a time range + * @param end end of a time range + * @return number of business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public int numberBusinessDates(ZonedDateTime start, ZonedDateTime end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } + public int numberBusinessDates(final String start, final String end) { + return numberBusinessDates(start,end, true, true); + } - return numberBusinessDates(DateTimeUtils.toLocalDate(start.toInstant(), timeZone()), DateTimeUtils.toLocalDate(end.toInstant(), timeZone()), endInclusive); + /** + * Returns the number of business dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @return number of business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public int numberBusinessDates(final ZonedDateTime start, final ZonedDateTime end) { + return numberBusinessDates(start,end, true, true); } /** - * Returns the number of business days between {@code start} and {@code end}. + * Returns the number of business dates in a given range. * - * @param start start time; if null, return NULL_INT - * @param end end time; if null, return NULL_INT - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} - * respectively. + * @param start start of a time range + * @param end end of a time range + * @return number of business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ - public int numberBusinessDates(String start, String end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } + public int numberBusinessDates(final Instant start, final Instant end) { + return numberBusinessDates(start,end, true, true); + } - return numberBusinessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), endInclusive); + /** + * Returns the number of non-business dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return number of non-business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public int numberNonBusinessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + + return numberCalendarDates(start, end, startInclusive, endInclusive) - numberBusinessDates(start, end, startInclusive, endInclusive); } /** - * Returns the number of non-business days between {@code start} and {@code end}. + * Returns the number of non-business dates in a given range. * - * @param start start time; if null, return NULL_INT - * @param end end time; if null, return NULL_INT - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return number of non-business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} - * respectively. + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return number of non-business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public int numberNonBusinessDates(final LocalDate start, final LocalDate end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } + public int numberNonBusinessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return numberNonBusinessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive, endInclusive); + } - return numberCalendarDates(start, end, endInclusive) - numberBusinessDates(start, end, endInclusive); + /** + * Returns the number of non-business dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return number of non-business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public int numberNonBusinessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return numberNonBusinessDates(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate(), startInclusive, endInclusive); } /** - * Returns the number of non-business days between {@code start} and {@code end}. + * Returns the number of non-business dates in a given range. * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return number of business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} - * respectively. + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return number of non-business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ - public int numberNonBusinessDates(Instant start, Instant end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } + public int numberNonBusinessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return numberNonBusinessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), startInclusive, endInclusive); + } - return numberNonBusinessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), endInclusive); + /** + * Returns the number of non-business dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @return number of non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public int numberNonBusinessDates(final LocalDate start, final LocalDate end) { + return numberNonBusinessDates(start,end, true, true); } /** - * Returns the number of non-business days between {@code start} and {@code end}. + * Returns the number of non-business dates in a given range. * - * @param start start time; if null, return NULL_INT - * @param end end time; if null, return NULL_INT - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return number of non-business days between the {@code start} and {@code end}, inclusive and {@code endInclusive} - * respectively. + * @param start start of a time range + * @param end end of a time range + * @return number of non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public int numberNonBusinessDates(final String start, final String end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } + public int numberNonBusinessDates(final String start, final String end) { + return numberNonBusinessDates(start,end, true, true); + } - return numberNonBusinessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), endInclusive); + /** + * Returns the number of non-business dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @return number of non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public int numberNonBusinessDates(final ZonedDateTime start, final ZonedDateTime end) { + return numberNonBusinessDates(start,end, true, true); } /** - * Returns the business days between {@code start} and {@code end}, inclusive. + * Returns the number of non-business dates in a given range. * - * Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for {@code start} - * and {@code end} will be included if they are business days. + * @param start start of a time range + * @param end end of a time range + * @return number of non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public int numberNonBusinessDates(final Instant start, final Instant end) { + return numberNonBusinessDates(start,end, true, true); + } + + /** + * Returns the business dates in a given range. * - * @param start start time; if null, return empty array - * @param end end time; if null, return empty array - * @return inclusive business days between {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ - public LocalDate[] businessDates(final LocalDate start, final LocalDate end) { - if (start == null || end == null) { - return new LocalDate[0]; - } + public LocalDate[] businessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); - LocalDate day = start; - final List dateList = new ArrayList<>(); + List dateList = new ArrayList<>(); - while (!day.isAfter(end)) { - if (isBusinessDay(day)) { + for (LocalDate day = start; !day.isAfter(end); day = day.plusDays(1)) { + final boolean skip = (!startInclusive && day.equals(start)) || (!endInclusive && day.equals(end)); + + if(!skip && isBusinessDay(day)) { dateList.add(day); } - day = day.plusDays(1); } return dateList.toArray(new LocalDate[0]); } /** - * Returns the business days between {@code start} and {@code end}, inclusive. - * - * Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for {@code start} - * and {@code end} will be included if they are business days. + * Returns the business dates in a given range. * - * @param start start time; if null, return empty array - * @param end end time; if null, return empty array - * @return inclusive business days between {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public LocalDate[] businessDates(final Instant start, final Instant end) { - if (start == null || end == null) { - return new LocalDate[0]; - } - - return businessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone())); + public LocalDate[] businessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return businessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive, endInclusive); } /** - * Returns the business days between {@code start} and {@code end}, inclusive. - * - * Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for {@code start} - * and {@code end} will be included if they are business days. + * Returns the business dates in a given range. * - * @param start start time; if null, return empty array - * @param end end time; if null, return empty array - * @return inclusive business days between {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ - public LocalDate[] businessDates(final ZonedDateTime start, final ZonedDateTime end) { - if (start == null || end == null) { - return new LocalDate[0]; - } + public LocalDate[] businessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return businessDates(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate(), startInclusive, endInclusive); + } - return businessDates(DateTimeUtils.toLocalDate(start.toInstant(), timeZone()), DateTimeUtils.toLocalDate(end.toInstant(), timeZone())); + /** + * Returns the business dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public LocalDate[] businessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return businessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), startInclusive, endInclusive); } /** - * Returns the business days between {@code start} and {@code end}, inclusive. + * Returns the business dates in a given range. * - * Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for {@code start} - * and {@code end} will be included if they are business days. + * @param start start of a time range + * @param end end of a time range + * @return business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public LocalDate[] businessDates(final LocalDate start, final LocalDate end) { + return businessDates(start,end, true, true); + } + + /** + * Returns the business dates in a given range. * - * @param start start time; if null, return empty array - * @param end end time; if null, return empty array - * @return inclusive business days between {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @return business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public LocalDate[] businessDates(String start, String end){ - if (start == null || end == null) { - return new LocalDate[0]; - } + public LocalDate[] businessDates(final String start, final String end) { + return businessDates(start,end, true, true); + } - return businessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end)); + /** + * Returns the business dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @return business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public LocalDate[] businessDates(final ZonedDateTime start, final ZonedDateTime end) { + return businessDates(start,end, true, true); } /** - * Returns the non-business days between {@code start} and {@code end}, inclusive. + * Returns the business dates in a given range. * - * Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for {@code start} - * and {@code end} will be included if they are non-business days. + * @param start start of a time range + * @param end end of a time range + * @return business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public LocalDate[] businessDates(final Instant start, final Instant end) { + return businessDates(start,end, true, true); + } + + /** + * Returns the non-business dates in a given range. * - * @param start start time; if null, return empty array - * @param end end time; if null, return empty array - * @return inclusive non-business days between {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return non-business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ - public LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end){ - if (start == null || end == null) { - return new LocalDate[0]; - } + public LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + + List dateList = new ArrayList<>(); - LocalDate day = start; - final List dateList = new ArrayList<>(); + for (LocalDate day = start; !day.isAfter(end); day = day.plusDays(1)) { + final boolean skip = (!startInclusive && day.equals(start)) || (!endInclusive && day.equals(end)); - while (!day.isAfter(end)) { - if (!isBusinessDay(day)) { + if(!skip && !isBusinessDay(day)) { dateList.add(day); } - day = day.plusDays(1); } return dateList.toArray(new LocalDate[0]); } /** - * Returns the non-business days between {@code start} and {@code end}, inclusive. - * - * Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for {@code start} - * and {@code end} will be included if they are non-business days. + * Returns the non-business dates in a given range. * - * @param start start time; if null, return empty array - * @param end end time; if null, return empty array - * @return inclusive non-business days between {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return non-business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public LocalDate[] nonBusinessDates(final Instant start, final Instant end){ - if (start == null || end == null) { - return new LocalDate[0]; - } - - return nonBusinessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone())); + public LocalDate[] nonBusinessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return nonBusinessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive, endInclusive); } /** - * Returns the non-business days between {@code start} and {@code end}, inclusive. + * Returns the non-business dates in a given range. * - * Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for {@code start} - * and {@code end} will be included if they are non-business days. + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return non-business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public LocalDate[] nonBusinessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return nonBusinessDates(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate(), startInclusive, endInclusive); + } + + /** + * Returns the non-business dates in a given range. * - * @param start start time; if null, return empty array - * @param end end time; if null, return empty array - * @return inclusive non-business days between {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return non-business dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ - public LocalDate[] nonBusinessDates(final ZonedDateTime start, final ZonedDateTime end){ - if (start == null || end == null) { - return new LocalDate[0]; - } + public LocalDate[] nonBusinessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return nonBusinessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), startInclusive, endInclusive); + } - return nonBusinessDates(DateTimeUtils.toLocalDate(start.toInstant(), timeZone()), DateTimeUtils.toLocalDate(end.toInstant(), timeZone())); + /** + * Returns the non-business dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @return non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end) { + return nonBusinessDates(start,end, true, true); } /** - * Returns the non-business days between {@code start} and {@code end}, inclusive. + * Returns the non-business dates in a given range. * - * Because no time information (e.g., hours, minutes, seconds) is returned, the corresponding days for {@code start} - * and {@code end} will be included if they are non-business days. + * @param start start of a time range + * @param end end of a time range + * @return non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed + */ + public LocalDate[] nonBusinessDates(final String start, final String end) { + return nonBusinessDates(start,end, true, true); + } + + /** + * Returns the non-business dates in a given range. * - * @param start start time; if null, return empty array - * @param end end time; if null, return empty array - * @return inclusive non-business days between {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @return non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ - public LocalDate[] nonBusinessDates(String start, String end){ - if (start == null || end == null) { - return new LocalDate[0]; - } + public LocalDate[] nonBusinessDates(final ZonedDateTime start, final ZonedDateTime end) { + return nonBusinessDates(start,end, true, true); + } - return nonBusinessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end)); + /** + * Returns the non-business dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @return non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range + */ + public LocalDate[] nonBusinessDates(final Instant start, final Instant end) { + return nonBusinessDates(start,end, true, true); } + // endregion + + // Differences + + **** + + //TODO: new range + + //TODO: consistently handle inclusive / exclusive in these ranges + /** * Returns the amount of business time in nanoseconds between {@code start} and {@code end}. * diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java index 7e59b9c860d..0642ce837a5 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java @@ -3,15 +3,20 @@ */ package io.deephaven.time.calendar; +import io.deephaven.base.verify.Require; +import io.deephaven.base.verify.RequirementFailure; import io.deephaven.time.DateTimeUtils; -import io.deephaven.util.QueryConstants; -import java.time.*; +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; //TODO: review all docs +//TODO: add final to all methods /** * A calendar. @@ -73,6 +78,15 @@ public ZoneId timeZone() { return timeZone; } + @Override + public String toString() { + return "Calendar{" + + "name='" + name + '\'' + + ", description='" + description + '\'' + + ", timeZone=" + timeZone + + '}'; + } + // endregion // region Arithmetic @@ -232,187 +246,263 @@ public LocalDate pastDate(int days) { // region Ranges /** - * Gets the days in a given range. + * Returns the dates in a given range. * - * @param start start of a time range; if null, return empty array - * @param end end of a time range; if null, return empty array - * @return the inclusive days between {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null */ - public LocalDate[] calendarDates(final LocalDate start, final LocalDate end) { - if (start == null || end == null) { - return new LocalDate[0]; - } + public LocalDate[] calendarDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); - LocalDate day = start; List dateList = new ArrayList<>(); - while (!day.isAfter(end)) { - dateList.add(day); - day = day.plusDays(1); + for (LocalDate day = start; !day.isAfter(end); day = day.plusDays(1)) { + final boolean skip = (!startInclusive && day.equals(start)) || (!endInclusive && day.equals(end)); + + if(!skip) { + dateList.add(day); + } } return dateList.toArray(new LocalDate[0]); } /** - * Gets the days in a given range. + * Returns the dates in a given range. * - * @param start start of a time range; if null, return empty array - * @param end end of a time range; if null, return empty array - * @return the inclusive days between {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public LocalDate[] calendarDates(final ZonedDateTime start, final ZonedDateTime end) { - if (start == null || end == null) { - return new LocalDate[0]; - } + public LocalDate[] calendarDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return calendarDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive, endInclusive); + } - return calendarDates(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate()); + /** + * Returns the dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed + */ + public LocalDate[] calendarDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return calendarDates(start.withZoneSameInstant(timeZone).toLocalDate(), end.withZoneSameInstant(timeZone).toLocalDate(), startInclusive, endInclusive); } /** - * Gets the days in a given range. + * Returns the dates in a given range. * - * @param start start of a time range; if null, return empty array - * @param end end of a time range; if null, return empty array - * @return the inclusive days between {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public LocalDate[] calendarDates(final Instant start, final Instant end) { - if (start == null || end == null) { - return new LocalDate[0]; - } + public LocalDate[] calendarDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return calendarDates(DateTimeUtils.toLocalDate(start, timeZone), DateTimeUtils.toLocalDate(end, timeZone), startInclusive, endInclusive); + } - return calendarDates(DateTimeUtils.toZonedDateTime(start, timeZone()).toLocalDate(), DateTimeUtils.toZonedDateTime(end, timeZone()).toLocalDate()); + /** + * Returns the dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @return dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + */ + public LocalDate[] calendarDates(final LocalDate start, final LocalDate end) { + return calendarDates(start,end, true, true); } /** - * Gets the days in a given range. + * Returns the dates in a given range. * - * @param start start of a time range; if null, return empty array - * @param end end of a time range; if null, return empty array - * @return the inclusive days between {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @return dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate[] calendarDates(final String start, final String end) { - if (start == null || end == null) { - return new LocalDate[0]; - } - - return calendarDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end)); + return calendarDates(start,end, true, true); } /** - * Gets the number of days in a given range. + * Returns the dates in a given range. * - * @param start start of a time range - * @param end end of a time range - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. + * @param start start of a time range + * @param end end of a time range + * @return dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null */ - public int numberCalendarDates(final LocalDate start, final LocalDate end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } - - int days = (int) ChronoUnit.DAYS.between(start, end); - if (days < 0) { - days = days - (endInclusive ? 1 : 0); - } else { - days = days + (endInclusive ? 1 : 0); - } - return days; + public LocalDate[] calendarDates(final ZonedDateTime start, final ZonedDateTime end) { + return calendarDates(start,end, true, true); } /** - * Gets the number of days in a given range, end date exclusive. + * Returns the dates in a given range. * * @param start start of a time range * @param end end of a time range - * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. + * @return dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null */ - public int numberCalendarDates(final LocalDate start, final LocalDate end) { - return numberCalendarDates(start, end, false); + public LocalDate[] calendarDates(final Instant start, final Instant end) { + return calendarDates(start,end, true, true); } /** - * Gets the number of days in a given range. + * Returns the number of dates in a given range. * - * @param start start of a time range - * @param end end of a time range - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return number of dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null */ - public int numberCalendarDates(final ZonedDateTime start, final ZonedDateTime end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } + public int numberCalendarDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + + int days = (int) ChronoUnit.DAYS.between(start, end.plusDays(1)); + + if(!startInclusive){ + days -= 1; + } - return numberCalendarDates(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate(), endInclusive); + if(!endInclusive){ + days -= 1; + } + + return Math.max(days, 0); } /** - * Gets the number of days in a given range, end date exclusive. + * Returns the number of dates in a given range. * * @param start start of a time range * @param end end of a time range - * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return number of dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public int numberCalendarDates(final ZonedDateTime start, final ZonedDateTime end) { - return numberCalendarDates(start, end, false); + public int numberCalendarDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return numberCalendarDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive, endInclusive); } /** - * Gets the number of days in a given range. + * Returns the number of dates in a given range. * - * @param start start of a time range - * @param end end of a time range - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return number of dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public int numberCalendarDates(final Instant start, final Instant end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } + public int numberCalendarDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return numberCalendarDates(start.withZoneSameInstant(timeZone).toLocalDate(), end.withZoneSameInstant(timeZone).toLocalDate(), startInclusive, endInclusive); + } - return numberCalendarDates(DateTimeUtils.toZonedDateTime(start, timeZone()).toLocalDate(), DateTimeUtils.toZonedDateTime(end, timeZone()).toLocalDate(), endInclusive); + /** + * Returns the number of dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @return number of dates between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed + */ + public int numberCalendarDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return numberCalendarDates(DateTimeUtils.toLocalDate(start, timeZone), DateTimeUtils.toLocalDate(end, timeZone), startInclusive, endInclusive); } /** - * Gets the number of days in a given range, end date exclusive. + * Returns the number of dates in a given range. * * @param start start of a time range * @param end end of a time range - * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. + * @return number of dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null */ - public int numberCalendarDates(final Instant start, final Instant end) { - return numberCalendarDates(start, end, false); + public int numberCalendarDates(final LocalDate start, final LocalDate end) { + return numberCalendarDates(start,end, true, true); } /** - * Gets the number of days in a given range. + * Returns the number of dates in a given range. * - * @param start start of a time range - * @param end end of a time range - * @param endInclusive whether to treat the {@code end} inclusive or exclusively - * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. + * @param start start of a time range + * @param end end of a time range + * @return number of dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public int numberCalendarDates(final String start, final String end, final boolean endInclusive) { - if (start == null || end == null) { - return QueryConstants.NULL_INT; - } + public int numberCalendarDates(final String start, final String end) { + return numberCalendarDates(start,end, true, true); + } - return numberCalendarDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), endInclusive); + /** + * Returns the number of dates in a given range. + * + * @param start start of a time range + * @param end end of a time range + * @return number of dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null + */ + public int numberCalendarDates(final ZonedDateTime start, final ZonedDateTime end) { + return numberCalendarDates(start,end, true, true); } /** - * Gets the number of days in a given range, end date exclusive. + * Returns the number of dates in a given range. * * @param start start of a time range * @param end end of a time range - * @return the number of days between {@code start} and {@code end}, or {@code NULL_INT} if any input is null. + * @return number of dates between {@code start} and {@code end}; including {@code start} and {@code end} + * @throws RequirementFailure if any input is null */ - public int numberCalendarDates(final String start, final String end) { - return numberCalendarDates(start, end, false); + public int numberCalendarDates(final Instant start, final Instant end) { + return numberCalendarDates(start,end, true, true); } + // endregion + + // region Differences + //TODO: time diff methods? // diffBusinessDay // diffBusinessDay From 6fa40778b97b6e99f155c04a64abff2f7b2bd79a Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 11 Jul 2023 12:23:06 -0600 Subject: [PATCH 024/150] BusinessCalendar refactoring and cleanup: * Differences --- .../time/calendar/BusinessCalendar.java | 258 +++++++----------- .../io/deephaven/time/calendar/Calendar.java | 8 +- 2 files changed, 103 insertions(+), 163 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index cad71a267c7..c83d4034b23 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -6,14 +6,12 @@ import io.deephaven.base.verify.Require; import io.deephaven.base.verify.RequirementFailure; import io.deephaven.time.DateTimeUtils; -import io.deephaven.util.QueryConstants; import java.time.*; import java.util.*; //TODO: update all headers //TODO: review all docs -//TODO: add final to all methods /** * A business calendar, with the concept of business and non-business time. @@ -123,11 +121,21 @@ private void populateCachedYearData() { } } + private YearData getYearData(final int year){ + final YearData yd = cachedYearData.get(year); + + if(yd == null){ + throw new InvalidDateException("Business calendar does not contain a complete year for: year=" + year); + } + + return yd; + } + // endregion // region Constructors - public BusinessCalendar(String name, String description, ZoneId timeZone, LocalDate firstValidDate, LocalDate lastValidDate, BusinessSchedule standardBusinessSchedule, Set weekendDays, Map> holidays) { + public BusinessCalendar(final String name, final String description, final ZoneId timeZone, final LocalDate firstValidDate, final LocalDate lastValidDate, final BusinessSchedule standardBusinessSchedule, final Set weekendDays, final Map> holidays) { super(name, description, timeZone); this.firstValidDate = firstValidDate; this.lastValidDate = lastValidDate; @@ -227,7 +235,7 @@ public BusinessSchedule businessSchedule(final Instant time) { * @throws InvalidDateException if the date is not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public BusinessSchedule businessSchedule(String date) { + public BusinessSchedule businessSchedule(final String date) { Require.neqNull(date, "date"); return businessSchedule(DateTimeUtils.parseLocalDate(date)); } @@ -303,7 +311,7 @@ public boolean isBusinessDay(final Instant time){ * @return true if the day is a business day; false otherwise * @throws RequirementFailure if the input is null */ - public boolean isBusinessDay(DayOfWeek day){ + public boolean isBusinessDay(final DayOfWeek day){ Require.neqNull(day, "day"); return !weekendDays.contains(day); } @@ -420,7 +428,7 @@ public boolean isLastBusinessDayOfWeek(final LocalDate date){ */ public boolean isLastBusinessDayOfWeek(final ZonedDateTime time) { Require.neqNull(time, "time"); - return isLastBusinessDayOfWeek(DateTimeUtils.toLocalDate(time, timeZone())); + return isLastBusinessDayOfWeek(time.withZoneSameInstant(timeZone()).toLocalDate()); } /** @@ -1268,195 +1276,114 @@ public LocalDate[] nonBusinessDates(final Instant start, final Instant end) { // endregion - // Differences - - **** - - //TODO: new range - - //TODO: consistently handle inclusive / exclusive in these ranges + // region Differences /** - * Returns the amount of business time in nanoseconds between {@code start} and {@code end}. + * Returns the amount of business time in nanoseconds between two times. * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @return the amount of business time in nanoseconds between the {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @return the amount of business time in nanoseconds between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ public long diffBusinessNanos(final Instant start, final Instant end) { - if (start == null || end == null) { - return QueryConstants.NULL_LONG; - } + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); if (DateTimeUtils.isAfter(start, end)) { return -diffBusinessNanos(end, start); } - long dayDiffNanos = 0; - Instant day = start; - - while (!DateTimeUtils.isAfter(day, end)) { - if (isBusinessDay(day)) { - BusinessSchedule businessDate = businessSchedule(day); - - if (businessDate != null) { - for (BusinessPeriod businessPeriod : businessDate.periods()) { - Instant endOfPeriod = businessPeriod.end(); - Instant startOfPeriod = businessPeriod.start(); - - // noinspection StatementWithEmptyBody - if (DateTimeUtils.isAfter(day, endOfPeriod) || DateTimeUtils.isBefore(end, startOfPeriod)) { - // continue - } else if (!DateTimeUtils.isAfter(day, startOfPeriod)) { - if (DateTimeUtils.isBefore(end, endOfPeriod)) { - dayDiffNanos += DateTimeUtils.minus(end, startOfPeriod); - } else { - dayDiffNanos += businessPeriod.nanos(); - } - } else { - if (DateTimeUtils.isAfter(end, endOfPeriod)) { - dayDiffNanos += DateTimeUtils.minus(endOfPeriod, day); - } else { - dayDiffNanos += DateTimeUtils.minus(end, day); - } - } - } - } - } - day = businessSchedule(plusBusinessDays(day,1)).businessStart(); + final LocalDate startDate = DateTimeUtils.toLocalDate(start, timeZone()); + final LocalDate endDate = DateTimeUtils.toLocalDate(end, timeZone()); + + assert startDate != null; + assert endDate != null; + + if(startDate.equals(endDate)) { + final BusinessSchedule schedule = businessSchedule(startDate); + return schedule.businessNanosElapsed(end) - schedule.businessNanosElapsed(start); } - return dayDiffNanos; + + long rst = businessSchedule(startDate).businessNanosRemaining(start) + businessSchedule(endDate).businessNanosElapsed(end); + + for (LocalDate d = startDate.plusDays(1); d.isBefore(endDate); d = d.plusDays(1)) { + rst += businessSchedule(d).businessNanos(); + } + + return rst; } /** - * Returns the amount of business time in nanoseconds between {@code start} and {@code end}. + * Returns the amount of business time in nanoseconds between two times. * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @return the amount of business time in nanoseconds between the {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @return the amount of business time in nanoseconds between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ public long diffBusinessNanos(final ZonedDateTime start, final ZonedDateTime end) { - if (start == null || end == null) { - return QueryConstants.NULL_LONG; - } - + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); return diffBusinessNanos(start.toInstant(), end.toInstant()); } /** - * Returns the amount of non-business time in nanoseconds between {@code start} and {@code end}. + * Returns the amount of non-business time in nanoseconds between two times. * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @return the amount of non-business time in nanoseconds between the {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @return the amount of nonbusiness time in nanoseconds between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ public long diffNonBusinessNanos(final Instant start, final Instant end) { - if (start == null || end == null) { - return QueryConstants.NULL_LONG; - } - - if (DateTimeUtils.isAfter(start, end)) { - return -diffNonBusinessNanos(end, start); - } - - return DateTimeUtils.minus(end, start) - diffBusinessNanos(start, end); + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + return DateTimeUtils.diffNanos(start, end) - diffBusinessNanos(start, end); } /** - * Returns the amount of non-business time in nanoseconds between {@code start} and {@code end}. + * Returns the amount of non-business time in nanoseconds between two times. * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @return the amount of non-business time in nanoseconds between the {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @return the amount of non-business time in nanoseconds between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ public long diffNonBusinessNanos(final ZonedDateTime start, final ZonedDateTime end) { - if (start == null || end == null) { - return QueryConstants.NULL_LONG; - } - + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); return diffNonBusinessNanos(start.toInstant(), end.toInstant()); } /** - * Returns the amount of business time in standard business days between {@code start} and {@code end}. + * Returns the amount of business time in standard business days between two times. * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @return the amount of business time in standard business days between the {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @return the amount of business time in standard business days between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ public double diffBusinessDays(final Instant start, final Instant end) { - if (start == null || end == null) { - return QueryConstants.NULL_DOUBLE; - } - return (double) diffBusinessNanos(start, end) / (double) standardBusinessDayLengthNanos(); } /** - * Returns the amount of business time in standard business days between {@code start} and {@code end}. + * Returns the amount of business time in standard business days between two times. * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @return the amount of business time in standard business days between the {@code start} and {@code end} + * @param start start of a time range + * @param end end of a time range + * @return the amount of business time in standard business days between {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ public double diffBusinessDays(final ZonedDateTime start, final ZonedDateTime end) { - if (start == null || end == null) { - return QueryConstants.NULL_DOUBLE; - } - - return diffBusinessDays(start.toInstant(), end.toInstant()); - } - - /** - * Returns the amount of non-business time in standard business days between {@code start} and {@code end}. - * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @return the amount of non-business time in standard business days between the {@code start} and {@code end} - */ - public double diffNonBusinessDays(final Instant start, final Instant end){ - if (start == null || end == null) { - return QueryConstants.NULL_DOUBLE; - } - - return (double) diffNonBusinessNanos(start, end) / (double) standardBusinessDayLengthNanos(); - } - - /** - * Returns the amount of non-business time in standard business days between {@code start} and {@code end}. - * - * @param start start time; if null, return NULL_LONG - * @param end end time; if null, return NULL_LONG - * @return the amount of non-business time in standard business days between the {@code start} and {@code end} - */ - public double diffNonBusinessDays(final ZonedDateTime start, final ZonedDateTime end){ - if (start == null || end == null) { - return QueryConstants.NULL_DOUBLE; - } - - double businessYearDiff = 0.0; - ZonedDateTime time = start; - - while (!DateTimeUtils.isAfter(time, end)) { - final int year = time.getYear(); - final YearData yd = cachedYearData.get(year); - - if(yd == null){ - throw new InvalidDateException("Business calendar does not contain a complete year for: year=" + year); - } - - final long yearDiff; - if (DateTimeUtils.isAfter(yd.end, end)) { - yearDiff = diffBusinessNanos(time, end); - } else { - yearDiff = diffBusinessNanos(time, yd.end); - } - - businessYearDiff += (double) yearDiff / (double) yd.businessTimeNanos; - time = yd.end; - } - - return businessYearDiff; + return (double) diffBusinessNanos(start, end) / (double) standardBusinessDayLengthNanos(); } /** @@ -1465,13 +1392,26 @@ public double diffNonBusinessDays(final ZonedDateTime start, final ZonedDateTime * @param start start; if null, return null * @param end end; if null, return null * @return the amount of business time in business years between the {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ - public double diffBusinessYears(final Instant start, final Instant end){ - if (start == null || end == null) { - return QueryConstants.NULL_DOUBLE; + public double diffBusinessYears(final Instant start, final Instant end) { + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); + + final int yearStart = DateTimeUtils.year(start, timeZone()); + final int yearEnd = DateTimeUtils.year(end, timeZone()); + + if(yearStart == yearEnd){ + return (double) diffBusinessNanos(start, end) / (double) getYearData(yearStart).businessTimeNanos; } - return diffBusinessYears(DateTimeUtils.toZonedDateTime(start, timeZone()), DateTimeUtils.toZonedDateTime(end, timeZone())); + final YearData yearDataStart = getYearData(yearStart); + final YearData yearDataEnd = getYearData(yearEnd); + + return (double) diffBusinessNanos(start, yearDataStart.end.toInstant()) / (double) yearDataStart.businessTimeNanos + + (double) diffBusinessNanos(yearDataEnd.start.toInstant(), end) / (double) yearDataEnd.businessTimeNanos + + yearEnd-yearStart-1; } /** @@ -1480,12 +1420,12 @@ public double diffBusinessYears(final Instant start, final Instant end){ * @param start start; if null, return null * @param end end; if null, return null * @return the amount of business time in business years between the {@code start} and {@code end} + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range */ public double diffBusinessYears(final ZonedDateTime start, final ZonedDateTime end) { - if (start == null || end == null) { - return QueryConstants.NULL_DOUBLE; - } - + Require.neqNull(start, "start"); + Require.neqNull(end, "end"); return diffBusinessYears(start.toInstant(), end.toInstant()); } diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java index 0642ce837a5..c57f2ef7855 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java @@ -16,7 +16,6 @@ import java.util.List; //TODO: review all docs -//TODO: add final to all methods /** * A calendar. @@ -26,6 +25,7 @@ * Date strings must be in a format that can be parsed by {@code DateTimeUtils#parseDate}. Methods that accept * strings can be slower than methods written explicitly for {@code Instant}, {@code ZonedDateTime}, or {@code LocalDate}. */ +@SuppressWarnings("unused") //TODO: remove unused annotation public class Calendar { private final String name; @@ -41,7 +41,7 @@ public class Calendar { * @param description calendar description. * @param timeZone calendar time zone. */ - public Calendar(String name, String description, ZoneId timeZone) { + public Calendar(final String name, final String description, final ZoneId timeZone) { this.name = name; this.description = description; this.timeZone = timeZone; @@ -227,7 +227,7 @@ public LocalDate currentDate() { * @param days number of days to add. * @return {@code days} days after the current date */ - public LocalDate futureDate(int days) { + public LocalDate futureDate(final int days) { return plusDays(currentDate(), days); } @@ -237,7 +237,7 @@ public LocalDate futureDate(int days) { * @param days number of days to subtract. * @return {@code days} days before the current date */ - public LocalDate pastDate(int days) { + public LocalDate pastDate(final int days) { return minusDays(currentDate(), days); } From 3af05d3279fe0c10d3b5cfea11154b2bfac6575c Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 11 Jul 2023 12:32:02 -0600 Subject: [PATCH 025/150] Calendar refactoring and cleanup: * Plus/Minus --- .../time/calendar/BusinessCalendar.java | 5 +- .../io/deephaven/time/calendar/Calendar.java | 67 +++++++------------ 2 files changed, 28 insertions(+), 44 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index c83d4034b23..c182ebb1b20 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -19,7 +19,6 @@ * Methods that take strings as arguments will generally be lower performance than non-string methods, * since strings must first be parsed into dates or times. */ -//TODO: fail on out of range //TODO should the methods be DB null tolerant //TODO: add null annotations @SuppressWarnings("unused") //TODO: remove unused annotation @@ -42,7 +41,7 @@ public static class InvalidDateException extends RuntimeException { * * @param message exception message. */ - private InvalidDateException(String message) { + private InvalidDateException(final String message) { super(message); } @@ -52,7 +51,7 @@ private InvalidDateException(String message) { * @param message exception message. * @param cause cause of the exception. */ - public InvalidDateException(String message, Throwable cause) { + public InvalidDateException(final String message, final Throwable cause) { super(message, cause); } } diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java index c57f2ef7855..b2d98679f66 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java @@ -96,13 +96,11 @@ public String toString() { * * @param date date * @param days number of days to add - * @return {@code days} days after {@code date}; null if {@code date} is null + * @return {@code days} days after {@code date} + * @throws RequirementFailure if the input is null */ public LocalDate plusDays(final LocalDate date, final int days) { - if (date == null) { - return null; - } - + Require.neqNull(date, "date"); return date.plusDays(days); } @@ -111,14 +109,12 @@ public LocalDate plusDays(final LocalDate date, final int days) { * * @param date date * @param days number of days to add - * @return {@code days} days after {@code date}; null if {@code date} is null + * @return {@code days} days after {@code date} + * @throws RequirementFailure if the input is null + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate plusDays(final String date, final int days) { - if (date == null) { - return null; - } - - //TODO: quiet parsing? document exception? + Require.neqNull(date, "date"); return plusDays(DateTimeUtils.parseLocalDate(date), days); } @@ -127,13 +123,11 @@ public LocalDate plusDays(final String date, final int days) { * * @param time time * @param days number of days to add - * @return {@code days} days after {@code time}; null if {@code date} is null + * @return {@code days} days after {@code time} + * @throws RequirementFailure if the input is null */ public LocalDate plusDays(final Instant time, final int days) { - if (time == null) { - return null; - } - + Require.neqNull(time, "time"); return plusDays(DateTimeUtils.toLocalDate(time, timeZone), days); } @@ -142,13 +136,11 @@ public LocalDate plusDays(final Instant time, final int days) { * * @param time time * @param days number of days to add - * @return {@code days} days after {@code time}; null if {@code date} is null + * @return {@code days} days after {@code time} + * @throws RequirementFailure if the input is null */ public LocalDate plusDays(final ZonedDateTime time, final int days) { - if (time == null) { - return null; - } - + Require.neqNull(time, "time"); return plusDays(time.toInstant(), days); } @@ -157,13 +149,11 @@ public LocalDate plusDays(final ZonedDateTime time, final int days) { * * @param date date * @param days number of days to subtract - * @return {@code days} days after {@code date}; null if {@code date} is null + * @return {@code days} days after {@code date} + * @throws RequirementFailure if the input is null */ public LocalDate minusDays(final LocalDate date, final int days) { - if (date == null) { - return null; - } - + Require.neqNull(date, "date"); return date.minusDays(days); } @@ -172,13 +162,12 @@ public LocalDate minusDays(final LocalDate date, final int days) { * * @param date date * @param days number of days to subtract - * @return {@code days} days after {@code date}; null if {@code date} is null + * @return {@code days} days after {@code date} + * @throws RequirementFailure if the input is null + * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate minusDays(final String date, final int days) { - if (date == null) { - return null; - } - + Require.neqNull(date, "date"); return minusDays(DateTimeUtils.parseLocalDate(date), days); } @@ -187,13 +176,11 @@ public LocalDate minusDays(final String date, final int days) { * * @param time time * @param days number of days to subtract - * @return {@code days} days after {@code time}; null if {@code date} is null + * @return {@code days} days after {@code time} + * @throws RequirementFailure if the input is null */ public LocalDate minusDays(final Instant time, final int days) { - if (time == null) { - return null; - } - + Require.neqNull(time, "time"); return minusDays(DateTimeUtils.toLocalDate(time, timeZone), days); } @@ -202,13 +189,11 @@ public LocalDate minusDays(final Instant time, final int days) { * * @param time time * @param days number of days to subtract - * @return {@code days} days after {@code time}; null if {@code date} is null + * @return {@code days} days after {@code time} + * @throws RequirementFailure if the input is null */ public LocalDate minusDays(final ZonedDateTime time, final int days) { - if (time == null) { - return null; - } - + Require.neqNull(time, "time"); return minusDays(time.toInstant(), days); } From f92b1f2cd7fbef7604a96fa2fc5af813e9214714 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 11 Jul 2023 12:43:59 -0600 Subject: [PATCH 026/150] DateTimeUtils added todayDate plus formatting LocalDate. --- .../java/io/deephaven/time/DateTimeUtils.java | 76 +++++++++++++++++-- .../io/deephaven/time/TestDateTimeUtils.java | 10 ++- 2 files changed, 78 insertions(+), 8 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java b/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java index 83dda6920ea..de001a4c567 100644 --- a/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java +++ b/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java @@ -383,7 +383,8 @@ public static Instant nowSystemMillisResolution() { private abstract static class CachedDate { final ZoneId timeZone; - String value; + LocalDate date; + String str; long valueExpirationTimeMillis; private CachedDate(@NotNull final ZoneId timeZone) { @@ -395,15 +396,26 @@ private ZoneId getTimeZone() { return timeZone; } - public String get() { - return get(currentClock().currentTimeMillis()); + public LocalDate getLocalDate() { + return getLocalDate(currentClock().currentTimeMillis()); } - public synchronized String get(final long currentTimeMillis) { + public synchronized LocalDate getLocalDate(final long currentTimeMillis) { if (currentTimeMillis >= valueExpirationTimeMillis) { update(currentTimeMillis); } - return value; + return date; + } + + public String getStr() { + return getStr(currentClock().currentTimeMillis()); + } + + public synchronized String getStr(final long currentTimeMillis) { + if (currentTimeMillis >= valueExpirationTimeMillis) { + update(currentTimeMillis); + } + return str; } abstract void update(long currentTimeMillis); @@ -417,7 +429,8 @@ private CachedCurrentDate(@NotNull final ZoneId timeZone) { @Override void update(final long currentTimeMillis) { - value = formatDate(epochMillisToInstant(currentTimeMillis), timeZone); + date = toLocalDate(epochMillisToInstant(currentTimeMillis), timeZone); + str = formatDate(date); valueExpirationTimeMillis = epochMillis(atMidnight(epochNanosToInstant(millisToNanos(currentTimeMillis) + DAY), timeZone)); } @@ -448,7 +461,7 @@ public ZoneId getKey(final CACHED_DATE_TYPE cachedDate) { @ScriptApi @NotNull public static String today(@NotNull final ZoneId timeZone) { - return cachedCurrentDates.putIfAbsent(timeZone, CachedCurrentDate::new).get(); + return cachedCurrentDates.putIfAbsent(timeZone, CachedCurrentDate::new).getStr(); } /** @@ -468,6 +481,39 @@ public static String today() { return today(DateTimeUtils.timeZone()); } + /** + * Provides the current date string according to the {@link #currentClock() current clock}. Under most + * circumstances, this method will return the date according to current system time, but during replay simulations, + * this method can return the date according to replay time. + * + * @param timeZone the time zone + * @return the current date according to the current clock and time zone formatted as "yyyy-MM-dd" + * @see #currentClock() + * @see #setClock(Clock) + */ + @ScriptApi + @NotNull + public static LocalDate todayDate(@NotNull final ZoneId timeZone) { + return cachedCurrentDates.putIfAbsent(timeZone, CachedCurrentDate::new).getLocalDate(); + } + + /** + * Provides the current date string according to the {@link #currentClock() current clock} and the + * {@link ZoneId#systemDefault() default time zone}. Under most circumstances, this method will return the date + * according to current system time, but during replay simulations, this method can return the date according to + * replay time. + * + * @return the current date according to the current clock and default time zone formatted as "yyyy-MM-dd" + * @see #currentClock() + * @see #setClock(Clock) + * @see ZoneId#systemDefault() + */ + @ScriptApi + @NotNull + public static LocalDate todayDate() { + return todayDate(DateTimeUtils.timeZone()); + } + // endregion // region Time Zone @@ -3158,6 +3204,22 @@ public static String formatDate(@Nullable final ZonedDateTime dateTime) { return ISO_LOCAL_DATE.format(dateTime); } + /** + * Returns a {@link LocalDate} formatted as a "yyyy-MM-dd" string. + * + * @param date date to format as a string + * @return {@code null} if either input is {@code null}; otherwise, the time formatted as a "yyyy-MM-dd" string + */ + @ScriptApi + @Nullable + public static String formatDate(@Nullable final LocalDate date) { + if (date == null) { + return null; + } + + return ISO_LOCAL_DATE.format(date); + } + // endregion // region Parse diff --git a/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java b/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java index 246fe50f2f7..f8b60b2ba44 100644 --- a/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java +++ b/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java @@ -1063,7 +1063,11 @@ public void testFormatDate() { TestCase.assertNull(DateTimeUtils.formatDate(null, TZ_NY)); TestCase.assertNull(DateTimeUtils.formatDate(dt2, null)); - TestCase.assertNull(DateTimeUtils.formatDate(null)); + TestCase.assertNull(DateTimeUtils.formatDate((ZonedDateTime) null)); + + final LocalDate date = LocalDate.of(2021,2,3); + TestCase.assertEquals("2021-02-03", DateTimeUtils.formatDate(date)); + TestCase.assertNull(DateTimeUtils.formatDate((LocalDate) null)); } public void testFormatDateTime() { @@ -1681,6 +1685,10 @@ public Instant instantMillis() { TestCase.assertEquals(DateTimeUtils.formatDate(Instant.ofEpochSecond(0, nanos), TZ_AL), DateTimeUtils.today(TZ_AL)); TestCase.assertEquals(DateTimeUtils.today(DateTimeUtils.timeZone()), DateTimeUtils.today()); + + TestCase.assertEquals(DateTimeUtils.toLocalDate(Instant.ofEpochSecond(0, nanos), TZ_AL), + DateTimeUtils.todayDate(TZ_AL)); + TestCase.assertEquals(DateTimeUtils.todayDate(DateTimeUtils.timeZone()), DateTimeUtils.todayDate()); } catch (Exception ex) { DateTimeUtils.setClock(initial); throw ex; From d1147bd7c907889240f9193d763500cf1ba39795 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 11 Jul 2023 12:47:03 -0600 Subject: [PATCH 027/150] Todo cleanup: * Calendar --- .../io/deephaven/time/calendar/Calendar.java | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java index b2d98679f66..9fa9a66d69e 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java @@ -15,8 +15,6 @@ import java.util.ArrayList; import java.util.List; -//TODO: review all docs - /** * A calendar. * @@ -25,7 +23,6 @@ * Date strings must be in a format that can be parsed by {@code DateTimeUtils#parseDate}. Methods that accept * strings can be slower than methods written explicitly for {@code Instant}, {@code ZonedDateTime}, or {@code LocalDate}. */ -@SuppressWarnings("unused") //TODO: remove unused annotation public class Calendar { private final String name; @@ -203,7 +200,7 @@ public LocalDate minusDays(final ZonedDateTime time, final int days) { * @return current date */ public LocalDate currentDate() { - return DateTimeUtils.today(timeZone()); + return DateTimeUtils.todayDate(timeZone()); } /** @@ -486,20 +483,4 @@ public int numberCalendarDates(final Instant start, final Instant end) { // endregion - // region Differences - - //TODO: time diff methods? -// diffBusinessDay -// diffBusinessDay -// diffBusinessNanos -// diffBusinessNanos -// diffBusinessYear -// diffBusinessYear -// diffNonBusinessDay -// diffNonBusinessDay -// diffNonBusinessNanos -// diffNonBusinessNanos - - // endregion - } From cb5b667545cd980dce018a8568f5d616141bc9b3 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 11 Jul 2023 12:55:21 -0600 Subject: [PATCH 028/150] Todo and docs cleanup: * Calendar * BusinessCalendar --- .../time/calendar/BusinessCalendar.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index c182ebb1b20..f5924f0b5ec 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -10,17 +10,12 @@ import java.time.*; import java.util.*; -//TODO: update all headers -//TODO: review all docs - /** * A business calendar, with the concept of business and non-business time. * - * Methods that take strings as arguments will generally be lower performance than non-string methods, - * since strings must first be parsed into dates or times. + * Date strings must be in a format that can be parsed by {@code DateTimeUtils#parseDate}. Methods that accept + * strings can be slower than methods written explicitly for {@code Instant}, {@code ZonedDateTime}, or {@code LocalDate}. */ -//TODO should the methods be DB null tolerant - //TODO: add null annotations @SuppressWarnings("unused") //TODO: remove unused annotation public class BusinessCalendar extends Calendar { @@ -180,7 +175,7 @@ public Map> holidays() { } /** - * Gets the indicated business day's schedule. + * Returns the business schedule for a date. * * @param date date * @return the corresponding BusinessSchedule of {@code date} @@ -200,7 +195,7 @@ public BusinessSchedule businessSchedule(final LocalDate date) { } /** - * Gets the indicated business day's schedule. + * Returns the business schedule for a date. * * @param time time * @return the corresponding BusinessSchedule of {@code date} @@ -213,7 +208,7 @@ public BusinessSchedule businessSchedule(final ZonedDateTime time) { } /** - * Gets the indicated business day's schedule. + * Returns the business schedule for a date. * * @param time time * @return the corresponding BusinessSchedule of {@code date} @@ -226,7 +221,7 @@ public BusinessSchedule businessSchedule(final Instant time) { } /** - * Gets the indicated business day's schedule. + * Returns the business schedule for a date. * * @param date date * @return the corresponding BusinessSchedule of {@code date} From 2d15d119b3a5e32dadfcb6f9f458ea6fdb6c21d7 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 11 Jul 2023 12:55:56 -0600 Subject: [PATCH 029/150] Todo and docs and formatting cleanup: * Calendar * BusinessCalendar --- .../time/calendar/BusinessCalendar.java | 453 +++++++++--------- .../io/deephaven/time/calendar/Calendar.java | 114 ++--- 2 files changed, 286 insertions(+), 281 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index f5924f0b5ec..f0e86429d8e 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -12,7 +12,7 @@ /** * A business calendar, with the concept of business and non-business time. - * + *

* Date strings must be in a format that can be parsed by {@code DateTimeUtils#parseDate}. Methods that accept * strings can be slower than methods written explicitly for {@code Instant}, {@code ZonedDateTime}, or {@code LocalDate}. */ @@ -44,7 +44,7 @@ private InvalidDateException(final String message) { * Creates a new exception. * * @param message exception message. - * @param cause cause of the exception. + * @param cause cause of the exception. */ public InvalidDateException(final String message, final Throwable cause) { super(message, cause); @@ -55,19 +55,19 @@ public InvalidDateException(final String message, final Throwable cause) { // region Cache - private final Map> cachedSchedules = new HashMap<>(); + private final Map> cachedSchedules = new HashMap<>(); private final Map cachedYearData = new HashMap<>(); private void populateSchedules() { LocalDate date = firstValidDate; - while(date.compareTo(lastValidDate) <= 0) { + while (date.compareTo(lastValidDate) <= 0) { final BusinessSchedule s = holidays.get(date); - if( s != null){ + if (s != null) { cachedSchedules.put(date, s); - } else if(weekendDays.contains(date.getDayOfWeek())) { + } else if (weekendDays.contains(date.getDayOfWeek())) { cachedSchedules.put(date, BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone())); } else { cachedSchedules.put(date, BusinessSchedule.toInstant(standardBusinessSchedule, date, timeZone())); @@ -115,10 +115,10 @@ private void populateCachedYearData() { } } - private YearData getYearData(final int year){ + private YearData getYearData(final int year) { final YearData yd = cachedYearData.get(year); - if(yd == null){ + if (yd == null) { throw new InvalidDateException("Business calendar does not contain a complete year for: year=" + year); } @@ -145,6 +145,7 @@ public BusinessCalendar(final String name, final String description, final ZoneI // region Business Schedule //TODO: rename? + /** * Business schedule for a standard business day. * @@ -155,6 +156,7 @@ public BusinessSchedule standardBusinessSchedule() { } //TODO: rename? + /** * Length of a standard business day in nanoseconds. * @@ -179,15 +181,15 @@ public Map> holidays() { * * @param date date * @return the corresponding BusinessSchedule of {@code date} - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public BusinessSchedule businessSchedule(final LocalDate date) { Require.neqNull(date, "date"); - if(date.isBefore(firstValidDate)){ + if (date.isBefore(firstValidDate)) { throw new InvalidDateException("Date is before the first valid business calendar date: date=" + date + " firstValidDate=" + firstValidDate); - } else if(date.isAfter(lastValidDate)){ + } else if (date.isAfter(lastValidDate)) { throw new InvalidDateException("Date is after the last valid business calendar date: date=" + date + " lastValidDate=" + lastValidDate); } @@ -199,7 +201,7 @@ public BusinessSchedule businessSchedule(final LocalDate date) { * * @param time time * @return the corresponding BusinessSchedule of {@code date} - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public BusinessSchedule businessSchedule(final ZonedDateTime time) { @@ -212,7 +214,7 @@ public BusinessSchedule businessSchedule(final ZonedDateTime time) { * * @param time time * @return the corresponding BusinessSchedule of {@code date} - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public BusinessSchedule businessSchedule(final Instant time) { @@ -225,8 +227,8 @@ public BusinessSchedule businessSchedule(final Instant time) { * * @param date date * @return the corresponding BusinessSchedule of {@code date} - * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public BusinessSchedule businessSchedule(final String date) { @@ -235,6 +237,7 @@ public BusinessSchedule businessSchedule(final String date) { } //TODO: rename current schedule? --> or zero arg? + /** * Gets today's business schedule. * @@ -253,7 +256,7 @@ public BusinessSchedule currentBusinessSchedule() { * * @param date date * @return true if the date is a business day; false otherwise - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public boolean isBusinessDay(final LocalDate date) { @@ -265,8 +268,8 @@ public boolean isBusinessDay(final LocalDate date) { * * @param date date * @return true if the date is a business day; false otherwise - * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public boolean isBusinessDay(final String date) { @@ -278,10 +281,10 @@ public boolean isBusinessDay(final String date) { * * @param time time * @return true if the date is a business day; false otherwise - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public boolean isBusinessDay(final ZonedDateTime time){ + public boolean isBusinessDay(final ZonedDateTime time) { return businessSchedule(time).isBusinessDay(); } @@ -290,14 +293,15 @@ public boolean isBusinessDay(final ZonedDateTime time){ * * @param time time * @return true if the date is a business day; false otherwise - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public boolean isBusinessDay(final Instant time){ + public boolean isBusinessDay(final Instant time) { return businessSchedule(time).isBusinessDay(); } //TODO: rename? + /** * Is the day of the week a normal business day? * @@ -305,7 +309,7 @@ public boolean isBusinessDay(final Instant time){ * @return true if the day is a business day; false otherwise * @throws RequirementFailure if the input is null */ - public boolean isBusinessDay(final DayOfWeek day){ + public boolean isBusinessDay(final DayOfWeek day) { Require.neqNull(day, "day"); return !weekendDays.contains(day); } @@ -324,7 +328,7 @@ public boolean isBusinessDay() { * * @param date date * @return true if {@code date} is the last business day of the month; false otherwise - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ boolean isLastBusinessDayOfMonth(final LocalDate date) { @@ -336,7 +340,7 @@ boolean isLastBusinessDayOfMonth(final LocalDate date) { final LocalDate nextBusAfterDate = plusBusinessDays(date, 1); - if(nextBusAfterDate == null){ + if (nextBusAfterDate == null) { //TODO ** raise an error; return false; } @@ -349,7 +353,7 @@ boolean isLastBusinessDayOfMonth(final LocalDate date) { * * @param time time * @return true if {@code time} is on the last business day of the month; false otherwise - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public boolean isLastBusinessDayOfMonth(final ZonedDateTime time) { @@ -362,7 +366,7 @@ public boolean isLastBusinessDayOfMonth(final ZonedDateTime time) { * * @param time time * @return true if {@code time} is on the last business day of the month; false otherwise - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public boolean isLastBusinessDayOfMonth(final Instant time) { @@ -375,8 +379,8 @@ public boolean isLastBusinessDayOfMonth(final Instant time) { * * @param date date * @return true if {@code time} is on the last business day of the month; false otherwise - * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ boolean isLastBusinessDayOfMonth(final String date) { @@ -398,10 +402,10 @@ public boolean isLastBusinessDayOfMonth() { * * @param date date * @return true if {@code date} is on the last business day of the week; false otherwise - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public boolean isLastBusinessDayOfWeek(final LocalDate date){ + public boolean isLastBusinessDayOfWeek(final LocalDate date) { Require.neqNull(date, "date"); if (!isBusinessDay(date)) { @@ -417,7 +421,7 @@ public boolean isLastBusinessDayOfWeek(final LocalDate date){ * * @param time time * @return true if {@code time} is on the last business day of the week; false otherwise - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public boolean isLastBusinessDayOfWeek(final ZonedDateTime time) { @@ -430,7 +434,7 @@ public boolean isLastBusinessDayOfWeek(final ZonedDateTime time) { * * @param time time * @return true if {@code time} is on the last business day of the week; false otherwise - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public boolean isLastBusinessDayOfWeek(final Instant time) { @@ -443,11 +447,11 @@ public boolean isLastBusinessDayOfWeek(final Instant time) { * * @param date date * @return true if {@code date} is the last business day of the week; false otherwise - * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public boolean isLastBusinessDayOfWeek(final String date){ + public boolean isLastBusinessDayOfWeek(final String date) { Require.neqNull(date, "date"); return isLastBusinessDayOfWeek(DateTimeUtils.parseLocalDate(date)); } @@ -466,7 +470,7 @@ public boolean isLastBusinessDayOfWeek() { * * @param date date * @return true if {@code date} is the last business day of the year; false otherwise - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ boolean isLastBusinessDayOfYear(final LocalDate date) { @@ -478,7 +482,7 @@ boolean isLastBusinessDayOfYear(final LocalDate date) { final LocalDate nextBusAfterDate = plusBusinessDays(date, 1); - if(nextBusAfterDate == null){ + if (nextBusAfterDate == null) { //TODO ** raise an error; return false; } @@ -491,7 +495,7 @@ boolean isLastBusinessDayOfYear(final LocalDate date) { * * @param time time * @return true if {@code time} is on the last business day of the year; false otherwise - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public boolean isLastBusinessDayOfYear(final ZonedDateTime time) { @@ -504,7 +508,7 @@ public boolean isLastBusinessDayOfYear(final ZonedDateTime time) { * * @param time time * @return true if {@code time} is on the last business day of the year; false otherwise - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public boolean isLastBusinessDayOfYear(final Instant time) { @@ -517,8 +521,8 @@ public boolean isLastBusinessDayOfYear(final Instant time) { * * @param date date * @return true if {@code time} is on the last business day of the year; false otherwise - * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ boolean isLastBusinessDayOfYear(final String date) { @@ -545,7 +549,7 @@ public boolean isLastBusinessDayOfYear() { * * @param time time * @return true if the specified time is a business time; otherwise, false - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public boolean isBusinessTime(final ZonedDateTime time) { @@ -559,7 +563,7 @@ public boolean isBusinessTime(final ZonedDateTime time) { * * @param time time * @return true if the specified time is a business time; otherwise, false - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public boolean isBusinessTime(final Instant time) { @@ -572,7 +576,7 @@ public boolean isBusinessTime(final Instant time) { * Business times fall within business periods of the day's business schedule. * * @return true if the specified time is a business time; otherwise, false - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public boolean isBusinessTime() { @@ -587,10 +591,10 @@ public boolean isBusinessTime() { * * @param date date * @return ratio of the business day length and the standard business day length for the date - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfStandardBusinessDay(final LocalDate date){ + public double fractionOfStandardBusinessDay(final LocalDate date) { Require.neqNull(date, "date"); final BusinessSchedule schedule = businessSchedule(date); return (double) schedule.businessNanos() / (double) standardBusinessDayLengthNanos(); @@ -604,11 +608,11 @@ public double fractionOfStandardBusinessDay(final LocalDate date){ * * @param date date * @return ratio of the business day length and the standard business day length for the date - * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public double fractionOfStandardBusinessDay(final String date){ + public double fractionOfStandardBusinessDay(final String date) { Require.neqNull(date, "date"); return fractionOfStandardBusinessDay(DateTimeUtils.parseLocalDate(date)); } @@ -621,10 +625,10 @@ public double fractionOfStandardBusinessDay(final String date){ * * @param time time * @return ratio of the business day length and the standard business day length for the date - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfStandardBusinessDay(final Instant time){ + public double fractionOfStandardBusinessDay(final Instant time) { Require.neqNull(time, "time"); return fractionOfStandardBusinessDay(DateTimeUtils.toLocalDate(time, timeZone())); } @@ -637,10 +641,10 @@ public double fractionOfStandardBusinessDay(final Instant time){ * * @param time time * @return ratio of the business day length and the standard business day length for the date - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfStandardBusinessDay(final ZonedDateTime time){ + public double fractionOfStandardBusinessDay(final ZonedDateTime time) { Require.neqNull(time, "time"); return fractionOfStandardBusinessDay(DateTimeUtils.toLocalDate(time.toInstant(), timeZone())); } @@ -652,7 +656,7 @@ public double fractionOfStandardBusinessDay(final ZonedDateTime time){ * A half day holiday will return 0.5. * * @return ratio of the business day length and the standard business day length for the date - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public double fractionOfStandardBusinessDay() { @@ -660,12 +664,13 @@ public double fractionOfStandardBusinessDay() { } //TODO: remove Of from function names! + /** * Fraction of the business day complete. * * @param time time * @return the fraction of the business day complete, or 1.0 if the day is not a business day - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public double fractionOfBusinessDayComplete(final Instant time) { @@ -673,7 +678,7 @@ public double fractionOfBusinessDayComplete(final Instant time) { final BusinessSchedule schedule = businessSchedule(time); - if(!schedule.isBusinessDay()) { + if (!schedule.isBusinessDay()) { return 1.0; } @@ -686,7 +691,7 @@ public double fractionOfBusinessDayComplete(final Instant time) { * * @param time time * @return the fraction of the business day complete, or 1.0 if the day is not a business day - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public double fractionOfBusinessDayComplete(final ZonedDateTime time) { @@ -698,7 +703,7 @@ public double fractionOfBusinessDayComplete(final ZonedDateTime time) { * Fraction of the current business day complete. * * @return the fraction of the business day complete, or 1.0 if the day is not a business day - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public double fractionOfBusinessDayComplete() { @@ -710,10 +715,10 @@ public double fractionOfBusinessDayComplete() { * * @param time time * @return the fraction of the business day complete, or 0.0 if the day is not a business day - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfBusinessDayRemaining(final Instant time){ + public double fractionOfBusinessDayRemaining(final Instant time) { Require.neqNull(time, "time"); return 1.0 - fractionOfBusinessDayComplete(time); } @@ -723,10 +728,10 @@ public double fractionOfBusinessDayRemaining(final Instant time){ * * @param time time * @return the fraction of the business day complete, or 0.0 if the day is not a business day - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfBusinessDayRemaining(final ZonedDateTime time){ + public double fractionOfBusinessDayRemaining(final ZonedDateTime time) { Require.neqNull(time, "time"); return 1.0 - fractionOfBusinessDayComplete(time); } @@ -735,10 +740,10 @@ public double fractionOfBusinessDayRemaining(final ZonedDateTime time){ * Fraction of the business day remaining. * * @return the fraction of the business day complete, or 0.0 if the day is not a business day - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfBusinessDayRemaining(){ + public double fractionOfBusinessDayRemaining() { return fractionOfBusinessDayRemaining(DateTimeUtils.now()); } @@ -749,15 +754,15 @@ public double fractionOfBusinessDayRemaining(){ /** * Returns the number of business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return number of business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ - public int numberBusinessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { + public int numberBusinessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { Require.neqNull(start, "start"); Require.neqNull(end, "end"); @@ -766,7 +771,7 @@ public int numberBusinessDates(final LocalDate start, final LocalDate end, final for (LocalDate day = start; !day.isAfter(end); day = day.plusDays(1)) { final boolean skip = (!startInclusive && day.equals(start)) || (!endInclusive && day.equals(end)); - if(!skip && isBusinessDay(day)) { + if (!skip && isBusinessDay(day)) { days++; } } @@ -777,16 +782,16 @@ public int numberBusinessDates(final LocalDate start, final LocalDate end, final /** * Returns the number of business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return number of business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null - * @throws InvalidDateException if the dates are not in the valid range + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public int numberBusinessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { + public int numberBusinessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { Require.neqNull(start, "start"); Require.neqNull(end, "end"); return numberBusinessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive, endInclusive); @@ -795,15 +800,15 @@ public int numberBusinessDates(final String start, final String end, final boole /** * Returns the number of business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return number of business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ - public int numberBusinessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { + public int numberBusinessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { Require.neqNull(start, "start"); Require.neqNull(end, "end"); return numberBusinessDates(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate(), startInclusive, endInclusive); @@ -812,15 +817,15 @@ public int numberBusinessDates(final ZonedDateTime start, final ZonedDateTime en /** * Returns the number of business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return number of business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ - public int numberBusinessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { + public int numberBusinessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { Require.neqNull(start, "start"); Require.neqNull(end, "end"); return numberBusinessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), startInclusive, endInclusive); @@ -832,11 +837,11 @@ public int numberBusinessDates(final Instant start, final Instant end, final boo * @param start start of a time range * @param end end of a time range * @return number of business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public int numberBusinessDates(final LocalDate start, final LocalDate end) { - return numberBusinessDates(start,end, true, true); + return numberBusinessDates(start, end, true, true); } /** @@ -845,12 +850,12 @@ public int numberBusinessDates(final LocalDate start, final LocalDate end) { * @param start start of a time range * @param end end of a time range * @return number of business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null - * @throws InvalidDateException if the dates are not in the valid range + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public int numberBusinessDates(final String start, final String end) { - return numberBusinessDates(start,end, true, true); + return numberBusinessDates(start, end, true, true); } /** @@ -859,11 +864,11 @@ public int numberBusinessDates(final String start, final String end) { * @param start start of a time range * @param end end of a time range * @return number of business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public int numberBusinessDates(final ZonedDateTime start, final ZonedDateTime end) { - return numberBusinessDates(start,end, true, true); + return numberBusinessDates(start, end, true, true); } /** @@ -872,25 +877,25 @@ public int numberBusinessDates(final ZonedDateTime start, final ZonedDateTime en * @param start start of a time range * @param end end of a time range * @return number of business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public int numberBusinessDates(final Instant start, final Instant end) { - return numberBusinessDates(start,end, true, true); + return numberBusinessDates(start, end, true, true); } /** * Returns the number of non-business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return number of non-business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ - public int numberNonBusinessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { + public int numberNonBusinessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { Require.neqNull(start, "start"); Require.neqNull(end, "end"); @@ -900,16 +905,16 @@ public int numberNonBusinessDates(final LocalDate start, final LocalDate end, fi /** * Returns the number of non-business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return number of non-business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null - * @throws InvalidDateException if the dates are not in the valid range + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public int numberNonBusinessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { + public int numberNonBusinessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { Require.neqNull(start, "start"); Require.neqNull(end, "end"); return numberNonBusinessDates(DateTimeUtils.parseLocalDate(start), DateTimeUtils.parseLocalDate(end), startInclusive, endInclusive); @@ -918,15 +923,15 @@ public int numberNonBusinessDates(final String start, final String end, final bo /** * Returns the number of non-business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return number of non-business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ - public int numberNonBusinessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { + public int numberNonBusinessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { Require.neqNull(start, "start"); Require.neqNull(end, "end"); return numberNonBusinessDates(start.withZoneSameInstant(timeZone()).toLocalDate(), end.withZoneSameInstant(timeZone()).toLocalDate(), startInclusive, endInclusive); @@ -935,15 +940,15 @@ public int numberNonBusinessDates(final ZonedDateTime start, final ZonedDateTime /** * Returns the number of non-business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return number of non-business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ - public int numberNonBusinessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { + public int numberNonBusinessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { Require.neqNull(start, "start"); Require.neqNull(end, "end"); return numberNonBusinessDates(DateTimeUtils.toLocalDate(start, timeZone()), DateTimeUtils.toLocalDate(end, timeZone()), startInclusive, endInclusive); @@ -955,11 +960,11 @@ public int numberNonBusinessDates(final Instant start, final Instant end, final * @param start start of a time range * @param end end of a time range * @return number of non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public int numberNonBusinessDates(final LocalDate start, final LocalDate end) { - return numberNonBusinessDates(start,end, true, true); + return numberNonBusinessDates(start, end, true, true); } /** @@ -968,12 +973,12 @@ public int numberNonBusinessDates(final LocalDate start, final LocalDate end) { * @param start start of a time range * @param end end of a time range * @return number of non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null - * @throws InvalidDateException if the dates are not in the valid range + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public int numberNonBusinessDates(final String start, final String end) { - return numberNonBusinessDates(start,end, true, true); + return numberNonBusinessDates(start, end, true, true); } /** @@ -982,11 +987,11 @@ public int numberNonBusinessDates(final String start, final String end) { * @param start start of a time range * @param end end of a time range * @return number of non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public int numberNonBusinessDates(final ZonedDateTime start, final ZonedDateTime end) { - return numberNonBusinessDates(start,end, true, true); + return numberNonBusinessDates(start, end, true, true); } /** @@ -995,22 +1000,22 @@ public int numberNonBusinessDates(final ZonedDateTime start, final ZonedDateTime * @param start start of a time range * @param end end of a time range * @return number of non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public int numberNonBusinessDates(final Instant start, final Instant end) { - return numberNonBusinessDates(start,end, true, true); + return numberNonBusinessDates(start, end, true, true); } /** * Returns the business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public LocalDate[] businessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { @@ -1022,7 +1027,7 @@ public LocalDate[] businessDates(final LocalDate start, final LocalDate end, fin for (LocalDate day = start; !day.isAfter(end); day = day.plusDays(1)) { final boolean skip = (!startInclusive && day.equals(start)) || (!endInclusive && day.equals(end)); - if(!skip && isBusinessDay(day)) { + if (!skip && isBusinessDay(day)) { dateList.add(day); } } @@ -1033,13 +1038,13 @@ public LocalDate[] businessDates(final LocalDate start, final LocalDate end, fin /** * Returns the business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null - * @throws InvalidDateException if the dates are not in the valid range + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate[] businessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { @@ -1051,12 +1056,12 @@ public LocalDate[] businessDates(final String start, final String end, final boo /** * Returns the business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public LocalDate[] businessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { @@ -1068,12 +1073,12 @@ public LocalDate[] businessDates(final ZonedDateTime start, final ZonedDateTime /** * Returns the business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public LocalDate[] businessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { @@ -1088,11 +1093,11 @@ public LocalDate[] businessDates(final Instant start, final Instant end, final b * @param start start of a time range * @param end end of a time range * @return business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public LocalDate[] businessDates(final LocalDate start, final LocalDate end) { - return businessDates(start,end, true, true); + return businessDates(start, end, true, true); } /** @@ -1101,12 +1106,12 @@ public LocalDate[] businessDates(final LocalDate start, final LocalDate end) { * @param start start of a time range * @param end end of a time range * @return business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null - * @throws InvalidDateException if the dates are not in the valid range + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate[] businessDates(final String start, final String end) { - return businessDates(start,end, true, true); + return businessDates(start, end, true, true); } /** @@ -1115,11 +1120,11 @@ public LocalDate[] businessDates(final String start, final String end) { * @param start start of a time range * @param end end of a time range * @return business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public LocalDate[] businessDates(final ZonedDateTime start, final ZonedDateTime end) { - return businessDates(start,end, true, true); + return businessDates(start, end, true, true); } /** @@ -1128,22 +1133,22 @@ public LocalDate[] businessDates(final ZonedDateTime start, final ZonedDateTime * @param start start of a time range * @param end end of a time range * @return business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public LocalDate[] businessDates(final Instant start, final Instant end) { - return businessDates(start,end, true, true); + return businessDates(start, end, true, true); } /** * Returns the non-business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return non-business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { @@ -1155,7 +1160,7 @@ public LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end, for (LocalDate day = start; !day.isAfter(end); day = day.plusDays(1)) { final boolean skip = (!startInclusive && day.equals(start)) || (!endInclusive && day.equals(end)); - if(!skip && !isBusinessDay(day)) { + if (!skip && !isBusinessDay(day)) { dateList.add(day); } } @@ -1166,13 +1171,13 @@ public LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end, /** * Returns the non-business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return non-business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null - * @throws InvalidDateException if the dates are not in the valid range + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate[] nonBusinessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { @@ -1184,12 +1189,12 @@ public LocalDate[] nonBusinessDates(final String start, final String end, final /** * Returns the non-business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return non-business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public LocalDate[] nonBusinessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { @@ -1201,12 +1206,12 @@ public LocalDate[] nonBusinessDates(final ZonedDateTime start, final ZonedDateTi /** * Returns the non-business dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return non-business dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public LocalDate[] nonBusinessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { @@ -1221,11 +1226,11 @@ public LocalDate[] nonBusinessDates(final Instant start, final Instant end, fina * @param start start of a time range * @param end end of a time range * @return non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end) { - return nonBusinessDates(start,end, true, true); + return nonBusinessDates(start, end, true, true); } /** @@ -1234,12 +1239,12 @@ public LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end) * @param start start of a time range * @param end end of a time range * @return non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null - * @throws InvalidDateException if the dates are not in the valid range + * @throws RequirementFailure if any input is null + * @throws InvalidDateException if the dates are not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate[] nonBusinessDates(final String start, final String end) { - return nonBusinessDates(start,end, true, true); + return nonBusinessDates(start, end, true, true); } /** @@ -1248,11 +1253,11 @@ public LocalDate[] nonBusinessDates(final String start, final String end) { * @param start start of a time range * @param end end of a time range * @return non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public LocalDate[] nonBusinessDates(final ZonedDateTime start, final ZonedDateTime end) { - return nonBusinessDates(start,end, true, true); + return nonBusinessDates(start, end, true, true); } /** @@ -1261,11 +1266,11 @@ public LocalDate[] nonBusinessDates(final ZonedDateTime start, final ZonedDateTi * @param start start of a time range * @param end end of a time range * @return non-business dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public LocalDate[] nonBusinessDates(final Instant start, final Instant end) { - return nonBusinessDates(start,end, true, true); + return nonBusinessDates(start, end, true, true); } // endregion @@ -1278,7 +1283,7 @@ public LocalDate[] nonBusinessDates(final Instant start, final Instant end) { * @param start start of a time range * @param end end of a time range * @return the amount of business time in nanoseconds between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public long diffBusinessNanos(final Instant start, final Instant end) { @@ -1295,7 +1300,7 @@ public long diffBusinessNanos(final Instant start, final Instant end) { assert startDate != null; assert endDate != null; - if(startDate.equals(endDate)) { + if (startDate.equals(endDate)) { final BusinessSchedule schedule = businessSchedule(startDate); return schedule.businessNanosElapsed(end) - schedule.businessNanosElapsed(start); } @@ -1315,7 +1320,7 @@ public long diffBusinessNanos(final Instant start, final Instant end) { * @param start start of a time range * @param end end of a time range * @return the amount of business time in nanoseconds between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public long diffBusinessNanos(final ZonedDateTime start, final ZonedDateTime end) { @@ -1330,7 +1335,7 @@ public long diffBusinessNanos(final ZonedDateTime start, final ZonedDateTime end * @param start start of a time range * @param end end of a time range * @return the amount of nonbusiness time in nanoseconds between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public long diffNonBusinessNanos(final Instant start, final Instant end) { @@ -1345,7 +1350,7 @@ public long diffNonBusinessNanos(final Instant start, final Instant end) { * @param start start of a time range * @param end end of a time range * @return the amount of non-business time in nanoseconds between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public long diffNonBusinessNanos(final ZonedDateTime start, final ZonedDateTime end) { @@ -1360,7 +1365,7 @@ public long diffNonBusinessNanos(final ZonedDateTime start, final ZonedDateTime * @param start start of a time range * @param end end of a time range * @return the amount of business time in standard business days between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public double diffBusinessDays(final Instant start, final Instant end) { @@ -1373,7 +1378,7 @@ public double diffBusinessDays(final Instant start, final Instant end) { * @param start start of a time range * @param end end of a time range * @return the amount of business time in standard business days between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public double diffBusinessDays(final ZonedDateTime start, final ZonedDateTime end) { @@ -1384,9 +1389,9 @@ public double diffBusinessDays(final ZonedDateTime start, final ZonedDateTime en * Returns the number of business years between {@code start} and {@code end}. * * @param start start; if null, return null - * @param end end; if null, return null + * @param end end; if null, return null * @return the amount of business time in business years between the {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public double diffBusinessYears(final Instant start, final Instant end) { @@ -1396,7 +1401,7 @@ public double diffBusinessYears(final Instant start, final Instant end) { final int yearStart = DateTimeUtils.year(start, timeZone()); final int yearEnd = DateTimeUtils.year(end, timeZone()); - if(yearStart == yearEnd){ + if (yearStart == yearEnd) { return (double) diffBusinessNanos(start, end) / (double) getYearData(yearStart).businessTimeNanos; } @@ -1405,16 +1410,16 @@ public double diffBusinessYears(final Instant start, final Instant end) { return (double) diffBusinessNanos(start, yearDataStart.end.toInstant()) / (double) yearDataStart.businessTimeNanos + (double) diffBusinessNanos(yearDataEnd.start.toInstant(), end) / (double) yearDataEnd.businessTimeNanos + - yearEnd-yearStart-1; + yearEnd - yearStart - 1; } /** * Returns the number of business years between {@code start} and {@code end}. * * @param start start; if null, return null - * @param end end; if null, return null + * @param end end; if null, return null * @return the amount of business time in business years between the {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws InvalidDateException if the dates are not in the valid range */ public double diffBusinessYears(final ZonedDateTime start, final ZonedDateTime end) { @@ -1435,13 +1440,13 @@ public double diffBusinessYears(final ZonedDateTime start, final ZonedDateTime e * @param date date * @param days number of days to add. * @return {@code days} business days after {@code date}; null if {@code date} is not a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public LocalDate plusBusinessDays(final LocalDate date, final int days) { Require.neqNull(date, "date"); - if(days == 0){ + if (days == 0) { return isBusinessDay() ? date : null; } @@ -1463,8 +1468,8 @@ public LocalDate plusBusinessDays(final LocalDate date, final int days) { * @param date date * @param days number of days to add. * @return {@code days} business days after {@code date}; null if {@code date} is not a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate plusBusinessDays(final String date, final int days) { @@ -1478,9 +1483,9 @@ public LocalDate plusBusinessDays(final String date, final int days) { * @param time time * @param days number of days to add. * @return {@code days} business days after {@code time}; null if {@code time} is not a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range - */ + */ public LocalDate plusBusinessDays(final Instant time, final int days) { Require.neqNull(time, "time"); return plusBusinessDays(DateTimeUtils.toLocalDate(time, timeZone()), days); @@ -1492,7 +1497,7 @@ public LocalDate plusBusinessDays(final Instant time, final int days) { * @param time time * @param days number of days to add. * @return {@code days} business days after {@code time}; null if {@code time} is not a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public LocalDate plusBusinessDays(final ZonedDateTime time, final int days) { @@ -1506,7 +1511,7 @@ public LocalDate plusBusinessDays(final ZonedDateTime time, final int days) { * @param date date * @param days number of days to add. * @return {@code days} business days before {@code date}; null if {@code date} is not a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public LocalDate minusBusinessDays(final LocalDate date, final int days) { @@ -1519,8 +1524,8 @@ public LocalDate minusBusinessDays(final LocalDate date, final int days) { * @param date date * @param days number of days to add. * @return {@code days} business days before {@code date}; null if {@code date} is not a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate minusBusinessDays(final String date, final int days) { @@ -1533,7 +1538,7 @@ public LocalDate minusBusinessDays(final String date, final int days) { * @param time time * @param days number of days to add. * @return {@code days} business days before {@code time}; null if {@code time} is not a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public LocalDate minusBusinessDays(final Instant time, final int days) { @@ -1546,7 +1551,7 @@ public LocalDate minusBusinessDays(final Instant time, final int days) { * @param time time * @param days number of days to add. * @return {@code days} business days before {@code time}; null if {@code time} is not a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public LocalDate minusBusinessDays(final ZonedDateTime time, final int days) { @@ -1559,13 +1564,13 @@ public LocalDate minusBusinessDays(final ZonedDateTime time, final int days) { * @param date date * @param days number of days to add. * @return {@code days} non-business days after {@code date}; null if {@code date} is not a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public LocalDate plusNonBusinessDays(final LocalDate date, final int days) { Require.neqNull(date, "date"); - if(days == 0){ + if (days == 0) { return isBusinessDay() ? null : date; } @@ -1587,8 +1592,8 @@ public LocalDate plusNonBusinessDays(final LocalDate date, final int days) { * @param date date * @param days number of days to add. * @return {@code days} non-business days after {@code date}; null if {@code date} is not a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate plusNonBusinessDays(final String date, final int days) { @@ -1596,15 +1601,15 @@ public LocalDate plusNonBusinessDays(final String date, final int days) { return this.plusNonBusinessDays(DateTimeUtils.parseLocalDate(date), days); } - /** - * Adds a specified number of non-business days to an input date. Adding negative days is equivalent to subtracting days. - * - * @param time time - * @param days number of days to add. - * @return {@code days} non-business days after {@code time}; null if {@code time} is not a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range - */ + /** + * Adds a specified number of non-business days to an input date. Adding negative days is equivalent to subtracting days. + * + * @param time time + * @param days number of days to add. + * @return {@code days} non-business days after {@code time}; null if {@code time} is not a business day and {@code days} is zero. + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range + */ public LocalDate plusNonBusinessDays(final Instant time, final int days) { Require.neqNull(time, "time"); return this.plusNonBusinessDays(DateTimeUtils.toLocalDate(time, timeZone()), days); @@ -1616,7 +1621,7 @@ public LocalDate plusNonBusinessDays(final Instant time, final int days) { * @param time time * @param days number of days to add. * @return {@code days} non-business days after {@code time}; null if {@code time} is not a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public LocalDate plusNonBusinessDays(final ZonedDateTime time, final int days) { @@ -1630,7 +1635,7 @@ public LocalDate plusNonBusinessDays(final ZonedDateTime time, final int days) { * @param date date * @param days number of days to add. * @return {@code days} non-business days before {@code date}; null if {@code date} is a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public LocalDate minusNonBusinessDays(final LocalDate date, final int days) { @@ -1643,8 +1648,8 @@ public LocalDate minusNonBusinessDays(final LocalDate date, final int days) { * @param date date * @param days number of days to add. * @return {@code days} non-business days before {@code date}; null if {@code date} is a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null - * @throws InvalidDateException if the date is not in the valid range + * @throws RequirementFailure if the input is null + * @throws InvalidDateException if the date is not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate minusNonBusinessDays(final String date, final int days) { @@ -1657,7 +1662,7 @@ public LocalDate minusNonBusinessDays(final String date, final int days) { * @param time time * @param days number of days to add. * @return {@code days} non-business days before {@code time}; null if {@code time} is a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public LocalDate minusNonBusinessDays(final Instant time, final int days) { @@ -1670,7 +1675,7 @@ public LocalDate minusNonBusinessDays(final Instant time, final int days) { * @param time time * @param days number of days to add. * @return {@code days} non-business days before {@code time}; null if {@code time} is a business day and {@code days} is zero. - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ public LocalDate minusNonBusinessDays(final ZonedDateTime time, final int days) { diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java index 9fa9a66d69e..1e0c3b2c58e 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java @@ -17,14 +17,14 @@ /** * A calendar. - * + *

* A calendar is associated with a specific time zone. - * + *

* Date strings must be in a format that can be parsed by {@code DateTimeUtils#parseDate}. Methods that accept * strings can be slower than methods written explicitly for {@code Instant}, {@code ZonedDateTime}, or {@code LocalDate}. */ public class Calendar { - + private final String name; private final String description; private final ZoneId timeZone; @@ -33,10 +33,10 @@ public class Calendar { /** * Creates a new calendar. - * - * @param name calendar name. + * + * @param name calendar name. * @param description calendar description. - * @param timeZone calendar time zone. + * @param timeZone calendar time zone. */ public Calendar(final String name, final String description, final ZoneId timeZone) { this.name = name; @@ -65,7 +65,7 @@ public String name() { public String description() { return description; } - + /** * Gets the timezone of the calendar. * @@ -107,7 +107,7 @@ public LocalDate plusDays(final LocalDate date, final int days) { * @param date date * @param days number of days to add * @return {@code days} days after {@code date} - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate plusDays(final String date, final int days) { @@ -160,7 +160,7 @@ public LocalDate minusDays(final LocalDate date, final int days) { * @param date date * @param days number of days to subtract * @return {@code days} days after {@code date} - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate minusDays(final String date, final int days) { @@ -230,10 +230,10 @@ public LocalDate pastDate(final int days) { /** * Returns the dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return dates between {@code start} and {@code end} * @throws RequirementFailure if any input is null */ @@ -246,7 +246,7 @@ public LocalDate[] calendarDates(final LocalDate start, final LocalDate end, fin for (LocalDate day = start; !day.isAfter(end); day = day.plusDays(1)) { final boolean skip = (!startInclusive && day.equals(start)) || (!endInclusive && day.equals(end)); - if(!skip) { + if (!skip) { dateList.add(day); } } @@ -257,12 +257,12 @@ public LocalDate[] calendarDates(final LocalDate start, final LocalDate end, fin /** * Returns the dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate[] calendarDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { @@ -274,12 +274,12 @@ public LocalDate[] calendarDates(final String start, final String end, final boo /** * Returns the dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate[] calendarDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { @@ -291,12 +291,12 @@ public LocalDate[] calendarDates(final ZonedDateTime start, final ZonedDateTime /** * Returns the dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate[] calendarDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { @@ -314,7 +314,7 @@ public LocalDate[] calendarDates(final Instant start, final Instant end, final b * @throws RequirementFailure if any input is null */ public LocalDate[] calendarDates(final LocalDate start, final LocalDate end) { - return calendarDates(start,end, true, true); + return calendarDates(start, end, true, true); } /** @@ -323,11 +323,11 @@ public LocalDate[] calendarDates(final LocalDate start, final LocalDate end) { * @param start start of a time range * @param end end of a time range * @return dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public LocalDate[] calendarDates(final String start, final String end) { - return calendarDates(start,end, true, true); + return calendarDates(start, end, true, true); } /** @@ -339,7 +339,7 @@ public LocalDate[] calendarDates(final String start, final String end) { * @throws RequirementFailure if any input is null */ public LocalDate[] calendarDates(final ZonedDateTime start, final ZonedDateTime end) { - return calendarDates(start,end, true, true); + return calendarDates(start, end, true, true); } /** @@ -351,16 +351,16 @@ public LocalDate[] calendarDates(final ZonedDateTime start, final ZonedDateTime * @throws RequirementFailure if any input is null */ public LocalDate[] calendarDates(final Instant start, final Instant end) { - return calendarDates(start,end, true, true); + return calendarDates(start, end, true, true); } /** * Returns the number of dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return number of dates between {@code start} and {@code end} * @throws RequirementFailure if any input is null */ @@ -370,26 +370,26 @@ public int numberCalendarDates(final LocalDate start, final LocalDate end, final int days = (int) ChronoUnit.DAYS.between(start, end.plusDays(1)); - if(!startInclusive){ - days -= 1; - } + if (!startInclusive) { + days -= 1; + } - if(!endInclusive){ - days -= 1; - } + if (!endInclusive) { + days -= 1; + } - return Math.max(days, 0); + return Math.max(days, 0); } /** * Returns the number of dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return number of dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public int numberCalendarDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { @@ -401,12 +401,12 @@ public int numberCalendarDates(final String start, final String end, final boole /** * Returns the number of dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return number of dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public int numberCalendarDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { @@ -418,12 +418,12 @@ public int numberCalendarDates(final ZonedDateTime start, final ZonedDateTime en /** * Returns the number of dates in a given range. * - * @param start start of a time range - * @param end end of a time range + * @param start start of a time range + * @param end end of a time range * @param startInclusive true to include {@code start} in the result; false to exclude {@code start} - * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} + * @param endInclusive true to include {@code end} in the result; false to exclude {@code end} * @return number of dates between {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public int numberCalendarDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { @@ -441,7 +441,7 @@ public int numberCalendarDates(final Instant start, final Instant end, final boo * @throws RequirementFailure if any input is null */ public int numberCalendarDates(final LocalDate start, final LocalDate end) { - return numberCalendarDates(start,end, true, true); + return numberCalendarDates(start, end, true, true); } /** @@ -450,11 +450,11 @@ public int numberCalendarDates(final LocalDate start, final LocalDate end) { * @param start start of a time range * @param end end of a time range * @return number of dates between {@code start} and {@code end}; including {@code start} and {@code end} - * @throws RequirementFailure if any input is null + * @throws RequirementFailure if any input is null * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ public int numberCalendarDates(final String start, final String end) { - return numberCalendarDates(start,end, true, true); + return numberCalendarDates(start, end, true, true); } /** @@ -466,7 +466,7 @@ public int numberCalendarDates(final String start, final String end) { * @throws RequirementFailure if any input is null */ public int numberCalendarDates(final ZonedDateTime start, final ZonedDateTime end) { - return numberCalendarDates(start,end, true, true); + return numberCalendarDates(start, end, true, true); } /** @@ -478,7 +478,7 @@ public int numberCalendarDates(final ZonedDateTime start, final ZonedDateTime en * @throws RequirementFailure if any input is null */ public int numberCalendarDates(final Instant start, final Instant end) { - return numberCalendarDates(start,end, true, true); + return numberCalendarDates(start, end, true, true); } // endregion From 860f615b1f0ef35bdba0ccd7a47564ec7e83a05d Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 11 Jul 2023 13:04:34 -0600 Subject: [PATCH 030/150] Todo and docs and formatting cleanup: * Calendar * BusinessCalendar --- .../time/calendar/BusinessCalendar.java | 80 ++++++++----------- 1 file changed, 32 insertions(+), 48 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index f0e86429d8e..a3a228b906a 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -78,11 +78,11 @@ private void populateSchedules() { } private static class YearData { - private final ZonedDateTime start; //TODO: type? - private final ZonedDateTime end; //TODO: type? + private final Instant start; + private final Instant end; private final long businessTimeNanos; - public YearData(final ZonedDateTime start, final ZonedDateTime end, final long businessTimeNanos) { + public YearData(final Instant start, final Instant end, final long businessTimeNanos) { this.start = start; this.end = end; this.businessTimeNanos = businessTimeNanos; @@ -110,7 +110,7 @@ private void populateCachedYearData() { date = date.plusDays(1); } - final YearData yd = new YearData(start, end, businessTimeNanos); + final YearData yd = new YearData(start.toInstant(), end.toInstant(), businessTimeNanos); cachedYearData.put(year, yd); } } @@ -155,14 +155,12 @@ public BusinessSchedule standardBusinessSchedule() { return standardBusinessSchedule; } - //TODO: rename? - /** * Length of a standard business day in nanoseconds. * * @return length of a standard business day in nanoseconds */ - public long standardBusinessDayLengthNanos() { + public long standardBusinessDayNanos() { return standardBusinessSchedule.businessNanos(); } @@ -300,8 +298,6 @@ public boolean isBusinessDay(final Instant time) { return businessSchedule(time).isBusinessDay(); } - //TODO: rename? - /** * Is the day of the week a normal business day? * @@ -339,12 +335,7 @@ boolean isLastBusinessDayOfMonth(final LocalDate date) { } final LocalDate nextBusAfterDate = plusBusinessDays(date, 1); - - if (nextBusAfterDate == null) { - //TODO ** raise an error; - return false; - } - + assert nextBusAfterDate != null; return date.getMonth() != nextBusAfterDate.getMonth(); } @@ -481,12 +472,7 @@ boolean isLastBusinessDayOfYear(final LocalDate date) { } final LocalDate nextBusAfterDate = plusBusinessDays(date, 1); - - if (nextBusAfterDate == null) { - //TODO ** raise an error; - return false; - } - + assert nextBusAfterDate != null; return date.getYear() != nextBusAfterDate.getYear(); } @@ -594,10 +580,10 @@ public boolean isBusinessTime() { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfStandardBusinessDay(final LocalDate date) { + public double fractionStandardBusinessDay(final LocalDate date) { Require.neqNull(date, "date"); final BusinessSchedule schedule = businessSchedule(date); - return (double) schedule.businessNanos() / (double) standardBusinessDayLengthNanos(); + return (double) schedule.businessNanos() / (double) standardBusinessDayNanos(); } /** @@ -612,9 +598,9 @@ public double fractionOfStandardBusinessDay(final LocalDate date) { * @throws InvalidDateException if the date is not in the valid range * @throws DateTimeUtils.DateTimeParseException if the string cannot be parsed */ - public double fractionOfStandardBusinessDay(final String date) { + public double fractionStandardBusinessDay(final String date) { Require.neqNull(date, "date"); - return fractionOfStandardBusinessDay(DateTimeUtils.parseLocalDate(date)); + return fractionStandardBusinessDay(DateTimeUtils.parseLocalDate(date)); } /** @@ -628,9 +614,9 @@ public double fractionOfStandardBusinessDay(final String date) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfStandardBusinessDay(final Instant time) { + public double fractionStandardBusinessDay(final Instant time) { Require.neqNull(time, "time"); - return fractionOfStandardBusinessDay(DateTimeUtils.toLocalDate(time, timeZone())); + return fractionStandardBusinessDay(DateTimeUtils.toLocalDate(time, timeZone())); } /** @@ -644,9 +630,9 @@ public double fractionOfStandardBusinessDay(final Instant time) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfStandardBusinessDay(final ZonedDateTime time) { + public double fractionStandardBusinessDay(final ZonedDateTime time) { Require.neqNull(time, "time"); - return fractionOfStandardBusinessDay(DateTimeUtils.toLocalDate(time.toInstant(), timeZone())); + return fractionStandardBusinessDay(DateTimeUtils.toLocalDate(time.toInstant(), timeZone())); } /** @@ -659,12 +645,10 @@ public double fractionOfStandardBusinessDay(final ZonedDateTime time) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfStandardBusinessDay() { - return fractionOfStandardBusinessDay(currentDate()); + public double fractionStandardBusinessDay() { + return fractionStandardBusinessDay(currentDate()); } - //TODO: remove Of from function names! - /** * Fraction of the business day complete. * @@ -673,7 +657,7 @@ public double fractionOfStandardBusinessDay() { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfBusinessDayComplete(final Instant time) { + public double fractionBusinessDayComplete(final Instant time) { Require.neqNull(time, "time"); final BusinessSchedule schedule = businessSchedule(time); @@ -694,9 +678,9 @@ public double fractionOfBusinessDayComplete(final Instant time) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfBusinessDayComplete(final ZonedDateTime time) { + public double fractionBusinessDayComplete(final ZonedDateTime time) { Require.neqNull(time, "time"); - return fractionOfBusinessDayComplete(time.toInstant()); + return fractionBusinessDayComplete(time.toInstant()); } /** @@ -706,8 +690,8 @@ public double fractionOfBusinessDayComplete(final ZonedDateTime time) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfBusinessDayComplete() { - return fractionOfBusinessDayComplete(DateTimeUtils.now()); + public double fractionBusinessDayComplete() { + return fractionBusinessDayComplete(DateTimeUtils.now()); } /** @@ -718,9 +702,9 @@ public double fractionOfBusinessDayComplete() { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfBusinessDayRemaining(final Instant time) { + public double fractionBusinessDayRemaining(final Instant time) { Require.neqNull(time, "time"); - return 1.0 - fractionOfBusinessDayComplete(time); + return 1.0 - fractionBusinessDayComplete(time); } /** @@ -731,9 +715,9 @@ public double fractionOfBusinessDayRemaining(final Instant time) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfBusinessDayRemaining(final ZonedDateTime time) { + public double fractionBusinessDayRemaining(final ZonedDateTime time) { Require.neqNull(time, "time"); - return 1.0 - fractionOfBusinessDayComplete(time); + return 1.0 - fractionBusinessDayComplete(time); } /** @@ -743,8 +727,8 @@ public double fractionOfBusinessDayRemaining(final ZonedDateTime time) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public double fractionOfBusinessDayRemaining() { - return fractionOfBusinessDayRemaining(DateTimeUtils.now()); + public double fractionBusinessDayRemaining() { + return fractionBusinessDayRemaining(DateTimeUtils.now()); } // endregion @@ -1369,7 +1353,7 @@ public long diffNonBusinessNanos(final ZonedDateTime start, final ZonedDateTime * @throws InvalidDateException if the dates are not in the valid range */ public double diffBusinessDays(final Instant start, final Instant end) { - return (double) diffBusinessNanos(start, end) / (double) standardBusinessDayLengthNanos(); + return (double) diffBusinessNanos(start, end) / (double) standardBusinessDayNanos(); } /** @@ -1382,7 +1366,7 @@ public double diffBusinessDays(final Instant start, final Instant end) { * @throws InvalidDateException if the dates are not in the valid range */ public double diffBusinessDays(final ZonedDateTime start, final ZonedDateTime end) { - return (double) diffBusinessNanos(start, end) / (double) standardBusinessDayLengthNanos(); + return (double) diffBusinessNanos(start, end) / (double) standardBusinessDayNanos(); } /** @@ -1408,8 +1392,8 @@ public double diffBusinessYears(final Instant start, final Instant end) { final YearData yearDataStart = getYearData(yearStart); final YearData yearDataEnd = getYearData(yearEnd); - return (double) diffBusinessNanos(start, yearDataStart.end.toInstant()) / (double) yearDataStart.businessTimeNanos + - (double) diffBusinessNanos(yearDataEnd.start.toInstant(), end) / (double) yearDataEnd.businessTimeNanos + + return (double) diffBusinessNanos(start, yearDataStart.end) / (double) yearDataStart.businessTimeNanos + + (double) diffBusinessNanos(yearDataEnd.start, end) / (double) yearDataEnd.businessTimeNanos + yearEnd - yearStart - 1; } From cbf64614b7b3992225db1b8bff81469993d7ef01 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 11 Jul 2023 13:10:05 -0600 Subject: [PATCH 031/150] Todo and docs and formatting cleanup: * Calendar * BusinessCalendar --- .../time/calendar/BusinessCalendar.java | 18 +++++++----------- .../io/deephaven/time/calendar/Calendar.java | 2 ++ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index a3a228b906a..4e46f45b203 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -16,7 +16,6 @@ * Date strings must be in a format that can be parsed by {@code DateTimeUtils#parseDate}. Methods that accept * strings can be slower than methods written explicitly for {@code Instant}, {@code ZonedDateTime}, or {@code LocalDate}. */ -@SuppressWarnings("unused") //TODO: remove unused annotation public class BusinessCalendar extends Calendar { private final LocalDate firstValidDate; @@ -144,8 +143,6 @@ public BusinessCalendar(final String name, final String description, final ZoneI // region Business Schedule - //TODO: rename? - /** * Business schedule for a standard business day. * @@ -160,7 +157,7 @@ public BusinessSchedule standardBusinessSchedule() { * * @return length of a standard business day in nanoseconds */ - public long standardBusinessDayNanos() { + public long standardBusinessNanos() { return standardBusinessSchedule.businessNanos(); } @@ -234,14 +231,13 @@ public BusinessSchedule businessSchedule(final String date) { return businessSchedule(DateTimeUtils.parseLocalDate(date)); } - //TODO: rename current schedule? --> or zero arg? - /** - * Gets today's business schedule. + * Returns the business schedule for today. * * @return today's business schedule + * @throws InvalidDateException if the date is not in the valid range */ - public BusinessSchedule currentBusinessSchedule() { + public BusinessSchedule businessSchedule() { return businessSchedule(currentDate()); } @@ -583,7 +579,7 @@ public boolean isBusinessTime() { public double fractionStandardBusinessDay(final LocalDate date) { Require.neqNull(date, "date"); final BusinessSchedule schedule = businessSchedule(date); - return (double) schedule.businessNanos() / (double) standardBusinessDayNanos(); + return (double) schedule.businessNanos() / (double) standardBusinessNanos(); } /** @@ -1353,7 +1349,7 @@ public long diffNonBusinessNanos(final ZonedDateTime start, final ZonedDateTime * @throws InvalidDateException if the dates are not in the valid range */ public double diffBusinessDays(final Instant start, final Instant end) { - return (double) diffBusinessNanos(start, end) / (double) standardBusinessDayNanos(); + return (double) diffBusinessNanos(start, end) / (double) standardBusinessNanos(); } /** @@ -1366,7 +1362,7 @@ public double diffBusinessDays(final Instant start, final Instant end) { * @throws InvalidDateException if the dates are not in the valid range */ public double diffBusinessDays(final ZonedDateTime start, final ZonedDateTime end) { - return (double) diffBusinessNanos(start, end) / (double) standardBusinessDayNanos(); + return (double) diffBusinessNanos(start, end) / (double) standardBusinessNanos(); } /** diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java index 1e0c3b2c58e..8803a15cf7b 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java @@ -88,6 +88,8 @@ public String toString() { // region Arithmetic + //TODO: should the add/subtract methods on Instants or ZDT return times of LocalDates? + /** * Adds a specified number of days to an input date. Adding negative days is equivalent to subtracting days. * From 124de3eebe07f7b7c0184fe81556b92bb8cb1e67 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 11 Jul 2023 13:14:00 -0600 Subject: [PATCH 032/150] Todo and docs and formatting cleanup: * BusinessPeriod * Calendars --- .../time/calendar/BusinessPeriod.java | 6 +++-- .../io/deephaven/time/calendar/Calendars.java | 23 ++++--------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java index 637e9229702..ec8af0caa58 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java @@ -4,9 +4,11 @@ package io.deephaven.time.calendar; import io.deephaven.time.DateTimeUtils; -import org.jetbrains.annotations.NotNull; -import java.time.*; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneId; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java index cf398940be0..ced106d8e3f 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java @@ -3,20 +3,15 @@ */ package io.deephaven.time.calendar; +import io.deephaven.api.util.NameValidator; import io.deephaven.base.verify.Require; import io.deephaven.base.verify.RequirementFailure; import io.deephaven.configuration.Configuration; -import io.deephaven.io.logger.Logger; -import io.deephaven.api.util.NameValidator; import io.deephaven.internal.log.LoggerFactory; +import io.deephaven.io.logger.Logger; import org.jetbrains.annotations.NotNull; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import java.io.*; import java.nio.file.NoSuchFileException; import java.util.Collection; import java.util.HashMap; @@ -50,7 +45,7 @@ static Calendars getInstance() { * @param name name of the calendar * @return business calendar * @throws IllegalArgumentException no calendar matching {@code name} - * @throws RequirementFailure if the input is null + * @throws RequirementFailure if the input is null */ public static BusinessCalendar calendar(final String name) { Require.neqNull(name, "name"); @@ -73,15 +68,6 @@ public static BusinessCalendar calendar() { return calendar(defaultName); } - /** - * Returns the default business calendar name - * - * @return default business calendar name - */ - public static String defaultCalendarName() { - return defaultName; - } - /** * Returns the names of all available calendars * @@ -92,7 +78,6 @@ public static String[] calendarNames() { } - private final Map calendars = new HashMap<>(); From 55e1dec692026d25c91e5262da434e79e53505ce Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 11 Jul 2023 14:34:50 -0600 Subject: [PATCH 033/150] Unit test: * BusinessPeriod --- .../time/calendar/BusinessPeriod.java | 14 +++++++ .../time/calendar/TestBusinessPeriod.java | 37 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java index ec8af0caa58..3081ec81035 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java @@ -11,6 +11,7 @@ import java.time.ZoneId; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; +import java.util.Objects; /** * A period of business time during a business day. @@ -82,6 +83,19 @@ public boolean contains(final T time) { && time.compareTo(end) <= 0; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof BusinessPeriod)) return false; + BusinessPeriod that = (BusinessPeriod) o; + return nanos == that.nanos && start.equals(that.start) && end.equals(that.end); + } + + @Override + public int hashCode() { + return Objects.hash(start, end, nanos); + } + /** * Converts a business period in local time to a specific date and time zone. * diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessPeriod.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessPeriod.java index 1f54de9046e..9a1be5aa9dc 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessPeriod.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessPeriod.java @@ -8,6 +8,12 @@ import junit.framework.TestCase; import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneId; +import java.util.Objects; + +import static org.junit.Assert.assertNotEquals; public class TestBusinessPeriod extends BaseArrayTestCase { @@ -52,4 +58,35 @@ public void testBusinessPeriod() { assertFalse(period .contains(DateTimeUtils.epochNanosToInstant(DateTimeUtils.epochNanos(close1) + DateTimeUtils.MINUTE))); } + + public void testToInstant() { + final LocalTime start = LocalTime.of(1,2,3); + final LocalTime end = LocalTime.of(7,8,9); + + final BusinessPeriod local = new BusinessPeriod<>(start, end); + + final LocalDate date = LocalDate.of(2017,3,11); + final ZoneId timeZone = ZoneId.of("America/Los_Angeles"); + final Instant targetStart = date.atTime(start).atZone(timeZone).toInstant(); + final Instant targetEnd = date.atTime(end).atZone(timeZone).toInstant(); + + final BusinessPeriod target = new BusinessPeriod<>(targetStart, targetEnd); + final BusinessPeriod rst = BusinessPeriod.toInstant(local, date, timeZone); + assertEquals(target, rst); + } + + public void testEqualsHash() { + final LocalTime start = LocalTime.of(1,2,3); + final LocalTime end = LocalTime.of(7,8,9); + final BusinessPeriod p1 = new BusinessPeriod<>(start, end); + final BusinessPeriod p2 = new BusinessPeriod<>(start, end); + final BusinessPeriod p3 = new BusinessPeriod<>(LocalTime.of(0,1), end); + final BusinessPeriod p4 = new BusinessPeriod<>(start, LocalTime.of(8,9)); + + assertEquals(p1.hashCode(), Objects.hash(start, end, p1.nanos())); + assertEquals(p1,p1); + assertEquals(p1,p2); + assertNotEquals(p1, p3); + assertNotEquals(p1, p4); + } } From 6b9d0b247e38ba6b2074dafcc65f714e5eee41eb Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 11 Jul 2023 14:56:57 -0600 Subject: [PATCH 034/150] Unit test: * BusinessSchedule --- .../time/calendar/BusinessSchedule.java | 16 ++++ .../time/calendar/TestBusinessSchedule.java | 73 ++++++++++++++++--- 2 files changed, 77 insertions(+), 12 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java index 4defd94dc1a..ac0bc60d8bf 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java @@ -15,6 +15,7 @@ import java.time.temporal.Temporal; import java.util.Arrays; import java.util.Comparator; +import java.util.Objects; /** * Schedule for a single business day. @@ -178,6 +179,21 @@ public boolean isBusinessTime(final T time) { return false; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof BusinessSchedule)) return false; + BusinessSchedule that = (BusinessSchedule) o; + return businessNanos == that.businessNanos && Arrays.equals(openPeriods, that.openPeriods) && Objects.equals(businessStart, that.businessStart) && Objects.equals(businessEnd, that.businessEnd); + } + + @Override + public int hashCode() { + int result = Objects.hash(businessStart, businessEnd, businessNanos); + result = 31 * result + Arrays.hashCode(openPeriods); + return result; + } + /** * Converts a business schedule in local time to a specific date and time zone. * diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessSchedule.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessSchedule.java index 9b67633b2f3..8a1e3189502 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessSchedule.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessSchedule.java @@ -7,18 +7,23 @@ import io.deephaven.time.DateTimeUtils; import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.ZoneId; +import java.util.Arrays; +import java.util.Objects; -public class TestBusinessSchedule extends BaseArrayTestCase { +import static org.junit.Assert.assertNotEquals; - public void testBusinessSchedule() { - final Instant open1 = DateTimeUtils.parseInstant("2017-03-11T10:00:00.000000000 NY"); - final Instant close1 = DateTimeUtils.parseInstant("2017-03-11T11:00:00.000000000 NY"); - final BusinessPeriod period1 = new BusinessPeriod<>(open1, close1); - final Instant open2 = DateTimeUtils.parseInstant("2017-03-11T12:00:00.000000000 NY"); - final Instant close2 = DateTimeUtils.parseInstant("2017-03-11T17:00:00.000000000 NY"); - final BusinessPeriod period2 = new BusinessPeriod<>(open2, close2); +public class TestBusinessSchedule extends BaseArrayTestCase { + final Instant open1 = DateTimeUtils.parseInstant("2017-03-11T10:00:00.000000000 NY"); + final Instant close1 = DateTimeUtils.parseInstant("2017-03-11T11:00:00.000000000 NY"); + final BusinessPeriod period1 = new BusinessPeriod<>(open1, close1); + final Instant open2 = DateTimeUtils.parseInstant("2017-03-11T12:00:00.000000000 NY"); + final Instant close2 = DateTimeUtils.parseInstant("2017-03-11T17:00:00.000000000 NY"); + final BusinessPeriod period2 = new BusinessPeriod<>(open2, close2); - // empty + public void testEmpty() { final BusinessSchedule empty = new BusinessSchedule<>(); assertEquals(new BusinessPeriod[0], empty.periods()); assertNull(empty.businessStart()); @@ -34,8 +39,9 @@ public void testBusinessSchedule() { assertEquals(0L, empty.businessNanosElapsed(close1)); assertEquals(0L, empty.businessNanosRemaining(open1)); assertEquals(0L, empty.businessNanosRemaining(close1)); + } - // single period + public void testSinglePeriod() { //noinspection unchecked,rawtypes final BusinessSchedule single = new BusinessSchedule<>(new BusinessPeriod[]{period1}); assertEquals(new BusinessPeriod[] {period1}, single.periods()); @@ -59,8 +65,9 @@ public void testBusinessSchedule() { single.businessNanosRemaining(DateTimeUtils.parseInstant("2017-03-11T10:30:00.000000000 NY"))); assertEquals(0L, single.businessNanosRemaining(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); + } - // multi period + public void testMultiPeriod() { //noinspection unchecked,rawtypes final BusinessSchedule multi = new BusinessSchedule<>(new BusinessPeriod[]{period1, period2}); assertEquals(new BusinessPeriod[] {period1, period2}, multi.periods()); @@ -83,7 +90,7 @@ public void testBusinessSchedule() { multi.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); assertEquals(DateTimeUtils.HOUR * 2, multi.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); - assertEquals(DateTimeUtils.HOUR*2, multi.businessNanosRemaining(DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"))); + assertEquals(DateTimeUtils.HOUR*6, multi.businessNanosRemaining(DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"))); assertEquals(DateTimeUtils.HOUR*5+DateTimeUtils.MINUTE * 30, multi.businessNanosRemaining(DateTimeUtils.parseInstant("2017-03-11T10:30:00.000000000 NY"))); assertEquals(DateTimeUtils.HOUR * 4, @@ -112,6 +119,48 @@ public void testBusinessSchedule() { multi2.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); assertEquals(DateTimeUtils.HOUR * 2, multi2.businessNanosElapsed(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); + } + + public void testPeriodsOverlap() { + try { + //noinspection unchecked,rawtypes + new BusinessSchedule<>(new BusinessPeriod[]{period1, period1}); + fail("Should have thrown an exception"); + }catch (IllegalArgumentException e) { + assertTrue(e.getMessage().contains("overlap")); + } + } + + public void testToInstant() { + final BusinessPeriod p1 = new BusinessPeriod<>(LocalTime.of(1,2), LocalTime.of(3,4)); + final BusinessPeriod p2 = new BusinessPeriod<>(LocalTime.of(5,6), LocalTime.of(7,8)); + + //noinspection unchecked,rawtypes + final BusinessSchedule local = new BusinessSchedule<>(new BusinessPeriod[]{p1,p2}); + final LocalDate date = LocalDate.of(2017,3,11); + final ZoneId timeZone = ZoneId.of("America/Los_Angeles"); + //noinspection unchecked,rawtypes + final BusinessSchedule target = new BusinessSchedule<>(new BusinessPeriod[]{BusinessPeriod.toInstant(p1, date, timeZone), BusinessPeriod.toInstant(p2,date,timeZone)}); + final BusinessSchedule actual = BusinessSchedule.toInstant(local, date, timeZone); + assertEquals(target, actual); + } + + public void testEqualsHash() { + //noinspection unchecked,rawtypes + final BusinessSchedule multi = new BusinessSchedule<>(new BusinessPeriod[]{period1, period2}); + assertEquals(new BusinessPeriod[] {period1, period2}, multi.periods()); + + int hashTarget = 31 * Objects.hash(multi.businessStart(), multi.businessEnd(), multi.businessNanos()) + Arrays.hashCode(multi.periods()); + assertEquals(hashTarget, multi.hashCode()); + + //noinspection unchecked,rawtypes + final BusinessSchedule multi2 = new BusinessSchedule<>(new BusinessPeriod[]{period1, period2}); + //noinspection unchecked,rawtypes + final BusinessSchedule multi3 = new BusinessSchedule<>(new BusinessPeriod[]{period1, new BusinessPeriod<>(open2, DateTimeUtils.parseInstant("2017-03-11T17:01:00.000000000 NY"))}); + assertEquals(multi, multi); + assertEquals(multi, multi2); + assertNotEquals(multi, multi3); + assertNotEquals(multi2, multi3); } } From 1c4664791d1be7cbbd921c8c404f08d715c392d6 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 11 Jul 2023 15:29:22 -0600 Subject: [PATCH 035/150] Unit test: * Calendar --- .../deephaven/time/calendar/TestCalendar.java | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java new file mode 100644 index 00000000000..e4b41c3f768 --- /dev/null +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java @@ -0,0 +1,140 @@ +package io.deephaven.time.calendar; + +import io.deephaven.base.testing.BaseArrayTestCase; +import io.deephaven.time.DateTimeUtils; + +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +public class TestCalendar extends BaseArrayTestCase { + private final String name = "TEST CALENDAR"; + private final String description = "This is a test"; + private final ZoneId timeZone = ZoneId.of("America/Los_Angeles"); + private final Calendar calendar = new Calendar(name, description, timeZone); + + public void testGetters(){ + assertEquals(name, calendar.name()); + assertEquals(description, calendar.description()); + assertEquals(timeZone, calendar.timeZone()); + } + + public void testToString() { + assertEquals("Calendar{name='TEST CALENDAR', description='This is a test', timeZone=America/Los_Angeles}", calendar.toString()); + } + + public void testPlusDays() { + final LocalDate d = LocalDate.of(2023,2,3); + final String s = "2023-02-03"; + final ZonedDateTime z = d.atTime(1,24).atZone(timeZone); + final Instant i = z.toInstant(); + + assertEquals(d, calendar.plusDays(d,0)); + assertEquals(d, calendar.plusDays(s,0)); + assertEquals(d, calendar.plusDays(z,0)); + assertEquals(d, calendar.plusDays(i,0)); + + final LocalDate d2 = LocalDate.of(2023,2,5); + assertEquals(d2, calendar.plusDays(d,2)); + assertEquals(d2, calendar.plusDays(s,2)); + assertEquals(d2, calendar.plusDays(z,2)); + assertEquals(d2, calendar.plusDays(i,2)); + + final LocalDate d3 = LocalDate.of(2023,2,1); + assertEquals(d3, calendar.plusDays(d,-2)); + assertEquals(d3, calendar.plusDays(s,-2)); + assertEquals(d3, calendar.plusDays(z,-2)); + assertEquals(d3, calendar.plusDays(i,-2)); + } + + public void testMinusDays() { + final LocalDate d = LocalDate.of(2023,2,3); + final String s = "2023-02-03"; + final ZonedDateTime z = d.atTime(1,24).atZone(timeZone); + final Instant i = z.toInstant(); + + assertEquals(d, calendar.minusDays(d,0)); + assertEquals(d, calendar.minusDays(s,0)); + assertEquals(d, calendar.minusDays(z,0)); + assertEquals(d, calendar.minusDays(i,0)); + + final LocalDate d2 = LocalDate.of(2023,2,1); + assertEquals(d2, calendar.minusDays(d,2)); + assertEquals(d2, calendar.minusDays(s,2)); + assertEquals(d2, calendar.minusDays(z,2)); + assertEquals(d2, calendar.minusDays(i,2)); + + final LocalDate d3 = LocalDate.of(2023,2,5); + assertEquals(d3, calendar.minusDays(d,-2)); + assertEquals(d3, calendar.minusDays(s,-2)); + assertEquals(d3, calendar.minusDays(z,-2)); + assertEquals(d3, calendar.minusDays(i,-2)); + } + + public void testCurrentDate() { + assertEquals(DateTimeUtils.todayDate(), calendar.currentDate()); + } + + public void testFutureDate() { + assertEquals(calendar.plusDays(DateTimeUtils.todayDate(),3), calendar.futureDate(3)); + assertEquals(calendar.plusDays(DateTimeUtils.todayDate(),-3), calendar.futureDate(-3)); + } + + public void testPastDate() { + assertEquals(calendar.minusDays(DateTimeUtils.todayDate(),3), calendar.pastDate(3)); + assertEquals(calendar.minusDays(DateTimeUtils.todayDate(),-3), calendar.pastDate(-3)); + } + + public void testCalendarDates() { + final LocalDate start = LocalDate.of(2023,2,3); + final LocalDate middle = LocalDate.of(2023,2,4); + final LocalDate end = LocalDate.of(2023,2,5); + + assertEquals(new LocalDate[]{start, middle, end},calendar.calendarDates(start, end)); + assertEquals(new LocalDate[]{start, middle, end},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(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant())); + + assertEquals(new LocalDate[]{start, middle},calendar.calendarDates(start, end, true, false)); + assertEquals(new LocalDate[]{start, middle},calendar.calendarDates(start.toString(), end.toString(), true, false)); + assertEquals(new LocalDate[]{start, middle},calendar.calendarDates(start.atTime(1,24).atZone(timeZone), end.atTime(1,24).atZone(timeZone), true, false)); + assertEquals(new LocalDate[]{start, middle},calendar.calendarDates(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant(), true, false)); + + assertEquals(new LocalDate[]{middle, end},calendar.calendarDates(start, end, false, true)); + assertEquals(new LocalDate[]{middle, end},calendar.calendarDates(start.toString(), end.toString(), false, true)); + assertEquals(new LocalDate[]{middle, end},calendar.calendarDates(start.atTime(1,24).atZone(timeZone), end.atTime(1,24).atZone(timeZone), false, true)); + assertEquals(new LocalDate[]{middle, end},calendar.calendarDates(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant(), false, true)); + + assertEquals(new LocalDate[]{middle},calendar.calendarDates(start, end, false, false)); + assertEquals(new LocalDate[]{middle},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(), end.atTime(1,24).atZone(timeZone).toInstant(), false, false)); + } + + public void testNumberCalendarDates() { + final LocalDate start = LocalDate.of(2023,2,3); + final LocalDate middle = LocalDate.of(2023,2,4); + final LocalDate end = LocalDate.of(2023,2,5); + + assertEquals(3,calendar.numberCalendarDates(start, end)); + assertEquals(3,calendar.numberCalendarDates(start.toString(), end.toString())); + assertEquals(3,calendar.numberCalendarDates(start.atTime(1,24).atZone(timeZone), end.atTime(1,24).atZone(timeZone))); + assertEquals(3,calendar.numberCalendarDates(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant())); + + assertEquals(2,calendar.numberCalendarDates(start, end, true, false)); + assertEquals(2,calendar.numberCalendarDates(start.toString(), end.toString(), true, false)); + assertEquals(2,calendar.numberCalendarDates(start.atTime(1,24).atZone(timeZone), end.atTime(1,24).atZone(timeZone), true, false)); + assertEquals(2,calendar.numberCalendarDates(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant(), true, false)); + + assertEquals(2,calendar.numberCalendarDates(start, end, false, true)); + assertEquals(2,calendar.numberCalendarDates(start.toString(), end.toString(), false, true)); + assertEquals(2,calendar.numberCalendarDates(start.atTime(1,24).atZone(timeZone), end.atTime(1,24).atZone(timeZone), false, true)); + assertEquals(2,calendar.numberCalendarDates(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant(), false, true)); + + assertEquals(1,calendar.numberCalendarDates(start, end, false, false)); + assertEquals(1,calendar.numberCalendarDates(start.toString(), end.toString(), false, false)); + assertEquals(1,calendar.numberCalendarDates(start.atTime(1,24).atZone(timeZone), end.atTime(1,24).atZone(timeZone), false, false)); + assertEquals(1,calendar.numberCalendarDates(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant(), false, false)); + } +} From 14ee3579f86d80deb3cfdd34ff3c6e613febe8ec Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Wed, 12 Jul 2023 10:15:22 -0600 Subject: [PATCH 036/150] Unit test: * BusinessPeriod * BusinessSchedule --- .../time/calendar/BusinessPeriod.java | 8 ++++++ .../time/calendar/BusinessSchedule.java | 7 +++++ .../time/calendar/TestBusinessPeriod.java | 7 +++++ .../time/calendar/TestBusinessSchedule.java | 27 +++++++++---------- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java index 3081ec81035..74cea6ac4b1 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java @@ -96,6 +96,14 @@ public int hashCode() { return Objects.hash(start, end, nanos); } + @Override + public String toString() { + return "BusinessPeriod{" + + "start=" + start + + ", end=" + end + + '}'; + } + /** * Converts a business period in local time to a specific date and time zone. * diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java index ac0bc60d8bf..7a31c28946d 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java @@ -194,6 +194,13 @@ public int hashCode() { return result; } + @Override + public String toString() { + return "BusinessSchedule{" + + "openPeriods=" + Arrays.toString(openPeriods) + + '}'; + } + /** * Converts a business schedule in local time to a specific date and time zone. * diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessPeriod.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessPeriod.java index 9a1be5aa9dc..234fbb3cf07 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessPeriod.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessPeriod.java @@ -89,4 +89,11 @@ public void testEqualsHash() { assertNotEquals(p1, p3); assertNotEquals(p1, p4); } + + public void testToString() { + final LocalTime start = LocalTime.of(1,2,3); + final LocalTime end = LocalTime.of(7,8,9); + final BusinessPeriod p1 = new BusinessPeriod<>(start, end); + assertEquals("BusinessPeriod{start=01:02:03, end=07:08:09}", p1.toString()); + } } diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessSchedule.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessSchedule.java index 8a1e3189502..005020083f1 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessSchedule.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessSchedule.java @@ -15,13 +15,14 @@ import static org.junit.Assert.assertNotEquals; +@SuppressWarnings({"unchecked", "rawtypes"}) public class TestBusinessSchedule extends BaseArrayTestCase { - final Instant open1 = DateTimeUtils.parseInstant("2017-03-11T10:00:00.000000000 NY"); - final Instant close1 = DateTimeUtils.parseInstant("2017-03-11T11:00:00.000000000 NY"); - final BusinessPeriod period1 = new BusinessPeriod<>(open1, close1); - final Instant open2 = DateTimeUtils.parseInstant("2017-03-11T12:00:00.000000000 NY"); - final Instant close2 = DateTimeUtils.parseInstant("2017-03-11T17:00:00.000000000 NY"); - final BusinessPeriod period2 = new BusinessPeriod<>(open2, close2); + private final Instant open1 = DateTimeUtils.parseInstant("2017-03-11T10:00:00.000000000 NY"); + private final Instant close1 = DateTimeUtils.parseInstant("2017-03-11T11:00:00.000000000 NY"); + private final BusinessPeriod period1 = new BusinessPeriod<>(open1, close1); + private final Instant open2 = DateTimeUtils.parseInstant("2017-03-11T12:00:00.000000000 NY"); + private final Instant close2 = DateTimeUtils.parseInstant("2017-03-11T17:00:00.000000000 NY"); + private final BusinessPeriod period2 = new BusinessPeriod<>(open2, close2); public void testEmpty() { final BusinessSchedule empty = new BusinessSchedule<>(); @@ -42,7 +43,6 @@ public void testEmpty() { } public void testSinglePeriod() { - //noinspection unchecked,rawtypes final BusinessSchedule single = new BusinessSchedule<>(new BusinessPeriod[]{period1}); assertEquals(new BusinessPeriod[] {period1}, single.periods()); assertEquals(open1, single.businessStart()); @@ -68,7 +68,6 @@ public void testSinglePeriod() { } public void testMultiPeriod() { - //noinspection unchecked,rawtypes final BusinessSchedule multi = new BusinessSchedule<>(new BusinessPeriod[]{period1, period2}); assertEquals(new BusinessPeriod[] {period1, period2}, multi.periods()); assertEquals(open1, multi.businessStart()); @@ -97,7 +96,6 @@ public void testMultiPeriod() { multi.businessNanosRemaining(DateTimeUtils.parseInstant("2017-03-11T13:00:00.000000000 NY"))); - //noinspection unchecked,rawtypes final BusinessSchedule multi2 = new BusinessSchedule<>(new BusinessPeriod[]{period2, period1}); assertEquals(new BusinessPeriod[] {period1, period2}, multi2.periods()); assertEquals(open1, multi2.businessStart()); @@ -123,7 +121,6 @@ public void testMultiPeriod() { public void testPeriodsOverlap() { try { - //noinspection unchecked,rawtypes new BusinessSchedule<>(new BusinessPeriod[]{period1, period1}); fail("Should have thrown an exception"); }catch (IllegalArgumentException e) { @@ -135,32 +132,32 @@ public void testToInstant() { final BusinessPeriod p1 = new BusinessPeriod<>(LocalTime.of(1,2), LocalTime.of(3,4)); final BusinessPeriod p2 = new BusinessPeriod<>(LocalTime.of(5,6), LocalTime.of(7,8)); - //noinspection unchecked,rawtypes final BusinessSchedule local = new BusinessSchedule<>(new BusinessPeriod[]{p1,p2}); final LocalDate date = LocalDate.of(2017,3,11); final ZoneId timeZone = ZoneId.of("America/Los_Angeles"); - //noinspection unchecked,rawtypes final BusinessSchedule target = new BusinessSchedule<>(new BusinessPeriod[]{BusinessPeriod.toInstant(p1, date, timeZone), BusinessPeriod.toInstant(p2,date,timeZone)}); final BusinessSchedule actual = BusinessSchedule.toInstant(local, date, timeZone); assertEquals(target, actual); } public void testEqualsHash() { - //noinspection unchecked,rawtypes final BusinessSchedule multi = new BusinessSchedule<>(new BusinessPeriod[]{period1, period2}); assertEquals(new BusinessPeriod[] {period1, period2}, multi.periods()); int hashTarget = 31 * Objects.hash(multi.businessStart(), multi.businessEnd(), multi.businessNanos()) + Arrays.hashCode(multi.periods()); assertEquals(hashTarget, multi.hashCode()); - //noinspection unchecked,rawtypes final BusinessSchedule multi2 = new BusinessSchedule<>(new BusinessPeriod[]{period1, period2}); - //noinspection unchecked,rawtypes final BusinessSchedule multi3 = new BusinessSchedule<>(new BusinessPeriod[]{period1, new BusinessPeriod<>(open2, DateTimeUtils.parseInstant("2017-03-11T17:01:00.000000000 NY"))}); assertEquals(multi, multi); assertEquals(multi, multi2); assertNotEquals(multi, multi3); assertNotEquals(multi2, multi3); } + + public void testToString() { + final BusinessSchedule multi = new BusinessSchedule<>(new BusinessPeriod[]{period1, period2}); + assertEquals("BusinessSchedule{openPeriods=[BusinessPeriod{start=2017-03-11T15:00:00Z, end=2017-03-11T16:00:00Z}, BusinessPeriod{start=2017-03-11T17:00:00Z, end=2017-03-11T22:00:00Z}]}", multi.toString()); + } } From 4cc5066f79c3d8701b6ba8b54e25e3190a0ab67c Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Wed, 12 Jul 2023 10:28:09 -0600 Subject: [PATCH 037/150] Unit test: * BusinessCalendar - Schedule --- .../time/calendar/BusinessCalendar.java | 4 +- .../time/calendar/TestBusinessCalendar.java | 1755 +++++++++++++++++ 2 files changed, 1757 insertions(+), 2 deletions(-) create mode 100644 engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index 4e46f45b203..9bc39059b92 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -95,8 +95,8 @@ private void populateCachedYearData() { final int yearEnd = ((lastValidDate.isLeapYear() && lastValidDate.getDayOfYear() == 366) || lastValidDate.getDayOfYear() == 365) ? lastValidDate.getYear() : lastValidDate.getYear() - 1; for (int year = yearStart; year <= yearEnd; year++) { - final LocalDate startDate = LocalDate.ofYearDay(year, 0); - final LocalDate endDate = LocalDate.ofYearDay(year + 1, 0); + final LocalDate startDate = LocalDate.ofYearDay(year, 1); + final LocalDate endDate = LocalDate.ofYearDay(year + 1, 1); final ZonedDateTime start = startDate.atTime(0, 0).atZone(timeZone()); final ZonedDateTime end = endDate.atTime(0, 0).atZone(timeZone()); diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java new file mode 100644 index 00000000000..5f9265d8cb4 --- /dev/null +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java @@ -0,0 +1,1755 @@ +/** + * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending + */ +package io.deephaven.time.calendar; + +import io.deephaven.base.verify.RequirementFailure; + +import java.time.*; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +@SuppressWarnings({"ConstantConditions", "unchecked", "rawtypes"}) +public class TestBusinessCalendar extends TestCalendar { +// private final String name = "TEST CALENDAR"; +// private final String description = "This is a test"; +// private final ZoneId timeZone = ZoneId.of("America/Los_Angeles"); + private final LocalDate firstValidDate = LocalDate.of(2000,1,1); + private final LocalDate lastValidDate = LocalDate.of(2050,12,31); + private final BusinessPeriod period = new BusinessPeriod<>(LocalTime.of(9, 0), LocalTime.of(12, 15)); + private final BusinessPeriod periodHalf = new BusinessPeriod<>(LocalTime.of(9, 0), LocalTime.of(11, 7)); + private final BusinessSchedule schedule = new BusinessSchedule<>(new BusinessPeriod[]{period}); + private final Set weekendDays = Set.of(DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY); + private final LocalDate holidayDate1 = LocalDate.of(2023,7,4); + private final LocalDate holidayDate2 = LocalDate.of(2023,12,25); + private final BusinessSchedule holiday = new BusinessSchedule<>(); + private final LocalDate halfDayDate = LocalDate.of(2023,7,6); + private final BusinessSchedule halfDay = new BusinessSchedule<>(new BusinessPeriod[]{BusinessPeriod.toInstant(periodHalf, halfDayDate,timeZone)}); + + private Map> holidays; + private BusinessCalendar bCalendar; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + holidays = new HashMap<>(); + holidays.put(holidayDate1, holiday); + holidays.put(holidayDate2, holiday); + holidays.put(halfDayDate, halfDay); + + bCalendar = new BusinessCalendar(name, description, timeZone, firstValidDate, lastValidDate, schedule, weekendDays, holidays); + calendar = bCalendar; + } + + public void testBusinessGetters() { + assertEquals(schedule, bCalendar.standardBusinessSchedule()); + assertEquals(schedule.businessNanos(), bCalendar.standardBusinessNanos()); + assertEquals(holidays, bCalendar.holidays()); + //TODO: implement +// assertEquals(firstValidDate, bCalendar.firstValidDate()); +// assertEquals(lastValidDate, bCalendar.lastValidDate()); + } + + public void testBusinessSchedule() { + assertEquals(holiday, bCalendar.businessSchedule(holidayDate1)); + assertEquals(holiday, bCalendar.businessSchedule(holidayDate2)); + assertEquals(halfDay, bCalendar.businessSchedule(halfDayDate)); + + // TUES - Weekday + LocalDate date = LocalDate.of(2023,7,11); + assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date)); + assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.toString())); + assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone))); + assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone).toInstant())); + + // WED - Weekend + date = LocalDate.of(2023,7,12); + assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date)); + assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.toString())); + assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone))); + assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone).toInstant())); + + // THURS - Weekend + date = LocalDate.of(2023,7,13); + assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date)); + assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.toString())); + assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone))); + assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone).toInstant())); + + // FRI - Weekday + date = LocalDate.of(2023,7,14); + assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date)); + assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.toString())); + assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone))); + assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone).toInstant())); + + // Current date + assertEquals(bCalendar.businessSchedule(bCalendar.currentDate()), bCalendar.businessSchedule()); + + + // Check that all dates in the range work + for(LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { + assertNotNull(bCalendar.businessSchedule(d)); + } + + try{ + bCalendar.businessSchedule(firstValidDate.minusDays(1)); + fail("should throw an exception"); + } catch (BusinessCalendar.InvalidDateException ignored){ + } + + try{ + bCalendar.businessSchedule(lastValidDate.plusDays(1)); + fail("should throw an exception"); + } catch (BusinessCalendar.InvalidDateException ignored){ + } + + try{ + bCalendar.businessSchedule((LocalDate) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.businessSchedule((String) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.businessSchedule((ZonedDateTime) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.businessSchedule((Instant) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + } + + public void testFail() { + fail(); + } + + +// *** rename and implement + +// private static final ZoneId TZ_NY = ZoneId.of("America/New_York"); +// private static final ZoneId TZ_JP = ZoneId.of("Asia/Tokyo"); +// private static final ZoneId TZ_UTC = ZoneId.of("UTC"); +// +// private final BusinessCalendar USNYSE = Calendars.calendar("USNYSE"); +// private final BusinessCalendar JPOSE = Calendars.calendar("JPOSE"); +// private final BusinessCalendar UTC = Calendars.calendar("UTC"); +// +// private final String curDay = "2017-09-27"; +// private File testCal; +// private BusinessCalendar test; +// +// @Override +// public void setUp() throws Exception { +// super.setUp(); +// testCal = File.createTempFile("Test", ".calendar"); +// final FileWriter fw = new FileWriter(testCal); +// fw.write("\n" + +// "\n" + +// "\n" + +// " TEST\n" + +// " NY\n" + +// " en\n" + +// " US\n" + +// " \n" + +// " 09:30,16:00\n" + +// " Saturday\n" + +// " Sunday\n" + +// " \n" + +// ""); +// fw.flush(); +// fw.close(); +// +// +// test = BusinessCalendarParser.loadBusinessCalendar(testCal); +//// test = new BusinessCalendarParser(BusinessCalendarParser.parseBusinessCalendarInputs(testCal)) { +//// @Override +//// public String currentDay() { +//// return curDay; +//// } +//// }; +// } +// +// @Override +// public void tearDown() throws Exception { +// assertTrue(testCal.delete()); +// super.tearDown(); +// } +// +// public void testName() { +// Calendar cal = Calendars.calendar("USNYSE"); +// assertEquals(cal.name(), "USNYSE"); +// } + +// public void testNextDay() { +//// assertEquals("2017-09-28", test.futureDate()); +// assertEquals("2017-09-29", test.futureDate(2)); +// assertEquals("2017-10-11", test.futureDate(14)); +// +// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); +// String day2 = "2016-09-02"; +// assertEquals(USNYSE.futureDate(day1, 2), day2); +// assertEquals(JPOSE.futureDate(day1, 2), day2); +// assertEquals(USNYSE.futureDate(day2, -2), DateTimeUtils.formatDate(day1, TZ_NY)); +// assertEquals(JPOSE.futureDate(day2, -2), DateTimeUtils.formatDate(day1, TZ_JP)); +// +// assertEquals(USNYSE.futureDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_NY)); +// assertEquals(JPOSE.futureDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_JP)); +// +// // leap day +// day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); +// day2 = "2016-02-29"; +// assertEquals(USNYSE.futureDate(day1), day2); +// assertEquals(JPOSE.futureDate(day1), day2); +// +// // new year +// day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); +// day2 = "2014-01-05"; +// assertEquals(USNYSE.futureDate(day1, 5), day2); +// assertEquals(JPOSE.futureDate(day1, 5), day2); +// assertEquals(USNYSE.futureDate(day2, -5), DateTimeUtils.formatDate(day1, TZ_NY)); +// assertEquals(JPOSE.futureDate(day2, -5), DateTimeUtils.formatDate(day1, TZ_JP)); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); +// day2 = "2017-03-13"; +// assertEquals(USNYSE.futureDate(day1), day2); +// assertEquals(JPOSE.futureDate(day1), day2); +// +// // outside calendar range +// day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); +// day2 = "2070-01-01"; +// assertEquals(USNYSE.futureDate(day1), day2); +// assertEquals(JPOSE.futureDate(day1), day2); +// +// day1 = null; +// assertNull(USNYSE.futureDate(day1)); +// assertNull(JPOSE.futureDate(day1)); +// } +// +// public void testNextDayString() { +// String day1 = "2016-08-31"; +// String day2 = "2016-09-04"; +// assertEquals(USNYSE.futureDate(day1, 4), day2); +// assertEquals(JPOSE.futureDate(day1, 4), day2); +// assertEquals(USNYSE.futureDate(day2, -4), day1); +// assertEquals(JPOSE.futureDate(day2, -4), day1); +// +// assertEquals(USNYSE.futureDate(day1, 0), day1); +// assertEquals(JPOSE.futureDate(day1, 0), day1); +// +// // leap day +// day1 = "2016-02-28"; +// day2 = "2016-02-29"; +// assertEquals(USNYSE.futureDate(day1), day2); +// assertEquals(JPOSE.futureDate(day1), day2); +// +// // new year +// day1 = "2013-12-31"; +// day2 = "2014-01-01"; +// assertEquals(USNYSE.futureDate(day1), day2); +// assertEquals(JPOSE.futureDate(day1), day2); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// day1 = "2017-03-12"; +// day2 = "2017-03-15"; +// assertEquals(USNYSE.futureDate(day1, 3), day2); +// assertEquals(JPOSE.futureDate(day1, 3), day2); +// assertEquals(USNYSE.futureDate(day2, -3), day1); +// assertEquals(JPOSE.futureDate(day2, -3), day1); +// +// day1 = null; +// assertNull(USNYSE.futureDate(day1)); +// assertNull(JPOSE.futureDate(day1)); +// +// +// day1 = "2014-03-10"; +// day2 = "2017-03-13"; +// assertEquals(USNYSE.futureDate(day1, 1099), day2); +// +// // incorrectly formatted days +// try { +// USNYSE.futureDate("2018-02-31"); +// fail(); +// } catch (IllegalArgumentException e) { +// // ok +// } +// try { +// USNYSE.futureDate("20193-02-31"); +// fail(); +// } catch (IllegalArgumentException e) { +// // ok +// } +// } +// +// public void testPreviousDay() { +// assertEquals("2017-09-26", test.pastDate()); +// assertEquals("2017-09-25", test.pastDate(2)); +// assertEquals("2017-09-13", test.pastDate(14)); +// +// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); +// Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); +// assertEquals(USNYSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); +// assertEquals(JPOSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); +// +// assertEquals(USNYSE.pastDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_NY)); +// assertEquals(JPOSE.pastDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_JP)); +// +// // leap day +// day1 = DateTimeUtils.parseInstant("2016-02-29T01:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 NY"); +// assertEquals(USNYSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); +// assertEquals(JPOSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); +// +// // new year +// day1 = DateTimeUtils.parseInstant("2013-12-29T01:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2014-01-01T01:00:00.000000000 NY"); +// assertEquals(USNYSE.pastDate(day2, 3), DateTimeUtils.formatDate(day1, TZ_NY)); +// assertEquals(JPOSE.pastDate(day2, 3), DateTimeUtils.formatDate(day1, TZ_JP)); +// assertEquals(USNYSE.pastDate(day1, -3), DateTimeUtils.formatDate(day2, TZ_NY)); +// assertEquals(JPOSE.pastDate(day1, -3), DateTimeUtils.formatDate(day2, TZ_JP)); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// day1 = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 NY"); +// assertEquals(USNYSE.pastDate(day2, 2), DateTimeUtils.formatDate(day1, TZ_NY)); +// assertEquals(JPOSE.pastDate(day2, 2), DateTimeUtils.formatDate(day1, TZ_JP)); +// assertEquals(USNYSE.pastDate(day1, -2), DateTimeUtils.formatDate(day2, TZ_NY)); +// assertEquals(JPOSE.pastDate(day1, -2), DateTimeUtils.formatDate(day2, TZ_JP)); +// +// day1 = null; +// assertNull(USNYSE.pastDate(day1)); +// assertNull(JPOSE.pastDate(day1)); +// } +// +// public void testPreviousDayString() { +// String day1 = "2016-08-30"; +// String day2 = "2016-09-01"; +// assertEquals(USNYSE.pastDate(day2, 2), day1); +// assertEquals(JPOSE.pastDate(day2, 2), day1); +// assertEquals(USNYSE.pastDate(day1, -2), day2); +// assertEquals(JPOSE.pastDate(day1, -2), day2); +// +// assertEquals(USNYSE.pastDate(day1, 0), day1); +// assertEquals(JPOSE.pastDate(day1, 0), day1); +// +// // leap day +// day1 = "2016-02-29"; +// day2 = "2016-03-01"; +// assertEquals(USNYSE.pastDate(day2), day1); +// assertEquals(JPOSE.pastDate(day2), day1); +// +// // new year +// day1 = "2013-12-31"; +// day2 = "2014-01-01"; +// assertEquals(USNYSE.pastDate(day2), day1); +// assertEquals(JPOSE.pastDate(day2), day1); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// day1 = "2017-03-10"; +// day2 = "2017-03-13"; +// assertEquals(USNYSE.pastDate(day2, 3), day1); +// assertEquals(JPOSE.pastDate(day2, 3), day1); +// assertEquals(USNYSE.pastDate(day1, -3), day2); +// assertEquals(JPOSE.pastDate(day1, -3), day2); +// +// day1 = null; +// assertNull(USNYSE.pastDate(day1)); +// assertNull(JPOSE.pastDate(day1)); +// +// day1 = "2014-03-10"; +// day2 = "2017-03-13"; +// assertEquals(USNYSE.pastDate(day2, 1099), day1); +// +// // incorrectly formatted days +// try { +// USNYSE.pastDate("2018-02-31"); +// fail(); +// } catch (IllegalArgumentException e) { +// // ok +// } +// try { +// USNYSE.pastDate("20193-02-31"); +// fail(); +// } catch (IllegalArgumentException e) { +// // ok +// } +// } +// +// public void testDateRange() { +// // day light savings +// Instant startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); +// Instant endDate = DateTimeUtils.parseInstant("2017-03-14T01:00:00.000000000 NY"); +// +// String[] goodResults = new String[] { +// "2017-03-11", +// "2017-03-12", +// "2017-03-13", +// "2017-03-14" +// }; +// +// String[] results = USNYSE.calendarDates(startDate, endDate); +// Arrays.sort(goodResults); +// Arrays.sort(results); +// boolean answer = Arrays.equals(goodResults, results); +// assertTrue(answer); +// +// +// startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 JP"); +// endDate = DateTimeUtils.parseInstant("2017-03-14T01:00:00.000000000 JP"); +// results = JPOSE.calendarDates(startDate, endDate); +// Arrays.sort(goodResults); +// Arrays.sort(results); +// answer = Arrays.equals(goodResults, results); +// assertTrue(answer); +// +// +// startDate = null; +// assertEquals(USNYSE.calendarDates(startDate, endDate).length, 0); +// assertEquals(JPOSE.calendarDates(startDate, endDate).length, 0); +// } +// +// public void testDateStringRange() { +// String startDate = "2014-02-18"; +// String endDate = "2014-03-05"; +// String[] goodResults = new String[] { +// "2014-02-18", "2014-02-19", "2014-02-20", "2014-02-21", "2014-02-22", "2014-02-23", +// "2014-02-24", "2014-02-25", "2014-02-26", "2014-02-27", "2014-02-28", +// "2014-03-01", "2014-03-02", "2014-03-03", "2014-03-04", "2014-03-05" +// }; +// +// String[] results = USNYSE.calendarDates(startDate, endDate); +// Arrays.sort(goodResults); +// Arrays.sort(results); +// boolean answer = Arrays.equals(goodResults, results); +// assertTrue(answer); +// +// results = JPOSE.calendarDates(startDate, endDate); +// Arrays.sort(goodResults); +// Arrays.sort(results); +// answer = Arrays.equals(goodResults, results); +// assertTrue(answer); +// +// startDate = "2020-01-01"; +// endDate = "2020-01-20"; +// +// results = USNYSE.calendarDates(startDate, endDate); +// assertEquals(results.length, 20); +// +// results = JPOSE.calendarDates(startDate, endDate); +// assertEquals(results.length, 20); +// +// startDate = null; +// assertEquals(USNYSE.calendarDates(startDate, endDate).length, 0); +// assertEquals(JPOSE.calendarDates(startDate, endDate).length, 0); +// +// +// // incorrectly formatted days +// assertEquals(new String[0], USNYSE.calendarDates("2018-02-31", "2019-02-31")); +// } +// +// public void testNumberOfDays() { +// Instant startDate = DateTimeUtils.parseInstant("2014-02-18T01:00:00.000000000 NY"); +// Instant endDate = DateTimeUtils.parseInstant("2014-03-05T01:00:00.000000000 NY"); +// +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 15); +// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 11); +// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, false), 11); +// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 12); +// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 4); +// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, false), 4); +// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 4); +// +// +// startDate = DateTimeUtils.parseInstant("2020-01-01T01:00:00.000000000 NY"); +// endDate = DateTimeUtils.parseInstant("2020-01-20T01:00:00.000000000 NY"); +// +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 19); +// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 12); +// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 12); +// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 7); +// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 8); +// +// startDate = endDate; +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 0); +// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 0); +// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 0); +// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 0); +// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 1); +// +// startDate = DateTimeUtils.parseInstant("2020-01-02T01:00:00.000000000 NY"); +// endDate = startDate; +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 0); +// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 0); +// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 1); +// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 0); +// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 0); +// +// startDate = null; +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); +// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); +// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); +// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); +// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); +// +// startDate = DateTimeUtils.parseInstant("2014-02-18T01:00:00.000000000 NY"); +// endDate = null; +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); +// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); +// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); +// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); +// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); +// +// startDate = DateTimeUtils.parseInstant("2014-02-18T01:00:00.000000000 NY"); +// endDate = DateTimeUtils.parseInstant("2017-02-18T01:00:00.000000000 NY"); +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 1096); +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate, true), 1097); +// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 758); +// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 758); +// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 338); +// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 339); +// } +// +// public void testNumberOfDaysString() { +// String startDate = "2014-02-18"; +// String endDate = "2014-03-05"; +// +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 15); +// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 11); +// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 4); +// +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate, false), 15); +// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, false), 11); +// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, false), 4); +// +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate, true), 16); +// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 12); +// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 4); +// +// assertEquals(USNYSE.numberCalendarDates(endDate, startDate), -15); +// assertEquals(USNYSE.numberOfBusinessDays(endDate, startDate), -11); +// assertEquals(USNYSE.numberOfNonBusinessDays(endDate, startDate), -4); +// +// assertEquals(USNYSE.numberCalendarDates(endDate, startDate, false), -15); +// assertEquals(USNYSE.numberBusinessDates(endDate, startDate, false), -11); +// assertEquals(USNYSE.numberNonBusinessDates(endDate, startDate, false), -4); +// +// assertEquals(USNYSE.numberCalendarDates(endDate, startDate, true), -16); +// assertEquals(USNYSE.numberBusinessDates(endDate, startDate, true), -12); +// assertEquals(USNYSE.numberNonBusinessDates(endDate, startDate, true), -4); +// +// endDate = startDate; +// +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 0); +// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 0); +// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 0); +// +// +// startDate = "2020-01-01"; +// endDate = "2020-01-20"; +// +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 19); +// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 12); +// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 7); +// +// startDate = null; +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); +// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); +// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); +// +// startDate = "2014-02-18"; +// endDate = null; +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); +// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); +// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); +// +// +// +// startDate = "2014-02-18"; +// endDate = "2017-02-18"; +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 1096); +// assertEquals(USNYSE.numberCalendarDates(startDate, endDate, true), 1097); +// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 758); +// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 758); +// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 338); +// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 339); +// +// +// // incorrectly formatted days +// try { +// USNYSE.numberCalendarDates("2018-02-31", "2019-02-31"); +// fail(); +// } catch (IllegalArgumentException e) { +// // ok +// } +// } +// +// public void testIsBusinessDay() { +// assertTrue(test.isBusinessDay()); +// +// Instant businessDay = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); +// Instant halfDay = DateTimeUtils.parseInstant("2014-07-03T01:00:00.000000000 NY"); +// Instant holiday = DateTimeUtils.parseInstant("2002-01-01T01:00:00.000000000 NY"); +// Instant holiday2 = DateTimeUtils.parseInstant("2002-01-21T01:00:00.000000000 NY"); +// +// assertTrue(USNYSE.isBusinessDay(businessDay)); +// assertTrue(USNYSE.isBusinessDay(halfDay)); +// assertFalse(USNYSE.isBusinessDay(holiday)); +// assertFalse(USNYSE.isBusinessDay(holiday2)); +// +// businessDay = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); +// halfDay = DateTimeUtils.parseInstant("2006-01-04T01:00:00.000000000 JP"); +// holiday = DateTimeUtils.parseInstant("2006-01-02T01:00:00.000000000 JP"); +// holiday2 = DateTimeUtils.parseInstant("2007-12-23T01:00:00.000000000 JP"); +// +// assertTrue(JPOSE.isBusinessDay(businessDay)); +// assertTrue(JPOSE.isBusinessDay(halfDay)); +// assertFalse(JPOSE.isBusinessDay(holiday)); +// assertFalse(JPOSE.isBusinessDay(holiday2)); +// +// +// businessDay = null; +// // noinspection ConstantConditions +// assertFalse(USNYSE.isBusinessDay(businessDay)); +// // noinspection ConstantConditions +// assertFalse(JPOSE.isBusinessDay(businessDay)); +// } +// +// public void testIsBusinessTime() { +// Instant businessDayNotTime = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); +// Instant halfDayTime = DateTimeUtils.parseInstant("2014-07-03T12:00:00.000000000 NY"); +// Instant holiday = DateTimeUtils.parseInstant("2002-01-01T01:00:00.000000000 NY"); +// Instant holiday2 = DateTimeUtils.parseInstant("2002-01-21T01:00:00.000000000 NY"); +// +// assertFalse(USNYSE.isBusinessTime(businessDayNotTime)); +// assertTrue(USNYSE.isBusinessTime(halfDayTime)); +// assertFalse(USNYSE.isBusinessTime(holiday)); +// assertFalse(USNYSE.isBusinessTime(holiday2)); +// +// Instant businessDayTime = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); +// halfDayTime = DateTimeUtils.parseInstant("2006-01-04T11:00:00.000000000 JP"); +// holiday = DateTimeUtils.parseInstant("2006-01-02T01:00:00.000000000 JP"); +// holiday2 = DateTimeUtils.parseInstant("2007-12-23T01:00:00.000000000 JP"); +// +// assertFalse(JPOSE.isBusinessTime(businessDayTime)); +// assertTrue(JPOSE.isBusinessTime(halfDayTime)); +// assertFalse(JPOSE.isBusinessTime(holiday)); +// assertFalse(JPOSE.isBusinessTime(holiday2)); +// +// +// holiday = null; +// // noinspection ConstantConditions +// assertFalse(USNYSE.isBusinessTime(holiday)); +// // noinspection ConstantConditions +// assertFalse(JPOSE.isBusinessTime(holiday)); +// } +// +// public void testIsBusinessDayString() { +// String businessDay = "2016-08-31"; +// String halfDay = "2014-07-03"; +// String holiday = "2002-01-01"; +// String holiday2 = "2002-01-21"; +// +// assertTrue(USNYSE.isBusinessDay(businessDay)); +// assertTrue(USNYSE.isBusinessDay(halfDay)); +// assertFalse(USNYSE.isBusinessDay(holiday)); +// assertFalse(USNYSE.isBusinessDay(holiday2)); +// +// businessDay = "2016-08-31"; +// halfDay = "2006-01-04"; +// holiday = "2007-09-17"; +// holiday2 = "2006-02-11"; +// +// assertTrue(JPOSE.isBusinessDay(businessDay)); +// assertTrue(JPOSE.isBusinessDay(halfDay)); +// assertFalse(JPOSE.isBusinessDay(holiday)); +// assertFalse(JPOSE.isBusinessDay(holiday2)); +// +// businessDay = null; +// assertFalse(JPOSE.isBusinessDay(businessDay)); +// assertFalse(JPOSE.isBusinessDay(businessDay)); +// +// +// // incorrectly formatted days +// try { +// USNYSE.isBusinessDay("2018-09-31"); +// fail(); +// } catch (IllegalArgumentException e) { +// // ok +// } +// } +// +// public void testNextBusinessDay() { +// assertEquals("2017-09-28", test.futureBusinessDate()); +// assertEquals("2017-09-29", test.futureBusinessDate(2)); +// assertEquals("2017-10-17", test.futureBusinessDate(14)); +// +// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); +// Instant day1JP = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); +// String day2 = "2016-09-01"; +// assertNull(USNYSE.futureBusinessDate((Instant) null)); +// assertEquals(USNYSE.futureBusinessDate(day1), day2); +// assertEquals(JPOSE.futureBusinessDate(day1JP), day2); +// +// assertNull(USNYSE.futureBusinessDate((Instant) null, 2)); +// assertEquals(USNYSE.futureBusinessDate(day1, 2), "2016-09-02"); +// assertEquals(JPOSE.futureBusinessDate(day1JP, 2), "2016-09-02"); +// +// assertEquals(USNYSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 NY"), -2), +// "2016-08-31"); +// assertEquals(JPOSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 JP"), -2), +// "2016-08-31"); +// +// assertEquals(USNYSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"), 0), +// "2016-08-30"); +// assertNull(USNYSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-08-28T01:00:00.000000000 NY"), 0)); +// +// // leap day +// day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 JP"); +// day2 = "2016-02-29"; +// assertEquals(USNYSE.futureBusinessDate(day1), day2); +// assertEquals(JPOSE.futureBusinessDate(day1JP), day2); +// +// // new year +// day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 JP"); +// day2 = "2014-01-02"; +// assertEquals(USNYSE.futureBusinessDate(day1), day2); +// +// day2 = "2014-01-01"; +// assertEquals(JPOSE.futureBusinessDate(day1JP), day2); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// // Japan doesn't observe day light savings +// day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); +// day2 = "2017-03-13"; +// assertEquals(USNYSE.futureBusinessDate(day1), day2); +// assertEquals(JPOSE.futureBusinessDate(day1JP), day2); +// +// // outside calendar range, so no day off for new years, but weekend should still be off +// day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 JP"); +// day2 = "2070-01-01"; +// assertEquals(USNYSE.futureBusinessDate(day1).compareTo(day2), 0); +// assertEquals(JPOSE.futureBusinessDate(day1JP), day2); +// +// day1 = DateTimeUtils.parseInstant("2070-01-03T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2070-01-03T01:00:00.000000000 JP"); +// day2 = "2070-01-06"; +// assertEquals(USNYSE.futureBusinessDate(day1), day2); +// assertEquals(JPOSE.futureBusinessDate(day1JP), day2); +// +// day1 = null; +// assertNull(USNYSE.futureBusinessDate(day1)); +// assertNull(JPOSE.futureBusinessDate(day1)); +// } +// +// public void testNextBusinessDayString() { +// String day1 = "2016-08-31"; +// String day2 = "2016-09-01"; +// assertNull(USNYSE.futureBusinessDate((String) null)); +// assertEquals(USNYSE.futureBusinessDate(day1), day2); +// assertEquals(JPOSE.futureBusinessDate(day1), day2); +// +// assertNull(USNYSE.futureBusinessDate((String) null, 2)); +// assertEquals(USNYSE.futureBusinessDate(day1, 2), "2016-09-02"); +// assertEquals(JPOSE.futureBusinessDate(day1, 2), "2016-09-02"); +// +// assertEquals(USNYSE.futureBusinessDate("2016-09-02", -2), "2016-08-31"); +// assertEquals(JPOSE.futureBusinessDate("2016-09-02", -2), "2016-08-31"); +// +// assertEquals(USNYSE.futureBusinessDate("2016-08-30", 0), "2016-08-30"); +// assertNull(USNYSE.futureBusinessDate("2016-08-28", 0)); +// +// // leap day +// day1 = "2016-02-28"; +// day2 = "2016-02-29"; +// assertEquals(USNYSE.futureBusinessDate(day1), day2); +// assertEquals(JPOSE.futureBusinessDate(day1), day2); +// +// // new year +// day1 = "2013-12-31"; +// day2 = "2014-01-02"; +// assertEquals(USNYSE.futureBusinessDate(day1), day2); +// +// day1 = "2007-01-01"; +// day2 = "2007-01-04"; +// assertEquals(JPOSE.futureBusinessDate(day1), day2); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// day1 = "2017-03-12"; +// day2 = "2017-03-13"; +// assertEquals(USNYSE.futureBusinessDate(day1), day2); +// assertEquals(JPOSE.futureBusinessDate(day1), day2); +// +// day1 = null; +// assertNull(USNYSE.futureBusinessDate(day1)); +// assertNull(JPOSE.futureBusinessDate(day1)); +// +// // incorrectly formatted days +// try { +// USNYSE.futureBusinessDate("2018-09-31"); +// fail(); +// } catch (IllegalArgumentException e) { +// // ok +// } +// } +// +// public void testNextBusinessSchedule() { +// assertEquals(test.nextBusinessSchedule(curDay), test.nextBusinessSchedule()); +// assertEquals(test.nextBusinessSchedule(curDay, 2), test.nextBusinessSchedule(2)); +// +// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); +// Instant day1JP = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); +// String day2 = "2016-09-01"; +// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); +// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); +// +// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1, 2).getSOBD(), TZ_NY), "2016-09-02"); +// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP, 2).getSOBD(), TZ_JP), "2016-09-02"); +// +// assertEquals(DateTimeUtils.formatDate( +// USNYSE.nextBusinessSchedule(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 NY"), -2) +// .getSOBD(), +// TZ_NY), "2016-08-31"); +// assertEquals(DateTimeUtils.formatDate( +// JPOSE.nextBusinessSchedule(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 JP"), -2) +// .getSOBD(), +// TZ_JP), "2016-08-31"); +// +// assertEquals(DateTimeUtils.formatDate( +// USNYSE.nextBusinessSchedule(DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"), 0) +// .getSOBD(), +// TZ_NY), "2016-08-30"); +// +// // leap day +// day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 JP"); +// day2 = "2016-02-29"; +// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); +// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); +// +// // new year +// day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 JP"); +// day2 = "2014-01-03"; +// assertEquals( +// DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(USNYSE.futureBusinessDate(day1)).getSOBD(), TZ_NY), +// day2); +// +// day2 = "2014-01-01"; +// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// // Japan doesn't observe day light savings +// day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); +// day2 = "2017-03-13"; +// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); +// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); +// +// // outside calendar range, so no day off for new years, but weekend should still be off +// day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 JP"); +// day2 = "2070-01-01"; +// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY).compareTo(day2), 0); +// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); +// +// day1 = DateTimeUtils.parseInstant("2070-01-05T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2070-01-05T01:00:00.000000000 JP"); +// day2 = "2070-01-06"; +// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); +// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); +// +// day1 = null; +// assertNull(USNYSE.nextBusinessSchedule(day1)); +// assertNull(JPOSE.nextBusinessSchedule(day1)); +// +// +// // holiday +// final BusinessSchedule holiday = USNYSE.businessSchedule("2017-12-25"); +// assertEquals(0, holiday.periods().length); +// assertEquals(0, holiday.businessNanos()); +// try { +// // noinspection ResultOfMethodCallIgnored +// holiday.businessEnd(); +// fail("Expected an exception!"); +// } catch (UnsupportedOperationException e) { +// // pass +// } +// try { +// // noinspection ResultOfMethodCallIgnored +// holiday.businessStart(); +// fail("Expected an exception!"); +// } catch (UnsupportedOperationException e) { +// // pass +// } +// } +// +// public void testNextBusinessScheduleString() { +// String day1 = "2016-08-31"; +// String day2 = "2016-09-01"; +// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); +// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1).getSOBD(), TZ_JP), day2); +// +// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1, 2).getSOBD(), TZ_NY), "2016-09-02"); +// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1, 2).getSOBD(), TZ_JP), "2016-09-02"); +// +// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule("2016-09-02", -2).getSOBD(), TZ_NY), +// "2016-08-31"); +// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule("2016-09-02", -2).getSOBD(), TZ_JP), +// "2016-08-31"); +// +// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule("2016-08-30", 0).getSOBD(), TZ_NY), +// "2016-08-30"); +// assertNull(USNYSE.nextBusinessSchedule((String) null, 0)); +// +// // leap day +// day1 = "2016-02-28"; +// day2 = "2016-02-29"; +// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); +// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1).getSOBD(), TZ_JP), day2); +// +// // new year +// day1 = "2014-01-01"; +// day2 = "2014-01-02"; +// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); +// +// day1 = "2007-01-03"; +// day2 = "2007-01-04"; +// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1).getSOBD(), TZ_JP), day2); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// day1 = "2017-03-12"; +// day2 = "2017-03-13"; +// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); +// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1).getSOBD(), TZ_JP), day2); +// +// day1 = null; +// assertNull(USNYSE.nextBusinessSchedule(day1)); +// assertNull(JPOSE.nextBusinessSchedule(day1)); +// } +// +// public void testNextNonBusinessDay() { +// assertEquals("2017-09-30", test.futureNonBusinessDate()); +// assertEquals("2017-10-01", test.futureNonBusinessDate(2)); +// assertEquals("2017-10-08", test.futureNonBusinessDate(4)); +// +// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); +// Instant day1JP = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); +// String day2 = "2016-09-03"; +// assertNull(USNYSE.futureNonBusinessDate((Instant) null)); +// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); +// assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); +// +// assertNull(USNYSE.futureNonBusinessDate((Instant) null, 2)); +// assertEquals(USNYSE.futureNonBusinessDate(day1, 2), "2016-09-04"); +// assertEquals(JPOSE.futureNonBusinessDate(day1JP, 2), "2016-09-04"); +// +// assertEquals(USNYSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-09-04T01:00:00.000000000 NY"), -2), +// "2016-08-28"); +// assertEquals(JPOSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-09-04T01:00:00.000000000 JP"), -2), +// "2016-08-28"); +// +// assertNull(USNYSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"), 0)); +// assertEquals(USNYSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-08-28T01:00:00.000000000 NY"), 0), +// "2016-08-28"); +// +// // leap day +// day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 JP"); +// day2 = "2016-03-05"; +// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); +// assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); +// +// // new year +// day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 JP"); +// day2 = "2014-01-01"; +// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); +// +// day2 = "2014-01-04"; +// assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); +// day2 = "2017-03-18"; +// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); +// assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); +// +// // outside calendar range, so no day off for new years, but weekend should still be off +// day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); +// day1JP = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 JP"); +// day2 = "2070-01-04"; +// assertEquals(USNYSE.futureNonBusinessDate(day1).compareTo(day2), 0); +// assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); +// +// day1 = null; +// assertNull(USNYSE.futureNonBusinessDate(day1)); +// assertNull(JPOSE.futureNonBusinessDate(day1)); +// } +// +// public void testNextNonBusinessDayString() { +// String day1 = "2016-08-31"; +// String day2 = "2016-09-03"; +// assertNull(USNYSE.futureNonBusinessDate((String) null)); +// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); +// assertEquals(JPOSE.futureNonBusinessDate(day1), day2); +// +// assertNull(USNYSE.futureNonBusinessDate((String) null, 2)); +// assertEquals(USNYSE.futureNonBusinessDate(day1, 2), "2016-09-04"); +// assertEquals(JPOSE.futureNonBusinessDate(day1, 2), "2016-09-04"); +// +// assertEquals(USNYSE.futureNonBusinessDate("2016-09-04", -2), "2016-08-28"); +// assertEquals(JPOSE.futureNonBusinessDate("2016-09-04", -2), "2016-08-28"); +// +// assertNull(USNYSE.futureNonBusinessDate("2016-08-30", 0)); +// assertEquals(USNYSE.futureNonBusinessDate("2016-08-28", 0), "2016-08-28"); +// +// // leap day +// day1 = "2016-02-28"; +// day2 = "2016-03-05"; +// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); +// assertEquals(JPOSE.futureNonBusinessDate(day1), day2); +// +// // new year +// day1 = "2013-12-31"; +// day2 = "2014-01-01"; +// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// day1 = "2017-03-12"; +// day2 = "2017-03-18"; +// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); +// assertEquals(JPOSE.futureNonBusinessDate(day1), day2); +// +// day1 = null; +// assertNull(USNYSE.futureNonBusinessDate(day1)); +// assertNull(JPOSE.futureNonBusinessDate(day1)); +// +// // incorrectly formatted days +// try { +// USNYSE.futureNonBusinessDate("2018-09-31"); +// fail(); +// } catch (IllegalArgumentException e) { +// // ok +// } +// } +// +// public void testLastBusinessDay() { +// assertEquals("2017-09-26", test.pastBusinessDate()); +// assertEquals("2017-09-25", test.pastBusinessDate(2)); +// assertEquals("2017-09-07", test.pastBusinessDate(14)); +// +// assertEquals("2017-09-24", test.pastNonBusinessDate()); +// assertEquals("2017-09-23", test.pastNonBusinessDate(2)); +// assertEquals("2017-09-16", test.pastNonBusinessDate(4)); +// +// +// Instant day1 = DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"); +// Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); +// assertNull(USNYSE.pastBusinessDate((Instant) null, 2)); +// assertEquals(USNYSE.pastBusinessDate(day2, 2), DateTimeUtils.formatDate(day1, TZ_NY)); +// assertEquals(USNYSE.pastBusinessDate(day1, -2), DateTimeUtils.formatDate(day2, TZ_NY)); +// +// assertEquals(USNYSE.pastBusinessDate(DateTimeUtils.parseInstant("2016-08-30T15:00:00.000000000 NY"), 0), +// "2016-08-30"); +// assertNull(USNYSE.pastBusinessDate(DateTimeUtils.parseInstant("2016-08-28T15:00:00.000000000 NY"), 0)); +// +// assertNull(USNYSE.pastNonBusinessDate((Instant) null, 0)); +// assertNull(USNYSE.pastNonBusinessDate(DateTimeUtils.parseInstant("2016-08-30T21:00:00.000000000 NY"), 0)); +// assertEquals( +// USNYSE.pastNonBusinessDate(DateTimeUtils.parseInstant("2016-08-28T21:00:00.000000000 NY"), 0), +// "2016-08-28"); +// +// // leap day +// day1 = DateTimeUtils.parseInstant("2016-02-29T21:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 NY"); +// assertEquals(USNYSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); +// +// // new year +// day1 = DateTimeUtils.parseInstant("2013-12-26T01:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2014-01-02T01:00:00.000000000 NY"); +// assertEquals(USNYSE.pastBusinessDate(day2, 4), DateTimeUtils.formatDate(day1, TZ_NY)); +// assertEquals(USNYSE.pastBusinessDate(day1, -4), DateTimeUtils.formatDate(day2, TZ_NY)); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// day1 = DateTimeUtils.parseInstant("2017-02-26T01:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 NY"); +// assertEquals(USNYSE.pastNonBusinessDate(day2, 5), DateTimeUtils.formatDate(day1, TZ_NY)); +// assertEquals(USNYSE.pastNonBusinessDate(day1, -5), "2017-03-18"); +// +// day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 NY"); +// assertEquals(USNYSE.pastNonBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); +// +// day1 = DateTimeUtils.parseInstant("2017-07-04T01:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2017-07-07T01:00:00.000000000 NY"); +// assertEquals(USNYSE.pastNonBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); +// +// day1 = null; +// assertNull(USNYSE.pastBusinessDate(day1)); +// assertNull(USNYSE.pastNonBusinessDate(day1)); +// +// +// +// day1 = DateTimeUtils.parseInstant("2016-08-31T21:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2016-09-01T21:00:00.000000000 JP"); +// assertEquals(JPOSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); +// +// // leap day +// day1 = DateTimeUtils.parseInstant("2016-02-29T01:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 JP"); +// assertEquals(JPOSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); +// +// // new year +// day1 = DateTimeUtils.parseInstant("2013-12-31T11:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2014-01-01T11:00:00.000000000 JP"); +// assertEquals(JPOSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); +// +// // Daylight savings starts in JP (UTC-7:00) at 2 AM 2017-03-12 +// day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 JP"); +// assertEquals(JPOSE.pastNonBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); +// +// +// day1 = null; +// assertNull(JPOSE.pastBusinessDate(day1)); +// assertNull(JPOSE.pastNonBusinessDate(day1)); +// } +// +// public void testLastBusinessDayString() { +// String day1 = "2016-08-31"; +// String day2 = "2016-09-01"; +// assertNull(USNYSE.pastBusinessDate((String) null)); +// assertEquals(USNYSE.pastBusinessDate(day2), day1); +// assertEquals(JPOSE.pastBusinessDate(day2), day1); +// +// assertNull(USNYSE.pastBusinessDate((String) null, 2)); +// assertEquals(USNYSE.pastBusinessDate("2016-08-30", 0), "2016-08-30"); +// assertNull(USNYSE.pastBusinessDate("2016-08-28", 0)); +// +// day1 = "2016-08-29"; +// assertEquals(USNYSE.pastBusinessDate(day2, 3), day1); +// assertEquals(JPOSE.pastBusinessDate(day2, 3), day1); +// assertEquals(USNYSE.pastBusinessDate(day1, -3), day2); +// assertEquals(JPOSE.pastBusinessDate(day1, -3), day2); +// +// // leap day +// day1 = "2016-02-29"; +// day2 = "2016-03-01"; +// assertEquals(USNYSE.pastBusinessDate(day2), day1); +// assertEquals(JPOSE.pastBusinessDate(day2), day1); +// +// // new year +// day1 = "2013-12-30"; +// day2 = "2014-01-01"; +// assertEquals(USNYSE.pastBusinessDate(day2, 2), day1); +// assertEquals(JPOSE.pastBusinessDate(day2, 2), day1); +// assertEquals(USNYSE.pastBusinessDate(day1, -2), "2014-01-02"); +// assertEquals(JPOSE.pastBusinessDate(day1, -2), day2); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// day1 = "2017-03-10"; +// day2 = "2017-03-13"; +// assertEquals(USNYSE.pastBusinessDate(day2), day1); +// assertEquals(JPOSE.pastBusinessDate(day2), day1); +// +// day1 = null; +// assertNull(USNYSE.pastBusinessDate(day1)); +// assertNull(JPOSE.pastBusinessDate(day1)); +// +// // incorrectly formatted days +// try { +// USNYSE.pastBusinessDate("2018-09-31"); +// fail(); +// } catch (IllegalArgumentException e) { +// // ok +// } +// } +// +// public void testLastBusinessSchedule() { +// assertEquals(test.previousBusinessSchedule(curDay), test.previousBusinessSchedule()); +// assertEquals(test.previousBusinessSchedule(curDay, 2), test.previousBusinessSchedule(2)); +// +// +// Instant day1 = DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"); +// Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); +// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2, 2).getSOBD(), TZ_NY), +// DateTimeUtils.formatDate(day1, TZ_NY)); +// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day1, -2).getSOBD(), TZ_NY), +// DateTimeUtils.formatDate(day2, TZ_NY)); +// +// assertEquals( +// DateTimeUtils.formatDate(USNYSE +// .previousBusinessSchedule(DateTimeUtils.parseInstant("2016-08-30T15:00:00.000000000 NY"), 0) +// .getSOBD(), TZ_NY), +// "2016-08-30"); +// assertNull(USNYSE.previousBusinessSchedule((Instant) null, 0)); +// +// // leap day +// day1 = DateTimeUtils.parseInstant("2016-02-29T21:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 NY"); +// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2).getSOBD(), TZ_NY), +// DateTimeUtils.formatDate(day1, TZ_NY)); +// +// // new year +// day1 = DateTimeUtils.parseInstant("2013-12-26T01:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2014-01-02T01:00:00.000000000 NY"); +// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2, 7).getSOBD(), TZ_NY), +// DateTimeUtils.formatDate(day1, TZ_NY)); +// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day1, -7).getSOBD(), TZ_NY), +// DateTimeUtils.formatDate(day2, TZ_NY)); +// +// day1 = null; +// assertNull(USNYSE.previousBusinessSchedule(day1)); +// +// +// day1 = DateTimeUtils.parseInstant("2016-08-31T21:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2016-09-01T21:00:00.000000000 JP"); +// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), +// DateTimeUtils.formatDate(day1, TZ_JP)); +// +// // leap day +// day1 = DateTimeUtils.parseInstant("2016-02-29T01:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 JP"); +// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), +// DateTimeUtils.formatDate(day1, TZ_JP)); +// +// // new year +// day1 = DateTimeUtils.parseInstant("2013-12-31T11:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2014-01-01T11:00:00.000000000 JP"); +// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), +// DateTimeUtils.formatDate(day1, TZ_JP)); +// +// +// day1 = null; +// assertNull(JPOSE.previousBusinessSchedule(day1)); +// } +// +// public void testLastBusinessScheduleString() { +// String day1 = "2016-08-31"; +// String day2 = "2016-09-01"; +// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2).getSOBD(), TZ_NY), day1); +// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), day1); +// +// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule("2016-08-30", 0).getSOBD(), TZ_NY), +// "2016-08-30"); +// assertNull(USNYSE.previousBusinessSchedule((String) null, 0)); +// +// day1 = "2016-08-29"; +// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2, 3).getSOBD(), TZ_NY), day1); +// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2, 3).getSOBD(), TZ_JP), day1); +// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day1, -3).getSOBD(), TZ_NY), day2); +// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day1, -3).getSOBD(), TZ_JP), day2); +// +// // leap day +// day1 = "2016-02-29"; +// day2 = "2016-03-01"; +// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2).getSOBD(), TZ_NY), day1); +// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), day1); +// +// // new year +// day1 = "2014-12-29"; +// day2 = "2014-12-31"; +// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2, 2).getSOBD(), TZ_NY), day1); +// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2, 2).getSOBD(), TZ_JP), day1); +// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day1, -2).getSOBD(), TZ_NY), day2); +// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day1, -2).getSOBD(), TZ_JP), day2); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// day1 = "2017-03-10"; +// day2 = "2017-03-13"; +// assertEquals( +// DateTimeUtils.formatDate( +// USNYSE.previousBusinessSchedule(USNYSE.pastDate(USNYSE.pastDate(day2))).getSOBD(), TZ_NY), +// day1); +// assertEquals( +// DateTimeUtils.formatDate( +// JPOSE.previousBusinessSchedule(JPOSE.pastDate(JPOSE.pastDate(day2))).getSOBD(), TZ_JP), +// day1); +// +// day1 = null; +// assertNull(USNYSE.previousBusinessSchedule(day1)); +// assertNull(JPOSE.previousBusinessSchedule(day1)); +// +// // incorrectly formatted days +// try { +// USNYSE.previousBusinessSchedule("2018-09-31"); +// fail(); +// } catch (IllegalArgumentException e) { +// // ok +// } +// } +// +// public void testLastNonBusinessDayString() { +// String day1 = "2016-08-28"; +// String day2 = "2016-09-01"; +// assertNull(USNYSE.pastNonBusinessDate((String) null)); +// assertEquals(USNYSE.pastNonBusinessDate(day2), day1); +// assertEquals(JPOSE.pastNonBusinessDate(day2), day1); +// +// assertNull(USNYSE.pastNonBusinessDate((String) null, 2)); +// assertNull(USNYSE.pastNonBusinessDate("2016-08-30", 0)); +// assertEquals(USNYSE.pastNonBusinessDate("2016-08-28", 0), "2016-08-28"); +// +// // leap day +// day1 = "2016-02-27"; +// day2 = "2016-03-01"; +// assertEquals(USNYSE.pastNonBusinessDate(day2, 2), day1); +// assertEquals(JPOSE.pastNonBusinessDate(day2, 2), day1); +// assertEquals(USNYSE.pastNonBusinessDate(day1, -2), "2016-03-05"); +// assertEquals(JPOSE.pastNonBusinessDate(day1, -2), "2016-03-05"); +// +// // new year +// day1 = "2013-12-29"; +// day2 = "2014-01-01"; +// assertEquals(USNYSE.pastNonBusinessDate(day2), day1); +// assertEquals(JPOSE.pastNonBusinessDate(day2), day1); +// +// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 +// day1 = "2017-03-05"; +// day2 = "2017-03-13"; +// assertEquals(USNYSE.pastNonBusinessDate(day2, 3), day1); +// assertEquals(JPOSE.pastNonBusinessDate(day2, 3), day1); +// assertEquals(USNYSE.pastNonBusinessDate(day1, -3), "2017-03-18"); +// assertEquals(JPOSE.pastNonBusinessDate(day1, -3), "2017-03-18"); +// +// day1 = null; +// assertNull(USNYSE.pastNonBusinessDate(day1)); +// assertNull(JPOSE.pastNonBusinessDate(day1)); +// +// // incorrectly formatted days +// try { +// USNYSE.pastNonBusinessDate("2018-09-31"); +// fail(); +// } catch (IllegalArgumentException e) { +// // ok +// } +// } +// +// public void testDiff() { +// // standard business day +// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); +// Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); +// assertEquals(USNYSE.diffDay(day1, day2), 1.0); +// assertEquals(USNYSE.diffNanos(day1, day2), DateTimeUtils.DAY); +// assertEquals(JPOSE.diffYear365(day1, day2), (double) DateTimeUtils.DAY / (double) DateTimeUtils.YEAR_365); +// assertEquals(JPOSE.diffYearAvg(day1, day2), (double) DateTimeUtils.DAY / (double) DateTimeUtils.YEAR_AVG); +// } +// +// public void testBusinessTimeDiff() { +// // standard business day +// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); +// Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); +// assertEquals(USNYSE.diffBusinessDays(day1, day2), 1.0); +// assertEquals(JPOSE.diffBusinessDays(day1, day2), 1.0); +// +// // 2.5 standard business days +// day1 = DateTimeUtils.parseInstant("2017-01-23T01:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2017-01-25T12:45:00.000000000 NY"); +// assertEquals(USNYSE.diffBusinessDays(day1, day2), 2.5); +// +// day1 = DateTimeUtils.parseInstant("2017-01-23T01:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2017-01-25T12:45:00.000000000 JP"); +// assertEquals(JPOSE.diffBusinessDays(day1, day2), 2.55); +// +// // middle of a business period +// day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2017-01-23T13:00:00.000000000 JP"); +// assertEquals(JPOSE.diffBusinessNanos(day1, day2), 2 * DateTimeUtils.HOUR); +// +// // after a business period +// day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2017-01-23T16:15:00.000000000 JP"); +// assertEquals(JPOSE.diffBusinessNanos(day1, day2), 4 * DateTimeUtils.HOUR); +// +// // middle of the second business period +// day1 = DateTimeUtils.parseInstant("2017-01-23T08:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2017-01-23T14:00:00.000000000 JP"); +// assertEquals(JPOSE.diffBusinessNanos(day1, day2), 4 * DateTimeUtils.HOUR); +// +// // weekend non business +// day1 = DateTimeUtils.parseInstant("2017-01-21T01:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2017-01-23T01:00:00.000000000 NY"); +// assertEquals(USNYSE.diffBusinessDays(day1, day2), 0.0); +// +// // one business year +// day1 = DateTimeUtils.parseInstant("2016-01-01T01:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2016-12-31T23:59:00.000000000 NY"); +// double yearDiff = USNYSE.diffBusinessYears(day1, day2); +// assertTrue(yearDiff < 1.004); +// assertTrue(yearDiff > 0.996); +// yearDiff = JPOSE.diffBusinessYears(day1, day2); +// assertTrue(yearDiff < 1.004); +// assertTrue(yearDiff > 0.996); +// +// // half year +// day1 = DateTimeUtils.parseInstant("2017-01-01T01:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2017-07-02T01:00:00.000000000 NY"); +// yearDiff = USNYSE.diffBusinessYears(day1, day2); +// assertTrue(yearDiff < 0.503); +// assertTrue(yearDiff > 0.497); +// yearDiff = JPOSE.diffBusinessYears(day1, day2); +// assertTrue(yearDiff < 0.503); +// assertTrue(yearDiff > 0.497); +// +// +// day1 = null; +// assertEquals(USNYSE.diffBusinessYears(day1, day2), QueryConstants.NULL_DOUBLE); +// assertEquals(USNYSE.diffBusinessDays(day1, day2), QueryConstants.NULL_DOUBLE); +// assertEquals(USNYSE.diffBusinessNanos(day1, day2), QueryConstants.NULL_LONG); +// +// day1 = day2; +// assertEquals(USNYSE.diffBusinessYears(day1, day2), 0.0); +// assertEquals(USNYSE.diffBusinessDays(day1, day2), 0.0); +// assertEquals(USNYSE.diffBusinessNanos(day1, day2), 0); +// } +// +// public void testNonBusinessTimeDiff() { +// // USNYSE +// // standard business day +// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); +// Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); +// assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), 63000000000000L); // 17.5 hours +// assertEquals(USNYSE.diffNonBusinessNanos(day2, day1), -63000000000000L); // 17.5 hours +// +// // middle of a business period +// day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2017-01-23T12:30:00.000000000 NY"); +// assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), 0); +// +// // after a business period +// day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 NY"); +// day2 = DateTimeUtils.parseInstant("2017-01-23T16:15:00.000000000 NY"); +// assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), 15 * DateTimeUtils.MINUTE); +// +// // JPOSE +// // standard business day +// day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 JP"); +// assertEquals(JPOSE.diffNonBusinessNanos(day1, day2), 19 * DateTimeUtils.HOUR); // 17.5 hours +// +// // middle of a business period +// day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2017-01-23T11:30:00.000000000 JP"); +// assertEquals(JPOSE.diffNonBusinessNanos(day1, day2), 0); +// +// // after a business period +// day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2017-01-23T16:00:00.000000000 JP"); +// assertEquals(JPOSE.diffNonBusinessNanos(day1, day2), 2 * DateTimeUtils.HOUR); +// assertEquals(JPOSE.diffNonBusinessDays(day1, day2), +// ((double) (2 * DateTimeUtils.HOUR)) / (double) JPOSE.standardBusinessNanos()); +// +// +// +// day1 = null; +// assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), QueryConstants.NULL_LONG); +// +// day1 = day2; +// assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), 0); +// +// day1 = null; +// assertEquals(USNYSE.diffNonBusinessDays(day1, day2), QueryConstants.NULL_DOUBLE); +// } +// +// public void testBusinessDateRange() { +// // day light savings +// Instant startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); +// Instant endDate = DateTimeUtils.parseInstant("2017-03-14T01:00:00.000000000 NY"); +// +// String[] goodResults = new String[] { +// "2017-03-13", +// "2017-03-14" +// }; +// +// String[] results = USNYSE.businessDates(startDate, endDate); +// Arrays.sort(goodResults); +// Arrays.sort(results); +// boolean answer = Arrays.equals(goodResults, results); +// assertTrue(answer); +// +// assertEquals(new String[0], USNYSE.businessDates(endDate, startDate)); +// +// startDate = DateTimeUtils.parseInstant("2017-11-23T01:00:00.000000000 JP"); +// endDate = DateTimeUtils.parseInstant("2017-11-25T01:00:00.000000000 JP"); +// +// goodResults = new String[] { +// "2017-11-24" +// }; +// +// results = JPOSE.businessDates(startDate, endDate); +// Arrays.sort(goodResults); +// Arrays.sort(results); +// answer = Arrays.equals(goodResults, results); +// assertTrue(answer); +// +// startDate = null; +// assertEquals(JPOSE.businessDates(startDate, endDate).length, 0); +// +// // non business +// startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); +// endDate = DateTimeUtils.parseInstant("2017-03-14T01:00:00.000000000 NY"); +// +// goodResults = new String[] { +// "2017-03-11", +// "2017-03-12" +// }; +// +// results = USNYSE.nonBusinessDates(startDate, endDate); +// Arrays.sort(goodResults); +// Arrays.sort(results); +// answer = Arrays.equals(goodResults, results); +// assertTrue(answer); +// +// +// startDate = DateTimeUtils.parseInstant("2017-11-23T01:00:00.000000000 JP"); +// endDate = DateTimeUtils.parseInstant("2017-11-25T01:00:00.000000000 JP"); +// +// goodResults = new String[] { +// "2017-11-23", +// "2017-11-25" +// }; +// +// assertEquals(new String[0], USNYSE.nonBusinessDates(endDate, startDate)); +// results = JPOSE.nonBusinessDates(startDate, endDate); +// Arrays.sort(goodResults); +// Arrays.sort(results); +// answer = Arrays.equals(goodResults, results); +// assertTrue(answer); +// +// startDate = null; +// assertEquals(JPOSE.nonBusinessDates(startDate, endDate).length, 0); +// +// startDate = null; +// assertEquals(USNYSE.nonBusinessDates(startDate, endDate).length, 0); +// } +// +// public void testBusinessDateStringRange() { +// // USNYSE +// String startDate = "2014-02-16"; +// String endDate = "2014-03-05"; +// String[] goodResults = new String[] { +// "2014-02-18", "2014-02-19", "2014-02-20", "2014-02-21", +// "2014-02-24", "2014-02-25", "2014-02-26", "2014-02-27", "2014-02-28", +// "2014-03-03", "2014-03-04", "2014-03-05", +// }; +// +// assertEquals(new String[0], USNYSE.businessDates(endDate, startDate)); +// String[] results = USNYSE.businessDates(startDate, endDate); +// Arrays.sort(goodResults); +// Arrays.sort(results); +// boolean answer = Arrays.equals(goodResults, results); +// assertTrue(answer); +// +// startDate = null; +// assertEquals(USNYSE.businessDates(startDate, endDate).length, 0); +// +// startDate = endDate; +// assertEquals(USNYSE.businessDates(startDate, endDate).length, 1); +// +// // JPOSE +// startDate = "2018-01-01"; +// endDate = "2018-01-05"; +// goodResults = new String[] { +// "2018-01-04", +// "2018-01-05" +// }; +// +// results = JPOSE.businessDates(startDate, endDate); +// Arrays.sort(goodResults); +// Arrays.sort(results); +// answer = Arrays.equals(goodResults, results); +// assertTrue(answer); +// +// +// // non business +// startDate = "2020-01-01"; +// endDate = "2020-01-20"; +// goodResults = new String[] { +// "2020-01-01", "2020-01-04", "2020-01-05", "2020-01-11", "2020-01-12", +// "2020-01-18", "2020-01-19", "2020-01-20" +// }; +// +// assertEquals(new String[0], USNYSE.nonBusinessDates(endDate, startDate)); +// results = USNYSE.nonBusinessDates(startDate, endDate); +// Arrays.sort(goodResults); +// Arrays.sort(results); +// answer = Arrays.equals(goodResults, results); +// assertTrue(answer); +// +// +// // JPOSE +// startDate = "2018-01-01"; +// endDate = "2018-01-05"; +// goodResults = new String[] { +// "2018-01-01", +// "2018-01-02", +// "2018-01-03" +// }; +// +// results = JPOSE.nonBusinessDates(startDate, endDate); +// Arrays.sort(goodResults); +// Arrays.sort(results); +// answer = Arrays.equals(goodResults, results); +// assertTrue(answer); +// +// +// // null tests +// startDate = null; +// assertEquals(USNYSE.nonBusinessDates(startDate, endDate).length, 0); +// +// startDate = endDate = "2018-01-06"; +// assertEquals(USNYSE.nonBusinessDates(startDate, endDate).length, 1); +// +// // incorrectly formatted days +// try { +// USNYSE.nonBusinessDates("2018-09-31", "2018-010-31"); +// fail(); +// } catch (IllegalArgumentException e) { +// // ok +// } +// } +// +// public void testDayOfWeek() { +// assertEquals(DayOfWeek.WEDNESDAY, test.dayOfWeek()); +// +// String dateString = "2017-02-06"; +// assertEquals(USNYSE.dayOfWeek(dateString), DayOfWeek.MONDAY); +// assertEquals(JPOSE.dayOfWeek(dateString), DayOfWeek.MONDAY); +// +// Instant dateTime = DateTimeUtils.parseInstant("2017-09-01T00:00:00.000000000 NY"); +// assertEquals(USNYSE.dayOfWeek(dateTime), DayOfWeek.FRIDAY); +// assertEquals(JPOSE.dayOfWeek(dateTime), DayOfWeek.FRIDAY); +// +// dateString = null; +// dateTime = null; +// assertNull(USNYSE.dayOfWeek(dateString)); +// assertNull(USNYSE.dayOfWeek(dateTime)); +// +// // incorrectly formatted days +// try { +// USNYSE.dayOfWeek("2018-09-31"); +// fail(); +// } catch (DateTimeException e) { +// // ok +// } +// } +// +// public void testLastBusinessDayOfWeek() { +// assertFalse(test.isLastBusinessDayOfWeek()); +// +// String dateString = "2017-02-10"; +// Instant dateTime = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 NY"); +// assertTrue(USNYSE.isLastBusinessDayOfWeek(dateString)); +// assertFalse(USNYSE.isLastBusinessDayOfWeek(dateTime)); +// assertTrue(JPOSE.isLastBusinessDayOfWeek(dateString)); +// assertFalse(JPOSE.isLastBusinessDayOfWeek(dateTime)); +// +// dateString = null; +// assertFalse(USNYSE.isLastBusinessDayOfWeek(dateString)); +// } +// +// public void testLastBusinessDayOfMonth() { +// assertFalse(test.isLastBusinessDayOfMonth()); +// +// String dateString = "2017-02-28"; +// Instant dateTime = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 NY"); +// assertTrue(USNYSE.isLastBusinessDayOfMonth(dateString)); +// assertFalse(USNYSE.isLastBusinessDayOfMonth(dateTime)); +// assertTrue(JPOSE.isLastBusinessDayOfMonth(dateString)); +// assertFalse(JPOSE.isLastBusinessDayOfMonth(dateTime)); +// +// dateString = null; +// assertFalse(USNYSE.isLastBusinessDayOfMonth(dateString)); +// assertFalse(JPOSE.isLastBusinessDayOfMonth(dateString)); +// } +// +// public void testFractionOfBusinessDay() { +// assertEquals(1.0, test.fractionStandardBusinessDay()); +// +// +// // half day, USNYSE market open from 0930 to 1300 +// String dateString = "2018-11-23"; +// +// // full day +// Instant dateTime = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 NY"); +// +// assertEquals(USNYSE.fractionStandardBusinessDay(dateString), 3.5 / 6.5); +// assertEquals(1.0, USNYSE.fractionStandardBusinessDay(dateTime)); +// +// // half day, JPOSE market open from 0930 to 1300 +// dateString = "2006-01-04"; +// +// assertEquals(JPOSE.fractionStandardBusinessDay(dateString), 0.5); +// assertEquals(1.0, JPOSE.fractionStandardBusinessDay(dateTime)); +// +// +// dateString = null; +// dateTime = null; +// assertEquals(JPOSE.fractionStandardBusinessDay(dateString), 0.0); +// assertEquals(JPOSE.fractionStandardBusinessDay(dateTime), 0.0); +// } +// +// public void testFractionOfBusinessDayLeft() { +// // half day, market open from 0930 to 1300 +// Instant day1 = DateTimeUtils.parseInstant("2018-11-23T10:00:00.000000000 NY"); +// +// // full day +// Instant day2 = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 NY"); +// +// // holiday +// Instant day3 = DateTimeUtils.parseInstant("2017-07-04T00:00:00.000000000 NY"); +// +// assertEquals(USNYSE.fractionBusinessDayRemaining(day1), 3.0 / 3.5); +// assertEquals(USNYSE.fractionBusinessDayComplete(day1), 0.5 / 3.5, 0.0000001); +// assertEquals(USNYSE.fractionBusinessDayRemaining(day2), 1.0); +// assertEquals(USNYSE.fractionBusinessDayComplete(day2), 0.0); +// assertEquals(USNYSE.fractionBusinessDayRemaining(day3), 0.0); +// +// // half day, market open from 0900 to 1130 +// day1 = DateTimeUtils.parseInstant("2006-01-04T10:00:00.000000000 JP"); +// day2 = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 JP"); +// assertEquals(JPOSE.fractionBusinessDayRemaining(day1), 1.5 / 2.5); +// assertEquals(JPOSE.fractionBusinessDayComplete(day1), 1.0 / 2.5); +// assertEquals(JPOSE.fractionBusinessDayRemaining(day2), 1.0); +// assertEquals(JPOSE.fractionBusinessDayComplete(day2), 0.0); +// +// +// assertEquals(JPOSE.fractionOfBusinessDayRemaining(null), QueryConstants.NULL_DOUBLE); +// assertEquals(JPOSE.fractionOfBusinessDayComplete(null), QueryConstants.NULL_DOUBLE); +// } +// +// public void testCurrentBusinessSchedule() { +// assertEquals(test.nextBusinessSchedule("2017-09-26"), test.businessSchedule()); +// } +// +// public void testMidnightClose() { +// assertEquals(DateTimeUtils.DAY, UTC.standardBusinessNanos()); +// assertEquals("2019-04-16", UTC.futureDate("2019-04-15")); +// assertEquals("2019-04-16", UTC.futureBusinessDate("2019-04-15")); +// assertEquals("2019-04-18", UTC.futureBusinessDate("2019-04-15", 3)); +// assertEquals("2019-08-19", +// UTC.futureBusinessDate(DateTimeUtils.parseInstant("2019-08-18T00:00:00.000000000 UTC"))); +// +// assertEquals("2019-05-16", DateTimeUtils.formatDate(UTC.businessSchedule("2019-05-16").businessStart(), TZ_UTC)); +// assertEquals("2019-05-17", DateTimeUtils.formatDate(UTC.businessSchedule("2019-05-16").businessEnd(), TZ_UTC)); +// } +} From c50eb371b114c2c654a06b135bbfb7a0035f63f1 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Wed, 12 Jul 2023 10:28:19 -0600 Subject: [PATCH 038/150] Unit test: * BusinessCalendar - Schedule --- .../io/deephaven/time/calendar/TestCalendar.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java index e4b41c3f768..7a6255b7b4e 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java @@ -9,10 +9,17 @@ import java.time.ZonedDateTime; public class TestCalendar extends BaseArrayTestCase { - private final String name = "TEST CALENDAR"; - private final String description = "This is a test"; - private final ZoneId timeZone = ZoneId.of("America/Los_Angeles"); - private final Calendar calendar = new Calendar(name, description, timeZone); + protected final String name = "TEST CALENDAR"; + protected final String description = "This is a test"; + protected final ZoneId timeZone = ZoneId.of("America/Los_Angeles"); + + protected Calendar calendar; + + @Override + protected void setUp() throws Exception { + super.setUp(); + calendar = new Calendar(name, description, timeZone); + } public void testGetters(){ assertEquals(name, calendar.name()); From d8756921881451e56070f71cbe80b0e9c7d135a2 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Wed, 12 Jul 2023 10:54:29 -0600 Subject: [PATCH 039/150] Unit test: * BusinessCalendar - Business Day --- .../time/calendar/TestBusinessCalendar.java | 340 +++- .../calendar/TestDefaultBusinessCalendar.java | 1635 ----------------- 2 files changed, 339 insertions(+), 1636 deletions(-) delete mode 100644 engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java index 5f9265d8cb4..5c9a0027fb5 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java @@ -88,7 +88,6 @@ public void testBusinessSchedule() { // Current date assertEquals(bCalendar.businessSchedule(bCalendar.currentDate()), bCalendar.businessSchedule()); - // Check that all dates in the range work for(LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { assertNotNull(bCalendar.businessSchedule(d)); @@ -131,6 +130,345 @@ public void testBusinessSchedule() { } } + public void testIsBusinessDay() { + assertFalse(bCalendar.isBusinessDay(holidayDate1)); + assertFalse(bCalendar.isBusinessDay(holidayDate2)); + assertTrue(bCalendar.isBusinessDay(halfDayDate)); + + // TUES - Weekday + LocalDate date = LocalDate.of(2023,7,11); + assertTrue(bCalendar.isBusinessDay(date)); + assertTrue(bCalendar.isBusinessDay(date.toString())); + assertTrue(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone))); + assertTrue(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // WED - Weekend + date = LocalDate.of(2023,7,12); + assertFalse(bCalendar.isBusinessDay(date)); + assertFalse(bCalendar.isBusinessDay(date.toString())); + assertFalse(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone))); + assertFalse(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // THURS - Weekend + date = LocalDate.of(2023,7,13); + assertFalse(bCalendar.isBusinessDay(date)); + assertFalse(bCalendar.isBusinessDay(date.toString())); + assertFalse(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone))); + assertFalse(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // FRI - Weekday + date = LocalDate.of(2023,7,14); + assertTrue(bCalendar.isBusinessDay(date)); + assertTrue(bCalendar.isBusinessDay(date.toString())); + assertTrue(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone))); + assertTrue(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // Current date + assertEquals(bCalendar.isBusinessDay(bCalendar.currentDate()), bCalendar.isBusinessDay()); + + // DayOfWeek + + for (DayOfWeek dow : DayOfWeek.values()){ + assertEquals(!weekendDays.contains(dow), bCalendar.isBusinessDay(dow)); + } + + // Check that all dates in the range work + for(LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { + bCalendar.isBusinessDay(d); + } + + try{ + bCalendar.isBusinessDay(firstValidDate.minusDays(1)); + fail("should throw an exception"); + } catch (BusinessCalendar.InvalidDateException ignored){ + } + + try{ + bCalendar.isBusinessDay(lastValidDate.plusDays(1)); + fail("should throw an exception"); + } catch (BusinessCalendar.InvalidDateException ignored){ + } + + try{ + bCalendar.isBusinessDay((LocalDate) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.isBusinessDay((String) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.isBusinessDay((ZonedDateTime) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.isBusinessDay((Instant) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.isBusinessDay((DayOfWeek) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + } + + public void testIsLastBusinessDayOfMonth() { + LocalDate date = LocalDate.of(2023,7,31); + assertTrue(bCalendar.isLastBusinessDayOfMonth(date)); + assertTrue(bCalendar.isLastBusinessDayOfMonth(date.toString())); + assertTrue(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone))); + assertTrue(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // THURS - Weekend + date = LocalDate.of(2023,8,31); + assertFalse(bCalendar.isLastBusinessDayOfMonth(date)); + assertFalse(bCalendar.isLastBusinessDayOfMonth(date.toString())); + assertFalse(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone))); + assertFalse(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // WED - Weekend + date = LocalDate.of(2023,8,30); + assertFalse(bCalendar.isLastBusinessDayOfMonth(date)); + assertFalse(bCalendar.isLastBusinessDayOfMonth(date.toString())); + assertFalse(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone))); + assertFalse(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // TUES - Weekday + date = LocalDate.of(2023,8,29); + assertTrue(bCalendar.isLastBusinessDayOfMonth(date)); + assertTrue(bCalendar.isLastBusinessDayOfMonth(date.toString())); + assertTrue(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone))); + assertTrue(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // Current date + assertEquals(bCalendar.isLastBusinessDayOfMonth(bCalendar.currentDate()), bCalendar.isLastBusinessDayOfMonth()); + + // Check that all dates in the range work + for(LocalDate d = firstValidDate; d.isBefore(lastValidDate); d = d.plusDays(1)) { + bCalendar.isLastBusinessDayOfMonth(d); + } + + try{ + bCalendar.isLastBusinessDayOfMonth(firstValidDate.minusDays(1)); + fail("should throw an exception"); + } catch (BusinessCalendar.InvalidDateException ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfMonth(lastValidDate.plusDays(1)); + fail("should throw an exception"); + } catch (BusinessCalendar.InvalidDateException ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfMonth((LocalDate) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfMonth((String) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfMonth((ZonedDateTime) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfMonth((Instant) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + } + + public void testIsLastBusinessDayOfWeek() { + // FRI + LocalDate date = LocalDate.of(2023,7,28); + assertFalse(bCalendar.isLastBusinessDayOfWeek(date)); + assertFalse(bCalendar.isLastBusinessDayOfWeek(date.toString())); + assertFalse(bCalendar.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone))); + assertFalse(bCalendar.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // SAT + date = LocalDate.of(2023,7,29); + assertFalse(bCalendar.isLastBusinessDayOfWeek(date)); + assertFalse(bCalendar.isLastBusinessDayOfWeek(date.toString())); + assertFalse(bCalendar.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone))); + assertFalse(bCalendar.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // SUN + date = LocalDate.of(2023,7,30); + assertTrue(bCalendar.isLastBusinessDayOfWeek(date)); + assertTrue(bCalendar.isLastBusinessDayOfWeek(date.toString())); + assertTrue(bCalendar.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone))); + assertTrue(bCalendar.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + final Set wd = Set.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY); + final BusinessCalendar bc = new BusinessCalendar(name, description, timeZone, firstValidDate, lastValidDate, schedule, wd, holidays); + + // FRI + date = LocalDate.of(2023,7,28); + assertTrue(bc.isLastBusinessDayOfWeek(date)); + assertTrue(bc.isLastBusinessDayOfWeek(date.toString())); + assertTrue(bc.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone))); + assertTrue(bc.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // SAT + date = LocalDate.of(2023,7,29); + assertFalse(bc.isLastBusinessDayOfWeek(date)); + assertFalse(bc.isLastBusinessDayOfWeek(date.toString())); + assertFalse(bc.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone))); + assertFalse(bc.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // SUN + date = LocalDate.of(2023,7,30); + assertFalse(bc.isLastBusinessDayOfWeek(date)); + assertFalse(bc.isLastBusinessDayOfWeek(date.toString())); + assertFalse(bc.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone))); + assertFalse(bc.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // Current date + assertEquals(bCalendar.isLastBusinessDayOfWeek(bCalendar.currentDate()), bCalendar.isLastBusinessDayOfWeek()); + + // Check that all dates in the range work + for(LocalDate d = firstValidDate; d.isBefore(lastValidDate); d = d.plusDays(1)) { + bCalendar.isLastBusinessDayOfWeek(d); + } + + try{ + bCalendar.isLastBusinessDayOfWeek(firstValidDate.minusDays(1)); + fail("should throw an exception"); + } catch (BusinessCalendar.InvalidDateException ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfWeek(lastValidDate.plusDays(1)); + fail("should throw an exception"); + } catch (BusinessCalendar.InvalidDateException ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfWeek((LocalDate) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfWeek((String) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfWeek((ZonedDateTime) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfWeek((Instant) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + } + + public void testIsLastBusinessDayOfYear() { + LocalDate date = LocalDate.of(2023,12,29); + assertFalse(bCalendar.isLastBusinessDayOfYear(date)); + assertFalse(bCalendar.isLastBusinessDayOfYear(date.toString())); + assertFalse(bCalendar.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone))); + assertFalse(bCalendar.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + date = LocalDate.of(2023,12,30); + assertFalse(bCalendar.isLastBusinessDayOfYear(date)); + assertFalse(bCalendar.isLastBusinessDayOfYear(date.toString())); + assertFalse(bCalendar.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone))); + assertFalse(bCalendar.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + date = LocalDate.of(2023,12,31); + assertTrue(bCalendar.isLastBusinessDayOfYear(date)); + assertTrue(bCalendar.isLastBusinessDayOfYear(date.toString())); + assertTrue(bCalendar.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone))); + assertTrue(bCalendar.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + final Set wd = Set.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY); + final BusinessCalendar bc = new BusinessCalendar(name, description, timeZone, firstValidDate, lastValidDate, schedule, wd, holidays); + + date = LocalDate.of(2023,12,29); + assertTrue(bc.isLastBusinessDayOfYear(date)); + assertTrue(bc.isLastBusinessDayOfYear(date.toString())); + assertTrue(bc.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone))); + assertTrue(bc.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + date = LocalDate.of(2023,12,30); + assertFalse(bc.isLastBusinessDayOfYear(date)); + assertFalse(bc.isLastBusinessDayOfYear(date.toString())); + assertFalse(bc.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone))); + assertFalse(bc.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + date = LocalDate.of(2023,12,31); + assertFalse(bc.isLastBusinessDayOfYear(date)); + assertFalse(bc.isLastBusinessDayOfYear(date.toString())); + assertFalse(bc.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone))); + assertFalse(bc.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); + + // Current date + assertEquals(bCalendar.isLastBusinessDayOfYear(bCalendar.currentDate()), bCalendar.isLastBusinessDayOfYear()); + + // Check that all dates in the range work + for(LocalDate d = firstValidDate; d.isBefore(lastValidDate); d = d.plusDays(1)) { + bCalendar.isLastBusinessDayOfYear(d); + } + + try{ + bCalendar.isLastBusinessDayOfYear(firstValidDate.minusDays(1)); + fail("should throw an exception"); + } catch (BusinessCalendar.InvalidDateException ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfYear(lastValidDate.plusDays(1)); + fail("should throw an exception"); + } catch (BusinessCalendar.InvalidDateException ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfYear((LocalDate) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfYear((String) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfYear((ZonedDateTime) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + + try{ + bCalendar.isLastBusinessDayOfYear((Instant) null); + fail("should throw an exception"); + }catch (RequirementFailure ignored){ + } + } + public void testFail() { fail(); } diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java deleted file mode 100644 index 90a05200413..00000000000 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestDefaultBusinessCalendar.java +++ /dev/null @@ -1,1635 +0,0 @@ -/** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending - */ -package io.deephaven.time.calendar; - -import io.deephaven.base.testing.BaseArrayTestCase; -import io.deephaven.time.DateTimeUtils; -import io.deephaven.util.QueryConstants; - -import java.io.File; -import java.io.FileWriter; -import java.time.DateTimeException; -import java.time.DayOfWeek; -import java.time.Instant; -import java.time.ZoneId; -import java.util.Arrays; - -@SuppressWarnings("ConstantConditions") -public class TestDefaultBusinessCalendar extends BaseArrayTestCase { - - private static final ZoneId TZ_NY = ZoneId.of("America/New_York"); - private static final ZoneId TZ_JP = ZoneId.of("Asia/Tokyo"); - private static final ZoneId TZ_UTC = ZoneId.of("UTC"); - - private final BusinessCalendar USNYSE = Calendars.calendar("USNYSE"); - private final BusinessCalendar JPOSE = Calendars.calendar("JPOSE"); - private final BusinessCalendar UTC = Calendars.calendar("UTC"); - - private final String curDay = "2017-09-27"; - private File testCal; - private BusinessCalendar test; - - @Override - public void setUp() throws Exception { - super.setUp(); - testCal = File.createTempFile("Test", ".calendar"); - final FileWriter fw = new FileWriter(testCal); - fw.write("\n" + - "\n" + - "\n" + - " TEST\n" + - " NY\n" + - " en\n" + - " US\n" + - " \n" + - " 09:30,16:00\n" + - " Saturday\n" + - " Sunday\n" + - " \n" + - ""); - fw.flush(); - fw.close(); - - - - test = new DefaultBusinessCalendar(DefaultBusinessCalendar.constructCalendarElements(testCal)) { - @Override - public String currentDay() { - return curDay; - } - }; - } - - @Override - public void tearDown() throws Exception { - assertTrue(testCal.delete()); - super.tearDown(); - } - - public void testName() { - Calendar cal = Calendars.calendar("USNYSE"); - assertEquals(cal.name(), "USNYSE"); - } - - public void testNextDay() { - assertEquals("2017-09-28", test.futureDate()); - assertEquals("2017-09-29", test.futureDate(2)); - assertEquals("2017-10-11", test.futureDate(14)); - - Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - String day2 = "2016-09-02"; - assertEquals(USNYSE.futureDate(day1, 2), day2); - assertEquals(JPOSE.futureDate(day1, 2), day2); - assertEquals(USNYSE.futureDate(day2, -2), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.futureDate(day2, -2), DateTimeUtils.formatDate(day1, TZ_JP)); - - assertEquals(USNYSE.futureDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.futureDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_JP)); - - // leap day - day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); - day2 = "2016-02-29"; - assertEquals(USNYSE.futureDate(day1), day2); - assertEquals(JPOSE.futureDate(day1), day2); - - // new year - day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); - day2 = "2014-01-05"; - assertEquals(USNYSE.futureDate(day1, 5), day2); - assertEquals(JPOSE.futureDate(day1, 5), day2); - assertEquals(USNYSE.futureDate(day2, -5), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.futureDate(day2, -5), DateTimeUtils.formatDate(day1, TZ_JP)); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); - day2 = "2017-03-13"; - assertEquals(USNYSE.futureDate(day1), day2); - assertEquals(JPOSE.futureDate(day1), day2); - - // outside calendar range - day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); - day2 = "2070-01-01"; - assertEquals(USNYSE.futureDate(day1), day2); - assertEquals(JPOSE.futureDate(day1), day2); - - day1 = null; - assertNull(USNYSE.futureDate(day1)); - assertNull(JPOSE.futureDate(day1)); - } - - public void testNextDayString() { - String day1 = "2016-08-31"; - String day2 = "2016-09-04"; - assertEquals(USNYSE.futureDate(day1, 4), day2); - assertEquals(JPOSE.futureDate(day1, 4), day2); - assertEquals(USNYSE.futureDate(day2, -4), day1); - assertEquals(JPOSE.futureDate(day2, -4), day1); - - assertEquals(USNYSE.futureDate(day1, 0), day1); - assertEquals(JPOSE.futureDate(day1, 0), day1); - - // leap day - day1 = "2016-02-28"; - day2 = "2016-02-29"; - assertEquals(USNYSE.futureDate(day1), day2); - assertEquals(JPOSE.futureDate(day1), day2); - - // new year - day1 = "2013-12-31"; - day2 = "2014-01-01"; - assertEquals(USNYSE.futureDate(day1), day2); - assertEquals(JPOSE.futureDate(day1), day2); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-12"; - day2 = "2017-03-15"; - assertEquals(USNYSE.futureDate(day1, 3), day2); - assertEquals(JPOSE.futureDate(day1, 3), day2); - assertEquals(USNYSE.futureDate(day2, -3), day1); - assertEquals(JPOSE.futureDate(day2, -3), day1); - - day1 = null; - assertNull(USNYSE.futureDate(day1)); - assertNull(JPOSE.futureDate(day1)); - - - day1 = "2014-03-10"; - day2 = "2017-03-13"; - assertEquals(USNYSE.futureDate(day1, 1099), day2); - - // incorrectly formatted days - try { - USNYSE.futureDate("2018-02-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - try { - USNYSE.futureDate("20193-02-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testPreviousDay() { - assertEquals("2017-09-26", test.pastDate()); - assertEquals("2017-09-25", test.pastDate(2)); - assertEquals("2017-09-13", test.pastDate(14)); - - Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); - assertEquals(USNYSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); - - assertEquals(USNYSE.pastDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.pastDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_JP)); - - // leap day - day1 = DateTimeUtils.parseInstant("2016-02-29T01:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 NY"); - assertEquals(USNYSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); - - // new year - day1 = DateTimeUtils.parseInstant("2013-12-29T01:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2014-01-01T01:00:00.000000000 NY"); - assertEquals(USNYSE.pastDate(day2, 3), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.pastDate(day2, 3), DateTimeUtils.formatDate(day1, TZ_JP)); - assertEquals(USNYSE.pastDate(day1, -3), DateTimeUtils.formatDate(day2, TZ_NY)); - assertEquals(JPOSE.pastDate(day1, -3), DateTimeUtils.formatDate(day2, TZ_JP)); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 NY"); - assertEquals(USNYSE.pastDate(day2, 2), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(JPOSE.pastDate(day2, 2), DateTimeUtils.formatDate(day1, TZ_JP)); - assertEquals(USNYSE.pastDate(day1, -2), DateTimeUtils.formatDate(day2, TZ_NY)); - assertEquals(JPOSE.pastDate(day1, -2), DateTimeUtils.formatDate(day2, TZ_JP)); - - day1 = null; - assertNull(USNYSE.pastDate(day1)); - assertNull(JPOSE.pastDate(day1)); - } - - public void testPreviousDayString() { - String day1 = "2016-08-30"; - String day2 = "2016-09-01"; - assertEquals(USNYSE.pastDate(day2, 2), day1); - assertEquals(JPOSE.pastDate(day2, 2), day1); - assertEquals(USNYSE.pastDate(day1, -2), day2); - assertEquals(JPOSE.pastDate(day1, -2), day2); - - assertEquals(USNYSE.pastDate(day1, 0), day1); - assertEquals(JPOSE.pastDate(day1, 0), day1); - - // leap day - day1 = "2016-02-29"; - day2 = "2016-03-01"; - assertEquals(USNYSE.pastDate(day2), day1); - assertEquals(JPOSE.pastDate(day2), day1); - - // new year - day1 = "2013-12-31"; - day2 = "2014-01-01"; - assertEquals(USNYSE.pastDate(day2), day1); - assertEquals(JPOSE.pastDate(day2), day1); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-10"; - day2 = "2017-03-13"; - assertEquals(USNYSE.pastDate(day2, 3), day1); - assertEquals(JPOSE.pastDate(day2, 3), day1); - assertEquals(USNYSE.pastDate(day1, -3), day2); - assertEquals(JPOSE.pastDate(day1, -3), day2); - - day1 = null; - assertNull(USNYSE.pastDate(day1)); - assertNull(JPOSE.pastDate(day1)); - - day1 = "2014-03-10"; - day2 = "2017-03-13"; - assertEquals(USNYSE.pastDate(day2, 1099), day1); - - // incorrectly formatted days - try { - USNYSE.pastDate("2018-02-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - try { - USNYSE.pastDate("20193-02-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testDateRange() { - // day light savings - Instant startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); - Instant endDate = DateTimeUtils.parseInstant("2017-03-14T01:00:00.000000000 NY"); - - String[] goodResults = new String[] { - "2017-03-11", - "2017-03-12", - "2017-03-13", - "2017-03-14" - }; - - String[] results = USNYSE.calendarDates(startDate, endDate); - Arrays.sort(goodResults); - Arrays.sort(results); - boolean answer = Arrays.equals(goodResults, results); - assertTrue(answer); - - - startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 JP"); - endDate = DateTimeUtils.parseInstant("2017-03-14T01:00:00.000000000 JP"); - results = JPOSE.calendarDates(startDate, endDate); - Arrays.sort(goodResults); - Arrays.sort(results); - answer = Arrays.equals(goodResults, results); - assertTrue(answer); - - - startDate = null; - assertEquals(USNYSE.calendarDates(startDate, endDate).length, 0); - assertEquals(JPOSE.calendarDates(startDate, endDate).length, 0); - } - - public void testDateStringRange() { - String startDate = "2014-02-18"; - String endDate = "2014-03-05"; - String[] goodResults = new String[] { - "2014-02-18", "2014-02-19", "2014-02-20", "2014-02-21", "2014-02-22", "2014-02-23", - "2014-02-24", "2014-02-25", "2014-02-26", "2014-02-27", "2014-02-28", - "2014-03-01", "2014-03-02", "2014-03-03", "2014-03-04", "2014-03-05" - }; - - String[] results = USNYSE.calendarDates(startDate, endDate); - Arrays.sort(goodResults); - Arrays.sort(results); - boolean answer = Arrays.equals(goodResults, results); - assertTrue(answer); - - results = JPOSE.calendarDates(startDate, endDate); - Arrays.sort(goodResults); - Arrays.sort(results); - answer = Arrays.equals(goodResults, results); - assertTrue(answer); - - startDate = "2020-01-01"; - endDate = "2020-01-20"; - - results = USNYSE.calendarDates(startDate, endDate); - assertEquals(results.length, 20); - - results = JPOSE.calendarDates(startDate, endDate); - assertEquals(results.length, 20); - - startDate = null; - assertEquals(USNYSE.calendarDates(startDate, endDate).length, 0); - assertEquals(JPOSE.calendarDates(startDate, endDate).length, 0); - - - // incorrectly formatted days - assertEquals(new String[0], USNYSE.calendarDates("2018-02-31", "2019-02-31")); - } - - public void testNumberOfDays() { - Instant startDate = DateTimeUtils.parseInstant("2014-02-18T01:00:00.000000000 NY"); - Instant endDate = DateTimeUtils.parseInstant("2014-03-05T01:00:00.000000000 NY"); - - assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 15); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 11); - assertEquals(USNYSE.numberBusinessDates(startDate, endDate, false), 11); - assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 12); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 4); - assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, false), 4); - assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 4); - - - startDate = DateTimeUtils.parseInstant("2020-01-01T01:00:00.000000000 NY"); - endDate = DateTimeUtils.parseInstant("2020-01-20T01:00:00.000000000 NY"); - - assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 19); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 12); - assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 12); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 7); - assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 8); - - startDate = endDate; - assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 0); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 0); - assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 0); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 0); - assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 1); - - startDate = DateTimeUtils.parseInstant("2020-01-02T01:00:00.000000000 NY"); - endDate = startDate; - assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 0); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 0); - assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 1); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 0); - assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 0); - - startDate = null; - assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); - - startDate = DateTimeUtils.parseInstant("2014-02-18T01:00:00.000000000 NY"); - endDate = null; - assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); - - startDate = DateTimeUtils.parseInstant("2014-02-18T01:00:00.000000000 NY"); - endDate = DateTimeUtils.parseInstant("2017-02-18T01:00:00.000000000 NY"); - assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 1096); - assertEquals(USNYSE.numberCalendarDates(startDate, endDate, true), 1097); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 758); - assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 758); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 338); - assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 339); - } - - public void testNumberOfDaysString() { - String startDate = "2014-02-18"; - String endDate = "2014-03-05"; - - assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 15); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 11); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 4); - - assertEquals(USNYSE.numberCalendarDates(startDate, endDate, false), 15); - assertEquals(USNYSE.numberBusinessDates(startDate, endDate, false), 11); - assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, false), 4); - - assertEquals(USNYSE.numberCalendarDates(startDate, endDate, true), 16); - assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 12); - assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 4); - - assertEquals(USNYSE.numberCalendarDates(endDate, startDate), -15); - assertEquals(USNYSE.numberOfBusinessDays(endDate, startDate), -11); - assertEquals(USNYSE.numberOfNonBusinessDays(endDate, startDate), -4); - - assertEquals(USNYSE.numberCalendarDates(endDate, startDate, false), -15); - assertEquals(USNYSE.numberBusinessDates(endDate, startDate, false), -11); - assertEquals(USNYSE.numberNonBusinessDates(endDate, startDate, false), -4); - - assertEquals(USNYSE.numberCalendarDates(endDate, startDate, true), -16); - assertEquals(USNYSE.numberBusinessDates(endDate, startDate, true), -12); - assertEquals(USNYSE.numberNonBusinessDates(endDate, startDate, true), -4); - - endDate = startDate; - - assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 0); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 0); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 0); - - - startDate = "2020-01-01"; - endDate = "2020-01-20"; - - assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 19); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 12); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 7); - - startDate = null; - assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); - - startDate = "2014-02-18"; - endDate = null; - assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); - - - - startDate = "2014-02-18"; - endDate = "2017-02-18"; - assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 1096); - assertEquals(USNYSE.numberCalendarDates(startDate, endDate, true), 1097); - assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 758); - assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 758); - assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 338); - assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 339); - - - // incorrectly formatted days - try { - USNYSE.numberCalendarDates("2018-02-31", "2019-02-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testIsBusinessDay() { - assertTrue(test.isBusinessDay()); - - Instant businessDay = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - Instant halfDay = DateTimeUtils.parseInstant("2014-07-03T01:00:00.000000000 NY"); - Instant holiday = DateTimeUtils.parseInstant("2002-01-01T01:00:00.000000000 NY"); - Instant holiday2 = DateTimeUtils.parseInstant("2002-01-21T01:00:00.000000000 NY"); - - assertTrue(USNYSE.isBusinessDay(businessDay)); - assertTrue(USNYSE.isBusinessDay(halfDay)); - assertFalse(USNYSE.isBusinessDay(holiday)); - assertFalse(USNYSE.isBusinessDay(holiday2)); - - businessDay = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); - halfDay = DateTimeUtils.parseInstant("2006-01-04T01:00:00.000000000 JP"); - holiday = DateTimeUtils.parseInstant("2006-01-02T01:00:00.000000000 JP"); - holiday2 = DateTimeUtils.parseInstant("2007-12-23T01:00:00.000000000 JP"); - - assertTrue(JPOSE.isBusinessDay(businessDay)); - assertTrue(JPOSE.isBusinessDay(halfDay)); - assertFalse(JPOSE.isBusinessDay(holiday)); - assertFalse(JPOSE.isBusinessDay(holiday2)); - - - businessDay = null; - // noinspection ConstantConditions - assertFalse(USNYSE.isBusinessDay(businessDay)); - // noinspection ConstantConditions - assertFalse(JPOSE.isBusinessDay(businessDay)); - } - - public void testIsBusinessTime() { - Instant businessDayNotTime = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - Instant halfDayTime = DateTimeUtils.parseInstant("2014-07-03T12:00:00.000000000 NY"); - Instant holiday = DateTimeUtils.parseInstant("2002-01-01T01:00:00.000000000 NY"); - Instant holiday2 = DateTimeUtils.parseInstant("2002-01-21T01:00:00.000000000 NY"); - - assertFalse(USNYSE.isBusinessTime(businessDayNotTime)); - assertTrue(USNYSE.isBusinessTime(halfDayTime)); - assertFalse(USNYSE.isBusinessTime(holiday)); - assertFalse(USNYSE.isBusinessTime(holiday2)); - - Instant businessDayTime = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); - halfDayTime = DateTimeUtils.parseInstant("2006-01-04T11:00:00.000000000 JP"); - holiday = DateTimeUtils.parseInstant("2006-01-02T01:00:00.000000000 JP"); - holiday2 = DateTimeUtils.parseInstant("2007-12-23T01:00:00.000000000 JP"); - - assertFalse(JPOSE.isBusinessTime(businessDayTime)); - assertTrue(JPOSE.isBusinessTime(halfDayTime)); - assertFalse(JPOSE.isBusinessTime(holiday)); - assertFalse(JPOSE.isBusinessTime(holiday2)); - - - holiday = null; - // noinspection ConstantConditions - assertFalse(USNYSE.isBusinessTime(holiday)); - // noinspection ConstantConditions - assertFalse(JPOSE.isBusinessTime(holiday)); - } - - public void testIsBusinessDayString() { - String businessDay = "2016-08-31"; - String halfDay = "2014-07-03"; - String holiday = "2002-01-01"; - String holiday2 = "2002-01-21"; - - assertTrue(USNYSE.isBusinessDay(businessDay)); - assertTrue(USNYSE.isBusinessDay(halfDay)); - assertFalse(USNYSE.isBusinessDay(holiday)); - assertFalse(USNYSE.isBusinessDay(holiday2)); - - businessDay = "2016-08-31"; - halfDay = "2006-01-04"; - holiday = "2007-09-17"; - holiday2 = "2006-02-11"; - - assertTrue(JPOSE.isBusinessDay(businessDay)); - assertTrue(JPOSE.isBusinessDay(halfDay)); - assertFalse(JPOSE.isBusinessDay(holiday)); - assertFalse(JPOSE.isBusinessDay(holiday2)); - - businessDay = null; - assertFalse(JPOSE.isBusinessDay(businessDay)); - assertFalse(JPOSE.isBusinessDay(businessDay)); - - - // incorrectly formatted days - try { - USNYSE.isBusinessDay("2018-09-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testNextBusinessDay() { - assertEquals("2017-09-28", test.futureBusinessDate()); - assertEquals("2017-09-29", test.futureBusinessDate(2)); - assertEquals("2017-10-17", test.futureBusinessDate(14)); - - Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - Instant day1JP = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); - String day2 = "2016-09-01"; - assertNull(USNYSE.futureBusinessDate((Instant) null)); - assertEquals(USNYSE.futureBusinessDate(day1), day2); - assertEquals(JPOSE.futureBusinessDate(day1JP), day2); - - assertNull(USNYSE.futureBusinessDate((Instant) null, 2)); - assertEquals(USNYSE.futureBusinessDate(day1, 2), "2016-09-02"); - assertEquals(JPOSE.futureBusinessDate(day1JP, 2), "2016-09-02"); - - assertEquals(USNYSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 NY"), -2), - "2016-08-31"); - assertEquals(JPOSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 JP"), -2), - "2016-08-31"); - - assertEquals(USNYSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"), 0), - "2016-08-30"); - assertNull(USNYSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-08-28T01:00:00.000000000 NY"), 0)); - - // leap day - day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 JP"); - day2 = "2016-02-29"; - assertEquals(USNYSE.futureBusinessDate(day1), day2); - assertEquals(JPOSE.futureBusinessDate(day1JP), day2); - - // new year - day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 JP"); - day2 = "2014-01-02"; - assertEquals(USNYSE.futureBusinessDate(day1), day2); - - day2 = "2014-01-01"; - assertEquals(JPOSE.futureBusinessDate(day1JP), day2); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - // Japan doesn't observe day light savings - day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); - day2 = "2017-03-13"; - assertEquals(USNYSE.futureBusinessDate(day1), day2); - assertEquals(JPOSE.futureBusinessDate(day1JP), day2); - - // outside calendar range, so no day off for new years, but weekend should still be off - day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 JP"); - day2 = "2070-01-01"; - assertEquals(USNYSE.futureBusinessDate(day1).compareTo(day2), 0); - assertEquals(JPOSE.futureBusinessDate(day1JP), day2); - - day1 = DateTimeUtils.parseInstant("2070-01-03T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2070-01-03T01:00:00.000000000 JP"); - day2 = "2070-01-06"; - assertEquals(USNYSE.futureBusinessDate(day1), day2); - assertEquals(JPOSE.futureBusinessDate(day1JP), day2); - - day1 = null; - assertNull(USNYSE.futureBusinessDate(day1)); - assertNull(JPOSE.futureBusinessDate(day1)); - } - - public void testNextBusinessDayString() { - String day1 = "2016-08-31"; - String day2 = "2016-09-01"; - assertNull(USNYSE.futureBusinessDate((String) null)); - assertEquals(USNYSE.futureBusinessDate(day1), day2); - assertEquals(JPOSE.futureBusinessDate(day1), day2); - - assertNull(USNYSE.futureBusinessDate((String) null, 2)); - assertEquals(USNYSE.futureBusinessDate(day1, 2), "2016-09-02"); - assertEquals(JPOSE.futureBusinessDate(day1, 2), "2016-09-02"); - - assertEquals(USNYSE.futureBusinessDate("2016-09-02", -2), "2016-08-31"); - assertEquals(JPOSE.futureBusinessDate("2016-09-02", -2), "2016-08-31"); - - assertEquals(USNYSE.futureBusinessDate("2016-08-30", 0), "2016-08-30"); - assertNull(USNYSE.futureBusinessDate("2016-08-28", 0)); - - // leap day - day1 = "2016-02-28"; - day2 = "2016-02-29"; - assertEquals(USNYSE.futureBusinessDate(day1), day2); - assertEquals(JPOSE.futureBusinessDate(day1), day2); - - // new year - day1 = "2013-12-31"; - day2 = "2014-01-02"; - assertEquals(USNYSE.futureBusinessDate(day1), day2); - - day1 = "2007-01-01"; - day2 = "2007-01-04"; - assertEquals(JPOSE.futureBusinessDate(day1), day2); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-12"; - day2 = "2017-03-13"; - assertEquals(USNYSE.futureBusinessDate(day1), day2); - assertEquals(JPOSE.futureBusinessDate(day1), day2); - - day1 = null; - assertNull(USNYSE.futureBusinessDate(day1)); - assertNull(JPOSE.futureBusinessDate(day1)); - - // incorrectly formatted days - try { - USNYSE.futureBusinessDate("2018-09-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testNextBusinessSchedule() { - assertEquals(test.nextBusinessSchedule(curDay), test.nextBusinessSchedule()); - assertEquals(test.nextBusinessSchedule(curDay, 2), test.nextBusinessSchedule(2)); - - Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - Instant day1JP = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); - String day2 = "2016-09-01"; - assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); - assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); - - assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1, 2).getSOBD(), TZ_NY), "2016-09-02"); - assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP, 2).getSOBD(), TZ_JP), "2016-09-02"); - - assertEquals(DateTimeUtils.formatDate( - USNYSE.nextBusinessSchedule(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 NY"), -2) - .getSOBD(), - TZ_NY), "2016-08-31"); - assertEquals(DateTimeUtils.formatDate( - JPOSE.nextBusinessSchedule(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 JP"), -2) - .getSOBD(), - TZ_JP), "2016-08-31"); - - assertEquals(DateTimeUtils.formatDate( - USNYSE.nextBusinessSchedule(DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"), 0) - .getSOBD(), - TZ_NY), "2016-08-30"); - - // leap day - day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 JP"); - day2 = "2016-02-29"; - assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); - assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); - - // new year - day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 JP"); - day2 = "2014-01-03"; - assertEquals( - DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(USNYSE.futureBusinessDate(day1)).getSOBD(), TZ_NY), - day2); - - day2 = "2014-01-01"; - assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - // Japan doesn't observe day light savings - day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); - day2 = "2017-03-13"; - assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); - assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); - - // outside calendar range, so no day off for new years, but weekend should still be off - day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 JP"); - day2 = "2070-01-01"; - assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY).compareTo(day2), 0); - assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); - - day1 = DateTimeUtils.parseInstant("2070-01-05T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2070-01-05T01:00:00.000000000 JP"); - day2 = "2070-01-06"; - assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); - assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); - - day1 = null; - assertNull(USNYSE.nextBusinessSchedule(day1)); - assertNull(JPOSE.nextBusinessSchedule(day1)); - - - // holiday - final BusinessSchedule holiday = USNYSE.businessSchedule("2017-12-25"); - assertEquals(0, holiday.periods().length); - assertEquals(0, holiday.businessNanos()); - try { - // noinspection ResultOfMethodCallIgnored - holiday.businessEnd(); - fail("Expected an exception!"); - } catch (UnsupportedOperationException e) { - // pass - } - try { - // noinspection ResultOfMethodCallIgnored - holiday.businessStart(); - fail("Expected an exception!"); - } catch (UnsupportedOperationException e) { - // pass - } - } - - public void testNextBusinessScheduleString() { - String day1 = "2016-08-31"; - String day2 = "2016-09-01"; - assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); - assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1).getSOBD(), TZ_JP), day2); - - assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1, 2).getSOBD(), TZ_NY), "2016-09-02"); - assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1, 2).getSOBD(), TZ_JP), "2016-09-02"); - - assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule("2016-09-02", -2).getSOBD(), TZ_NY), - "2016-08-31"); - assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule("2016-09-02", -2).getSOBD(), TZ_JP), - "2016-08-31"); - - assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule("2016-08-30", 0).getSOBD(), TZ_NY), - "2016-08-30"); - assertNull(USNYSE.nextBusinessSchedule((String) null, 0)); - - // leap day - day1 = "2016-02-28"; - day2 = "2016-02-29"; - assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); - assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1).getSOBD(), TZ_JP), day2); - - // new year - day1 = "2014-01-01"; - day2 = "2014-01-02"; - assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); - - day1 = "2007-01-03"; - day2 = "2007-01-04"; - assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1).getSOBD(), TZ_JP), day2); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-12"; - day2 = "2017-03-13"; - assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); - assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1).getSOBD(), TZ_JP), day2); - - day1 = null; - assertNull(USNYSE.nextBusinessSchedule(day1)); - assertNull(JPOSE.nextBusinessSchedule(day1)); - } - - public void testNextNonBusinessDay() { - assertEquals("2017-09-30", test.futureNonBusinessDate()); - assertEquals("2017-10-01", test.futureNonBusinessDate(2)); - assertEquals("2017-10-08", test.futureNonBusinessDate(4)); - - Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - Instant day1JP = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); - String day2 = "2016-09-03"; - assertNull(USNYSE.futureNonBusinessDate((Instant) null)); - assertEquals(USNYSE.futureNonBusinessDate(day1), day2); - assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); - - assertNull(USNYSE.futureNonBusinessDate((Instant) null, 2)); - assertEquals(USNYSE.futureNonBusinessDate(day1, 2), "2016-09-04"); - assertEquals(JPOSE.futureNonBusinessDate(day1JP, 2), "2016-09-04"); - - assertEquals(USNYSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-09-04T01:00:00.000000000 NY"), -2), - "2016-08-28"); - assertEquals(JPOSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-09-04T01:00:00.000000000 JP"), -2), - "2016-08-28"); - - assertNull(USNYSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"), 0)); - assertEquals(USNYSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-08-28T01:00:00.000000000 NY"), 0), - "2016-08-28"); - - // leap day - day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 JP"); - day2 = "2016-03-05"; - assertEquals(USNYSE.futureNonBusinessDate(day1), day2); - assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); - - // new year - day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 JP"); - day2 = "2014-01-01"; - assertEquals(USNYSE.futureNonBusinessDate(day1), day2); - - day2 = "2014-01-04"; - assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); - day2 = "2017-03-18"; - assertEquals(USNYSE.futureNonBusinessDate(day1), day2); - assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); - - // outside calendar range, so no day off for new years, but weekend should still be off - day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); - day1JP = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 JP"); - day2 = "2070-01-04"; - assertEquals(USNYSE.futureNonBusinessDate(day1).compareTo(day2), 0); - assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); - - day1 = null; - assertNull(USNYSE.futureNonBusinessDate(day1)); - assertNull(JPOSE.futureNonBusinessDate(day1)); - } - - public void testNextNonBusinessDayString() { - String day1 = "2016-08-31"; - String day2 = "2016-09-03"; - assertNull(USNYSE.futureNonBusinessDate((String) null)); - assertEquals(USNYSE.futureNonBusinessDate(day1), day2); - assertEquals(JPOSE.futureNonBusinessDate(day1), day2); - - assertNull(USNYSE.futureNonBusinessDate((String) null, 2)); - assertEquals(USNYSE.futureNonBusinessDate(day1, 2), "2016-09-04"); - assertEquals(JPOSE.futureNonBusinessDate(day1, 2), "2016-09-04"); - - assertEquals(USNYSE.futureNonBusinessDate("2016-09-04", -2), "2016-08-28"); - assertEquals(JPOSE.futureNonBusinessDate("2016-09-04", -2), "2016-08-28"); - - assertNull(USNYSE.futureNonBusinessDate("2016-08-30", 0)); - assertEquals(USNYSE.futureNonBusinessDate("2016-08-28", 0), "2016-08-28"); - - // leap day - day1 = "2016-02-28"; - day2 = "2016-03-05"; - assertEquals(USNYSE.futureNonBusinessDate(day1), day2); - assertEquals(JPOSE.futureNonBusinessDate(day1), day2); - - // new year - day1 = "2013-12-31"; - day2 = "2014-01-01"; - assertEquals(USNYSE.futureNonBusinessDate(day1), day2); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-12"; - day2 = "2017-03-18"; - assertEquals(USNYSE.futureNonBusinessDate(day1), day2); - assertEquals(JPOSE.futureNonBusinessDate(day1), day2); - - day1 = null; - assertNull(USNYSE.futureNonBusinessDate(day1)); - assertNull(JPOSE.futureNonBusinessDate(day1)); - - // incorrectly formatted days - try { - USNYSE.futureNonBusinessDate("2018-09-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testLastBusinessDay() { - assertEquals("2017-09-26", test.pastBusinessDate()); - assertEquals("2017-09-25", test.pastBusinessDate(2)); - assertEquals("2017-09-07", test.pastBusinessDate(14)); - - assertEquals("2017-09-24", test.pastNonBusinessDate()); - assertEquals("2017-09-23", test.pastNonBusinessDate(2)); - assertEquals("2017-09-16", test.pastNonBusinessDate(4)); - - - Instant day1 = DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"); - Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); - assertNull(USNYSE.pastBusinessDate((Instant) null, 2)); - assertEquals(USNYSE.pastBusinessDate(day2, 2), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(USNYSE.pastBusinessDate(day1, -2), DateTimeUtils.formatDate(day2, TZ_NY)); - - assertEquals(USNYSE.pastBusinessDate(DateTimeUtils.parseInstant("2016-08-30T15:00:00.000000000 NY"), 0), - "2016-08-30"); - assertNull(USNYSE.pastBusinessDate(DateTimeUtils.parseInstant("2016-08-28T15:00:00.000000000 NY"), 0)); - - assertNull(USNYSE.pastNonBusinessDate((Instant) null, 0)); - assertNull(USNYSE.pastNonBusinessDate(DateTimeUtils.parseInstant("2016-08-30T21:00:00.000000000 NY"), 0)); - assertEquals( - USNYSE.pastNonBusinessDate(DateTimeUtils.parseInstant("2016-08-28T21:00:00.000000000 NY"), 0), - "2016-08-28"); - - // leap day - day1 = DateTimeUtils.parseInstant("2016-02-29T21:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 NY"); - assertEquals(USNYSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); - - // new year - day1 = DateTimeUtils.parseInstant("2013-12-26T01:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2014-01-02T01:00:00.000000000 NY"); - assertEquals(USNYSE.pastBusinessDate(day2, 4), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(USNYSE.pastBusinessDate(day1, -4), DateTimeUtils.formatDate(day2, TZ_NY)); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = DateTimeUtils.parseInstant("2017-02-26T01:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 NY"); - assertEquals(USNYSE.pastNonBusinessDate(day2, 5), DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(USNYSE.pastNonBusinessDate(day1, -5), "2017-03-18"); - - day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 NY"); - assertEquals(USNYSE.pastNonBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); - - day1 = DateTimeUtils.parseInstant("2017-07-04T01:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2017-07-07T01:00:00.000000000 NY"); - assertEquals(USNYSE.pastNonBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); - - day1 = null; - assertNull(USNYSE.pastBusinessDate(day1)); - assertNull(USNYSE.pastNonBusinessDate(day1)); - - - - day1 = DateTimeUtils.parseInstant("2016-08-31T21:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2016-09-01T21:00:00.000000000 JP"); - assertEquals(JPOSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); - - // leap day - day1 = DateTimeUtils.parseInstant("2016-02-29T01:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 JP"); - assertEquals(JPOSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); - - // new year - day1 = DateTimeUtils.parseInstant("2013-12-31T11:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2014-01-01T11:00:00.000000000 JP"); - assertEquals(JPOSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); - - // Daylight savings starts in JP (UTC-7:00) at 2 AM 2017-03-12 - day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 JP"); - assertEquals(JPOSE.pastNonBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); - - - day1 = null; - assertNull(JPOSE.pastBusinessDate(day1)); - assertNull(JPOSE.pastNonBusinessDate(day1)); - } - - public void testLastBusinessDayString() { - String day1 = "2016-08-31"; - String day2 = "2016-09-01"; - assertNull(USNYSE.pastBusinessDate((String) null)); - assertEquals(USNYSE.pastBusinessDate(day2), day1); - assertEquals(JPOSE.pastBusinessDate(day2), day1); - - assertNull(USNYSE.pastBusinessDate((String) null, 2)); - assertEquals(USNYSE.pastBusinessDate("2016-08-30", 0), "2016-08-30"); - assertNull(USNYSE.pastBusinessDate("2016-08-28", 0)); - - day1 = "2016-08-29"; - assertEquals(USNYSE.pastBusinessDate(day2, 3), day1); - assertEquals(JPOSE.pastBusinessDate(day2, 3), day1); - assertEquals(USNYSE.pastBusinessDate(day1, -3), day2); - assertEquals(JPOSE.pastBusinessDate(day1, -3), day2); - - // leap day - day1 = "2016-02-29"; - day2 = "2016-03-01"; - assertEquals(USNYSE.pastBusinessDate(day2), day1); - assertEquals(JPOSE.pastBusinessDate(day2), day1); - - // new year - day1 = "2013-12-30"; - day2 = "2014-01-01"; - assertEquals(USNYSE.pastBusinessDate(day2, 2), day1); - assertEquals(JPOSE.pastBusinessDate(day2, 2), day1); - assertEquals(USNYSE.pastBusinessDate(day1, -2), "2014-01-02"); - assertEquals(JPOSE.pastBusinessDate(day1, -2), day2); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-10"; - day2 = "2017-03-13"; - assertEquals(USNYSE.pastBusinessDate(day2), day1); - assertEquals(JPOSE.pastBusinessDate(day2), day1); - - day1 = null; - assertNull(USNYSE.pastBusinessDate(day1)); - assertNull(JPOSE.pastBusinessDate(day1)); - - // incorrectly formatted days - try { - USNYSE.pastBusinessDate("2018-09-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testLastBusinessSchedule() { - assertEquals(test.previousBusinessSchedule(curDay), test.previousBusinessSchedule()); - assertEquals(test.previousBusinessSchedule(curDay, 2), test.previousBusinessSchedule(2)); - - - Instant day1 = DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"); - Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); - assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2, 2).getSOBD(), TZ_NY), - DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day1, -2).getSOBD(), TZ_NY), - DateTimeUtils.formatDate(day2, TZ_NY)); - - assertEquals( - DateTimeUtils.formatDate(USNYSE - .previousBusinessSchedule(DateTimeUtils.parseInstant("2016-08-30T15:00:00.000000000 NY"), 0) - .getSOBD(), TZ_NY), - "2016-08-30"); - assertNull(USNYSE.previousBusinessSchedule((Instant) null, 0)); - - // leap day - day1 = DateTimeUtils.parseInstant("2016-02-29T21:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 NY"); - assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2).getSOBD(), TZ_NY), - DateTimeUtils.formatDate(day1, TZ_NY)); - - // new year - day1 = DateTimeUtils.parseInstant("2013-12-26T01:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2014-01-02T01:00:00.000000000 NY"); - assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2, 7).getSOBD(), TZ_NY), - DateTimeUtils.formatDate(day1, TZ_NY)); - assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day1, -7).getSOBD(), TZ_NY), - DateTimeUtils.formatDate(day2, TZ_NY)); - - day1 = null; - assertNull(USNYSE.previousBusinessSchedule(day1)); - - - day1 = DateTimeUtils.parseInstant("2016-08-31T21:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2016-09-01T21:00:00.000000000 JP"); - assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), - DateTimeUtils.formatDate(day1, TZ_JP)); - - // leap day - day1 = DateTimeUtils.parseInstant("2016-02-29T01:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 JP"); - assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), - DateTimeUtils.formatDate(day1, TZ_JP)); - - // new year - day1 = DateTimeUtils.parseInstant("2013-12-31T11:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2014-01-01T11:00:00.000000000 JP"); - assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), - DateTimeUtils.formatDate(day1, TZ_JP)); - - - day1 = null; - assertNull(JPOSE.previousBusinessSchedule(day1)); - } - - public void testLastBusinessScheduleString() { - String day1 = "2016-08-31"; - String day2 = "2016-09-01"; - assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2).getSOBD(), TZ_NY), day1); - assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), day1); - - assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule("2016-08-30", 0).getSOBD(), TZ_NY), - "2016-08-30"); - assertNull(USNYSE.previousBusinessSchedule((String) null, 0)); - - day1 = "2016-08-29"; - assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2, 3).getSOBD(), TZ_NY), day1); - assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2, 3).getSOBD(), TZ_JP), day1); - assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day1, -3).getSOBD(), TZ_NY), day2); - assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day1, -3).getSOBD(), TZ_JP), day2); - - // leap day - day1 = "2016-02-29"; - day2 = "2016-03-01"; - assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2).getSOBD(), TZ_NY), day1); - assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), day1); - - // new year - day1 = "2014-12-29"; - day2 = "2014-12-31"; - assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2, 2).getSOBD(), TZ_NY), day1); - assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2, 2).getSOBD(), TZ_JP), day1); - assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day1, -2).getSOBD(), TZ_NY), day2); - assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day1, -2).getSOBD(), TZ_JP), day2); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-10"; - day2 = "2017-03-13"; - assertEquals( - DateTimeUtils.formatDate( - USNYSE.previousBusinessSchedule(USNYSE.pastDate(USNYSE.pastDate(day2))).getSOBD(), TZ_NY), - day1); - assertEquals( - DateTimeUtils.formatDate( - JPOSE.previousBusinessSchedule(JPOSE.pastDate(JPOSE.pastDate(day2))).getSOBD(), TZ_JP), - day1); - - day1 = null; - assertNull(USNYSE.previousBusinessSchedule(day1)); - assertNull(JPOSE.previousBusinessSchedule(day1)); - - // incorrectly formatted days - try { - USNYSE.previousBusinessSchedule("2018-09-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testLastNonBusinessDayString() { - String day1 = "2016-08-28"; - String day2 = "2016-09-01"; - assertNull(USNYSE.pastNonBusinessDate((String) null)); - assertEquals(USNYSE.pastNonBusinessDate(day2), day1); - assertEquals(JPOSE.pastNonBusinessDate(day2), day1); - - assertNull(USNYSE.pastNonBusinessDate((String) null, 2)); - assertNull(USNYSE.pastNonBusinessDate("2016-08-30", 0)); - assertEquals(USNYSE.pastNonBusinessDate("2016-08-28", 0), "2016-08-28"); - - // leap day - day1 = "2016-02-27"; - day2 = "2016-03-01"; - assertEquals(USNYSE.pastNonBusinessDate(day2, 2), day1); - assertEquals(JPOSE.pastNonBusinessDate(day2, 2), day1); - assertEquals(USNYSE.pastNonBusinessDate(day1, -2), "2016-03-05"); - assertEquals(JPOSE.pastNonBusinessDate(day1, -2), "2016-03-05"); - - // new year - day1 = "2013-12-29"; - day2 = "2014-01-01"; - assertEquals(USNYSE.pastNonBusinessDate(day2), day1); - assertEquals(JPOSE.pastNonBusinessDate(day2), day1); - - // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 - day1 = "2017-03-05"; - day2 = "2017-03-13"; - assertEquals(USNYSE.pastNonBusinessDate(day2, 3), day1); - assertEquals(JPOSE.pastNonBusinessDate(day2, 3), day1); - assertEquals(USNYSE.pastNonBusinessDate(day1, -3), "2017-03-18"); - assertEquals(JPOSE.pastNonBusinessDate(day1, -3), "2017-03-18"); - - day1 = null; - assertNull(USNYSE.pastNonBusinessDate(day1)); - assertNull(JPOSE.pastNonBusinessDate(day1)); - - // incorrectly formatted days - try { - USNYSE.pastNonBusinessDate("2018-09-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testDiff() { - // standard business day - Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); - assertEquals(USNYSE.diffDay(day1, day2), 1.0); - assertEquals(USNYSE.diffNanos(day1, day2), DateTimeUtils.DAY); - assertEquals(JPOSE.diffYear365(day1, day2), (double) DateTimeUtils.DAY / (double) DateTimeUtils.YEAR_365); - assertEquals(JPOSE.diffYearAvg(day1, day2), (double) DateTimeUtils.DAY / (double) DateTimeUtils.YEAR_AVG); - } - - public void testBusinessTimeDiff() { - // standard business day - Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); - assertEquals(USNYSE.diffBusinessDays(day1, day2), 1.0); - assertEquals(JPOSE.diffBusinessDays(day1, day2), 1.0); - - // 2.5 standard business days - day1 = DateTimeUtils.parseInstant("2017-01-23T01:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2017-01-25T12:45:00.000000000 NY"); - assertEquals(USNYSE.diffBusinessDays(day1, day2), 2.5); - - day1 = DateTimeUtils.parseInstant("2017-01-23T01:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2017-01-25T12:45:00.000000000 JP"); - assertEquals(JPOSE.diffBusinessDays(day1, day2), 2.55); - - // middle of a business period - day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2017-01-23T13:00:00.000000000 JP"); - assertEquals(JPOSE.diffBusinessNanos(day1, day2), 2 * DateTimeUtils.HOUR); - - // after a business period - day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2017-01-23T16:15:00.000000000 JP"); - assertEquals(JPOSE.diffBusinessNanos(day1, day2), 4 * DateTimeUtils.HOUR); - - // middle of the second business period - day1 = DateTimeUtils.parseInstant("2017-01-23T08:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2017-01-23T14:00:00.000000000 JP"); - assertEquals(JPOSE.diffBusinessNanos(day1, day2), 4 * DateTimeUtils.HOUR); - - // weekend non business - day1 = DateTimeUtils.parseInstant("2017-01-21T01:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2017-01-23T01:00:00.000000000 NY"); - assertEquals(USNYSE.diffBusinessDays(day1, day2), 0.0); - - // one business year - day1 = DateTimeUtils.parseInstant("2016-01-01T01:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2016-12-31T23:59:00.000000000 NY"); - double yearDiff = USNYSE.diffBusinessYears(day1, day2); - assertTrue(yearDiff < 1.004); - assertTrue(yearDiff > 0.996); - yearDiff = JPOSE.diffBusinessYears(day1, day2); - assertTrue(yearDiff < 1.004); - assertTrue(yearDiff > 0.996); - - // half year - day1 = DateTimeUtils.parseInstant("2017-01-01T01:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2017-07-02T01:00:00.000000000 NY"); - yearDiff = USNYSE.diffBusinessYears(day1, day2); - assertTrue(yearDiff < 0.503); - assertTrue(yearDiff > 0.497); - yearDiff = JPOSE.diffBusinessYears(day1, day2); - assertTrue(yearDiff < 0.503); - assertTrue(yearDiff > 0.497); - - - day1 = null; - assertEquals(USNYSE.diffBusinessYears(day1, day2), QueryConstants.NULL_DOUBLE); - assertEquals(USNYSE.diffBusinessDays(day1, day2), QueryConstants.NULL_DOUBLE); - assertEquals(USNYSE.diffBusinessNanos(day1, day2), QueryConstants.NULL_LONG); - - day1 = day2; - assertEquals(USNYSE.diffBusinessYears(day1, day2), 0.0); - assertEquals(USNYSE.diffBusinessDays(day1, day2), 0.0); - assertEquals(USNYSE.diffBusinessNanos(day1, day2), 0); - } - - public void testNonBusinessTimeDiff() { - // USNYSE - // standard business day - Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); - assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), 63000000000000L); // 17.5 hours - assertEquals(USNYSE.diffNonBusinessNanos(day2, day1), -63000000000000L); // 17.5 hours - - // middle of a business period - day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2017-01-23T12:30:00.000000000 NY"); - assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), 0); - - // after a business period - day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 NY"); - day2 = DateTimeUtils.parseInstant("2017-01-23T16:15:00.000000000 NY"); - assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), 15 * DateTimeUtils.MINUTE); - - // JPOSE - // standard business day - day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 JP"); - assertEquals(JPOSE.diffNonBusinessNanos(day1, day2), 19 * DateTimeUtils.HOUR); // 17.5 hours - - // middle of a business period - day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2017-01-23T11:30:00.000000000 JP"); - assertEquals(JPOSE.diffNonBusinessNanos(day1, day2), 0); - - // after a business period - day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2017-01-23T16:00:00.000000000 JP"); - assertEquals(JPOSE.diffNonBusinessNanos(day1, day2), 2 * DateTimeUtils.HOUR); - assertEquals(JPOSE.diffNonBusinessDays(day1, day2), - ((double) (2 * DateTimeUtils.HOUR)) / (double) JPOSE.standardBusinessDayLengthNanos()); - - - - day1 = null; - assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), QueryConstants.NULL_LONG); - - day1 = day2; - assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), 0); - - day1 = null; - assertEquals(USNYSE.diffNonBusinessDays(day1, day2), QueryConstants.NULL_DOUBLE); - } - - public void testBusinessDateRange() { - // day light savings - Instant startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); - Instant endDate = DateTimeUtils.parseInstant("2017-03-14T01:00:00.000000000 NY"); - - String[] goodResults = new String[] { - "2017-03-13", - "2017-03-14" - }; - - String[] results = USNYSE.businessDates(startDate, endDate); - Arrays.sort(goodResults); - Arrays.sort(results); - boolean answer = Arrays.equals(goodResults, results); - assertTrue(answer); - - assertEquals(new String[0], USNYSE.businessDates(endDate, startDate)); - - startDate = DateTimeUtils.parseInstant("2017-11-23T01:00:00.000000000 JP"); - endDate = DateTimeUtils.parseInstant("2017-11-25T01:00:00.000000000 JP"); - - goodResults = new String[] { - "2017-11-24" - }; - - results = JPOSE.businessDates(startDate, endDate); - Arrays.sort(goodResults); - Arrays.sort(results); - answer = Arrays.equals(goodResults, results); - assertTrue(answer); - - startDate = null; - assertEquals(JPOSE.businessDates(startDate, endDate).length, 0); - - // non business - startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); - endDate = DateTimeUtils.parseInstant("2017-03-14T01:00:00.000000000 NY"); - - goodResults = new String[] { - "2017-03-11", - "2017-03-12" - }; - - results = USNYSE.nonBusinessDates(startDate, endDate); - Arrays.sort(goodResults); - Arrays.sort(results); - answer = Arrays.equals(goodResults, results); - assertTrue(answer); - - - startDate = DateTimeUtils.parseInstant("2017-11-23T01:00:00.000000000 JP"); - endDate = DateTimeUtils.parseInstant("2017-11-25T01:00:00.000000000 JP"); - - goodResults = new String[] { - "2017-11-23", - "2017-11-25" - }; - - assertEquals(new String[0], USNYSE.nonBusinessDates(endDate, startDate)); - results = JPOSE.nonBusinessDates(startDate, endDate); - Arrays.sort(goodResults); - Arrays.sort(results); - answer = Arrays.equals(goodResults, results); - assertTrue(answer); - - startDate = null; - assertEquals(JPOSE.nonBusinessDates(startDate, endDate).length, 0); - - startDate = null; - assertEquals(USNYSE.nonBusinessDates(startDate, endDate).length, 0); - } - - public void testBusinessDateStringRange() { - // USNYSE - String startDate = "2014-02-16"; - String endDate = "2014-03-05"; - String[] goodResults = new String[] { - "2014-02-18", "2014-02-19", "2014-02-20", "2014-02-21", - "2014-02-24", "2014-02-25", "2014-02-26", "2014-02-27", "2014-02-28", - "2014-03-03", "2014-03-04", "2014-03-05", - }; - - assertEquals(new String[0], USNYSE.businessDates(endDate, startDate)); - String[] results = USNYSE.businessDates(startDate, endDate); - Arrays.sort(goodResults); - Arrays.sort(results); - boolean answer = Arrays.equals(goodResults, results); - assertTrue(answer); - - startDate = null; - assertEquals(USNYSE.businessDates(startDate, endDate).length, 0); - - startDate = endDate; - assertEquals(USNYSE.businessDates(startDate, endDate).length, 1); - - // JPOSE - startDate = "2018-01-01"; - endDate = "2018-01-05"; - goodResults = new String[] { - "2018-01-04", - "2018-01-05" - }; - - results = JPOSE.businessDates(startDate, endDate); - Arrays.sort(goodResults); - Arrays.sort(results); - answer = Arrays.equals(goodResults, results); - assertTrue(answer); - - - // non business - startDate = "2020-01-01"; - endDate = "2020-01-20"; - goodResults = new String[] { - "2020-01-01", "2020-01-04", "2020-01-05", "2020-01-11", "2020-01-12", - "2020-01-18", "2020-01-19", "2020-01-20" - }; - - assertEquals(new String[0], USNYSE.nonBusinessDates(endDate, startDate)); - results = USNYSE.nonBusinessDates(startDate, endDate); - Arrays.sort(goodResults); - Arrays.sort(results); - answer = Arrays.equals(goodResults, results); - assertTrue(answer); - - - // JPOSE - startDate = "2018-01-01"; - endDate = "2018-01-05"; - goodResults = new String[] { - "2018-01-01", - "2018-01-02", - "2018-01-03" - }; - - results = JPOSE.nonBusinessDates(startDate, endDate); - Arrays.sort(goodResults); - Arrays.sort(results); - answer = Arrays.equals(goodResults, results); - assertTrue(answer); - - - // null tests - startDate = null; - assertEquals(USNYSE.nonBusinessDates(startDate, endDate).length, 0); - - startDate = endDate = "2018-01-06"; - assertEquals(USNYSE.nonBusinessDates(startDate, endDate).length, 1); - - // incorrectly formatted days - try { - USNYSE.nonBusinessDates("2018-09-31", "2018-010-31"); - fail(); - } catch (IllegalArgumentException e) { - // ok - } - } - - public void testDayOfWeek() { - assertEquals(DayOfWeek.WEDNESDAY, test.dayOfWeek()); - - String dateString = "2017-02-06"; - assertEquals(USNYSE.dayOfWeek(dateString), DayOfWeek.MONDAY); - assertEquals(JPOSE.dayOfWeek(dateString), DayOfWeek.MONDAY); - - Instant dateTime = DateTimeUtils.parseInstant("2017-09-01T00:00:00.000000000 NY"); - assertEquals(USNYSE.dayOfWeek(dateTime), DayOfWeek.FRIDAY); - assertEquals(JPOSE.dayOfWeek(dateTime), DayOfWeek.FRIDAY); - - dateString = null; - dateTime = null; - assertNull(USNYSE.dayOfWeek(dateString)); - assertNull(USNYSE.dayOfWeek(dateTime)); - - // incorrectly formatted days - try { - USNYSE.dayOfWeek("2018-09-31"); - fail(); - } catch (DateTimeException e) { - // ok - } - } - - public void testLastBusinessDayOfWeek() { - assertFalse(test.isLastBusinessDayOfWeek()); - - String dateString = "2017-02-10"; - Instant dateTime = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 NY"); - assertTrue(USNYSE.isLastBusinessDayOfWeek(dateString)); - assertFalse(USNYSE.isLastBusinessDayOfWeek(dateTime)); - assertTrue(JPOSE.isLastBusinessDayOfWeek(dateString)); - assertFalse(JPOSE.isLastBusinessDayOfWeek(dateTime)); - - dateString = null; - assertFalse(USNYSE.isLastBusinessDayOfWeek(dateString)); - } - - public void testLastBusinessDayOfMonth() { - assertFalse(test.isLastBusinessDayOfMonth()); - - String dateString = "2017-02-28"; - Instant dateTime = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 NY"); - assertTrue(USNYSE.isLastBusinessDayOfMonth(dateString)); - assertFalse(USNYSE.isLastBusinessDayOfMonth(dateTime)); - assertTrue(JPOSE.isLastBusinessDayOfMonth(dateString)); - assertFalse(JPOSE.isLastBusinessDayOfMonth(dateTime)); - - dateString = null; - assertFalse(USNYSE.isLastBusinessDayOfMonth(dateString)); - assertFalse(JPOSE.isLastBusinessDayOfMonth(dateString)); - } - - public void testFractionOfBusinessDay() { - assertEquals(1.0, test.fractionOfStandardBusinessDay()); - - - // half day, USNYSE market open from 0930 to 1300 - String dateString = "2018-11-23"; - - // full day - Instant dateTime = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 NY"); - - assertEquals(USNYSE.fractionOfStandardBusinessDay(dateString), 3.5 / 6.5); - assertEquals(1.0, USNYSE.fractionOfStandardBusinessDay(dateTime)); - - // half day, JPOSE market open from 0930 to 1300 - dateString = "2006-01-04"; - - assertEquals(JPOSE.fractionOfStandardBusinessDay(dateString), 0.5); - assertEquals(1.0, JPOSE.fractionOfStandardBusinessDay(dateTime)); - - - dateString = null; - dateTime = null; - assertEquals(JPOSE.fractionOfStandardBusinessDay(dateString), 0.0); - assertEquals(JPOSE.fractionOfStandardBusinessDay(dateTime), 0.0); - } - - public void testFractionOfBusinessDayLeft() { - // half day, market open from 0930 to 1300 - Instant day1 = DateTimeUtils.parseInstant("2018-11-23T10:00:00.000000000 NY"); - - // full day - Instant day2 = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 NY"); - - // holiday - Instant day3 = DateTimeUtils.parseInstant("2017-07-04T00:00:00.000000000 NY"); - - assertEquals(USNYSE.fractionOfBusinessDayRemaining(day1), 3.0 / 3.5); - assertEquals(USNYSE.fractionOfBusinessDayComplete(day1), 0.5 / 3.5, 0.0000001); - assertEquals(USNYSE.fractionOfBusinessDayRemaining(day2), 1.0); - assertEquals(USNYSE.fractionOfBusinessDayComplete(day2), 0.0); - assertEquals(USNYSE.fractionOfBusinessDayRemaining(day3), 0.0); - - // half day, market open from 0900 to 1130 - day1 = DateTimeUtils.parseInstant("2006-01-04T10:00:00.000000000 JP"); - day2 = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 JP"); - assertEquals(JPOSE.fractionOfBusinessDayRemaining(day1), 1.5 / 2.5); - assertEquals(JPOSE.fractionOfBusinessDayComplete(day1), 1.0 / 2.5); - assertEquals(JPOSE.fractionOfBusinessDayRemaining(day2), 1.0); - assertEquals(JPOSE.fractionOfBusinessDayComplete(day2), 0.0); - - - assertEquals(JPOSE.fractionOfBusinessDayRemaining(null), QueryConstants.NULL_DOUBLE); - assertEquals(JPOSE.fractionOfBusinessDayComplete(null), QueryConstants.NULL_DOUBLE); - } - - public void testCurrentBusinessSchedule() { - assertEquals(test.nextBusinessSchedule("2017-09-26"), test.currentBusinessSchedule()); - } - - public void testMidnightClose() { - assertEquals(DateTimeUtils.DAY, UTC.standardBusinessDayLengthNanos()); - assertEquals("2019-04-16", UTC.futureDate("2019-04-15")); - assertEquals("2019-04-16", UTC.futureBusinessDate("2019-04-15")); - assertEquals("2019-04-18", UTC.futureBusinessDate("2019-04-15", 3)); - assertEquals("2019-08-19", - UTC.futureBusinessDate(DateTimeUtils.parseInstant("2019-08-18T00:00:00.000000000 UTC"))); - - assertEquals("2019-05-16", DateTimeUtils.formatDate(UTC.businessSchedule("2019-05-16").businessStart(), TZ_UTC)); - assertEquals("2019-05-17", DateTimeUtils.formatDate(UTC.businessSchedule("2019-05-16").businessEnd(), TZ_UTC)); - } -} From 6aefb0df73f9caa490e02d35586d996f12a5305d Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Wed, 12 Jul 2023 14:10:18 -0600 Subject: [PATCH 040/150] Unit test: * BusinessCalendar - Business Time --- .../time/calendar/TestBusinessCalendar.java | 483 ++++++++++++++---- 1 file changed, 371 insertions(+), 112 deletions(-) diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java index 5c9a0027fb5..93c7a85b235 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java @@ -4,6 +4,7 @@ package io.deephaven.time.calendar; import io.deephaven.base.verify.RequirementFailure; +import io.deephaven.time.DateTimeUtils; import java.time.*; import java.util.HashMap; @@ -12,22 +13,19 @@ @SuppressWarnings({"ConstantConditions", "unchecked", "rawtypes"}) public class TestBusinessCalendar extends TestCalendar { -// private final String name = "TEST CALENDAR"; -// private final String description = "This is a test"; -// private final ZoneId timeZone = ZoneId.of("America/Los_Angeles"); - private final LocalDate firstValidDate = LocalDate.of(2000,1,1); - private final LocalDate lastValidDate = LocalDate.of(2050,12,31); + private final LocalDate firstValidDate = LocalDate.of(2000, 1, 1); + private final LocalDate lastValidDate = LocalDate.of(2050, 12, 31); private final BusinessPeriod period = new BusinessPeriod<>(LocalTime.of(9, 0), LocalTime.of(12, 15)); private final BusinessPeriod periodHalf = new BusinessPeriod<>(LocalTime.of(9, 0), LocalTime.of(11, 7)); private final BusinessSchedule schedule = new BusinessSchedule<>(new BusinessPeriod[]{period}); private final Set weekendDays = Set.of(DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY); - private final LocalDate holidayDate1 = LocalDate.of(2023,7,4); - private final LocalDate holidayDate2 = LocalDate.of(2023,12,25); + private final LocalDate holidayDate1 = LocalDate.of(2023, 7, 4); + private final LocalDate holidayDate2 = LocalDate.of(2023, 12, 25); private final BusinessSchedule holiday = new BusinessSchedule<>(); - private final LocalDate halfDayDate = LocalDate.of(2023,7,6); - private final BusinessSchedule halfDay = new BusinessSchedule<>(new BusinessPeriod[]{BusinessPeriod.toInstant(periodHalf, halfDayDate,timeZone)}); + private final LocalDate halfDayDate = LocalDate.of(2023, 7, 6); + private final BusinessSchedule halfDay = new BusinessSchedule<>(new BusinessPeriod[]{BusinessPeriod.toInstant(periodHalf, halfDayDate, timeZone)}); - private Map> holidays; + private Map> holidays; private BusinessCalendar bCalendar; @Override @@ -58,75 +56,75 @@ public void testBusinessSchedule() { assertEquals(halfDay, bCalendar.businessSchedule(halfDayDate)); // TUES - Weekday - LocalDate date = LocalDate.of(2023,7,11); + LocalDate date = LocalDate.of(2023, 7, 11); assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date)); assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.toString())); - assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone))); - assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone).toInstant())); + assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.atTime(1, 2, 3).atZone(timeZone))); + assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // WED - Weekend - date = LocalDate.of(2023,7,12); + date = LocalDate.of(2023, 7, 12); assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date)); assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.toString())); - assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone))); - assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone).toInstant())); + assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.atTime(1, 2, 3).atZone(timeZone))); + assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // THURS - Weekend - date = LocalDate.of(2023,7,13); + date = LocalDate.of(2023, 7, 13); assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date)); assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.toString())); - assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone))); - assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone).toInstant())); + assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.atTime(1, 2, 3).atZone(timeZone))); + assertEquals(BusinessSchedule.toInstant(BusinessSchedule.HOLIDAY, date, timeZone), bCalendar.businessSchedule(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // FRI - Weekday - date = LocalDate.of(2023,7,14); + date = LocalDate.of(2023, 7, 14); assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date)); assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.toString())); - assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone))); - assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.atTime(1,2,3).atZone(timeZone).toInstant())); + assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.atTime(1, 2, 3).atZone(timeZone))); + assertEquals(BusinessSchedule.toInstant(schedule, date, timeZone), bCalendar.businessSchedule(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // Current date assertEquals(bCalendar.businessSchedule(bCalendar.currentDate()), bCalendar.businessSchedule()); // Check that all dates in the range work - for(LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { + for (LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { assertNotNull(bCalendar.businessSchedule(d)); } - try{ + try { bCalendar.businessSchedule(firstValidDate.minusDays(1)); fail("should throw an exception"); - } catch (BusinessCalendar.InvalidDateException ignored){ + } catch (BusinessCalendar.InvalidDateException ignored) { } - try{ + try { bCalendar.businessSchedule(lastValidDate.plusDays(1)); fail("should throw an exception"); - } catch (BusinessCalendar.InvalidDateException ignored){ + } catch (BusinessCalendar.InvalidDateException ignored) { } - try{ + try { bCalendar.businessSchedule((LocalDate) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.businessSchedule((String) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.businessSchedule((ZonedDateTime) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.businessSchedule((Instant) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } } @@ -136,28 +134,28 @@ public void testIsBusinessDay() { assertTrue(bCalendar.isBusinessDay(halfDayDate)); // TUES - Weekday - LocalDate date = LocalDate.of(2023,7,11); + LocalDate date = LocalDate.of(2023, 7, 11); assertTrue(bCalendar.isBusinessDay(date)); assertTrue(bCalendar.isBusinessDay(date.toString())); assertTrue(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone))); assertTrue(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // WED - Weekend - date = LocalDate.of(2023,7,12); + date = LocalDate.of(2023, 7, 12); assertFalse(bCalendar.isBusinessDay(date)); assertFalse(bCalendar.isBusinessDay(date.toString())); assertFalse(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone))); assertFalse(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // THURS - Weekend - date = LocalDate.of(2023,7,13); + date = LocalDate.of(2023, 7, 13); assertFalse(bCalendar.isBusinessDay(date)); assertFalse(bCalendar.isBusinessDay(date.toString())); assertFalse(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone))); assertFalse(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // FRI - Weekday - date = LocalDate.of(2023,7,14); + date = LocalDate.of(2023, 7, 14); assertTrue(bCalendar.isBusinessDay(date)); assertTrue(bCalendar.isBusinessDay(date.toString())); assertTrue(bCalendar.isBusinessDay(date.atTime(1, 2, 3).atZone(timeZone))); @@ -168,81 +166,81 @@ public void testIsBusinessDay() { // DayOfWeek - for (DayOfWeek dow : DayOfWeek.values()){ + for (DayOfWeek dow : DayOfWeek.values()) { assertEquals(!weekendDays.contains(dow), bCalendar.isBusinessDay(dow)); } // Check that all dates in the range work - for(LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { + for (LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { bCalendar.isBusinessDay(d); } - try{ + try { bCalendar.isBusinessDay(firstValidDate.minusDays(1)); fail("should throw an exception"); - } catch (BusinessCalendar.InvalidDateException ignored){ + } catch (BusinessCalendar.InvalidDateException ignored) { } - try{ + try { bCalendar.isBusinessDay(lastValidDate.plusDays(1)); fail("should throw an exception"); - } catch (BusinessCalendar.InvalidDateException ignored){ + } catch (BusinessCalendar.InvalidDateException ignored) { } - try{ + try { bCalendar.isBusinessDay((LocalDate) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.isBusinessDay((String) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.isBusinessDay((ZonedDateTime) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.isBusinessDay((Instant) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.isBusinessDay((DayOfWeek) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } } public void testIsLastBusinessDayOfMonth() { - LocalDate date = LocalDate.of(2023,7,31); + LocalDate date = LocalDate.of(2023, 7, 31); assertTrue(bCalendar.isLastBusinessDayOfMonth(date)); assertTrue(bCalendar.isLastBusinessDayOfMonth(date.toString())); assertTrue(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone))); assertTrue(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // THURS - Weekend - date = LocalDate.of(2023,8,31); + date = LocalDate.of(2023, 8, 31); assertFalse(bCalendar.isLastBusinessDayOfMonth(date)); assertFalse(bCalendar.isLastBusinessDayOfMonth(date.toString())); assertFalse(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone))); assertFalse(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // WED - Weekend - date = LocalDate.of(2023,8,30); + date = LocalDate.of(2023, 8, 30); assertFalse(bCalendar.isLastBusinessDayOfMonth(date)); assertFalse(bCalendar.isLastBusinessDayOfMonth(date.toString())); assertFalse(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone))); assertFalse(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // TUES - Weekday - date = LocalDate.of(2023,8,29); + date = LocalDate.of(2023, 8, 29); assertTrue(bCalendar.isLastBusinessDayOfMonth(date)); assertTrue(bCalendar.isLastBusinessDayOfMonth(date.toString())); assertTrue(bCalendar.isLastBusinessDayOfMonth(date.atTime(1, 2, 3).atZone(timeZone))); @@ -252,88 +250,88 @@ public void testIsLastBusinessDayOfMonth() { assertEquals(bCalendar.isLastBusinessDayOfMonth(bCalendar.currentDate()), bCalendar.isLastBusinessDayOfMonth()); // Check that all dates in the range work - for(LocalDate d = firstValidDate; d.isBefore(lastValidDate); d = d.plusDays(1)) { + for (LocalDate d = firstValidDate; d.isBefore(lastValidDate); d = d.plusDays(1)) { bCalendar.isLastBusinessDayOfMonth(d); } - try{ + try { bCalendar.isLastBusinessDayOfMonth(firstValidDate.minusDays(1)); fail("should throw an exception"); - } catch (BusinessCalendar.InvalidDateException ignored){ + } catch (BusinessCalendar.InvalidDateException ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfMonth(lastValidDate.plusDays(1)); fail("should throw an exception"); - } catch (BusinessCalendar.InvalidDateException ignored){ + } catch (BusinessCalendar.InvalidDateException ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfMonth((LocalDate) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfMonth((String) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfMonth((ZonedDateTime) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfMonth((Instant) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } } public void testIsLastBusinessDayOfWeek() { // FRI - LocalDate date = LocalDate.of(2023,7,28); + LocalDate date = LocalDate.of(2023, 7, 28); assertFalse(bCalendar.isLastBusinessDayOfWeek(date)); assertFalse(bCalendar.isLastBusinessDayOfWeek(date.toString())); assertFalse(bCalendar.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone))); assertFalse(bCalendar.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // SAT - date = LocalDate.of(2023,7,29); + date = LocalDate.of(2023, 7, 29); assertFalse(bCalendar.isLastBusinessDayOfWeek(date)); assertFalse(bCalendar.isLastBusinessDayOfWeek(date.toString())); assertFalse(bCalendar.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone))); assertFalse(bCalendar.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // SUN - date = LocalDate.of(2023,7,30); + date = LocalDate.of(2023, 7, 30); assertTrue(bCalendar.isLastBusinessDayOfWeek(date)); assertTrue(bCalendar.isLastBusinessDayOfWeek(date.toString())); assertTrue(bCalendar.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone))); assertTrue(bCalendar.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); - final Set wd = Set.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY); + final Set wd = Set.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY); final BusinessCalendar bc = new BusinessCalendar(name, description, timeZone, firstValidDate, lastValidDate, schedule, wd, holidays); // FRI - date = LocalDate.of(2023,7,28); + date = LocalDate.of(2023, 7, 28); assertTrue(bc.isLastBusinessDayOfWeek(date)); assertTrue(bc.isLastBusinessDayOfWeek(date.toString())); assertTrue(bc.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone))); assertTrue(bc.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // SAT - date = LocalDate.of(2023,7,29); + date = LocalDate.of(2023, 7, 29); assertFalse(bc.isLastBusinessDayOfWeek(date)); assertFalse(bc.isLastBusinessDayOfWeek(date.toString())); assertFalse(bc.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone))); assertFalse(bc.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); // SUN - date = LocalDate.of(2023,7,30); + date = LocalDate.of(2023, 7, 30); assertFalse(bc.isLastBusinessDayOfWeek(date)); assertFalse(bc.isLastBusinessDayOfWeek(date.toString())); assertFalse(bc.isLastBusinessDayOfWeek(date.atTime(1, 2, 3).atZone(timeZone))); @@ -343,61 +341,61 @@ public void testIsLastBusinessDayOfWeek() { assertEquals(bCalendar.isLastBusinessDayOfWeek(bCalendar.currentDate()), bCalendar.isLastBusinessDayOfWeek()); // Check that all dates in the range work - for(LocalDate d = firstValidDate; d.isBefore(lastValidDate); d = d.plusDays(1)) { + for (LocalDate d = firstValidDate; d.isBefore(lastValidDate); d = d.plusDays(1)) { bCalendar.isLastBusinessDayOfWeek(d); } - try{ + try { bCalendar.isLastBusinessDayOfWeek(firstValidDate.minusDays(1)); fail("should throw an exception"); - } catch (BusinessCalendar.InvalidDateException ignored){ + } catch (BusinessCalendar.InvalidDateException ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfWeek(lastValidDate.plusDays(1)); fail("should throw an exception"); - } catch (BusinessCalendar.InvalidDateException ignored){ + } catch (BusinessCalendar.InvalidDateException ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfWeek((LocalDate) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfWeek((String) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfWeek((ZonedDateTime) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfWeek((Instant) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } } public void testIsLastBusinessDayOfYear() { - LocalDate date = LocalDate.of(2023,12,29); + LocalDate date = LocalDate.of(2023, 12, 29); assertFalse(bCalendar.isLastBusinessDayOfYear(date)); assertFalse(bCalendar.isLastBusinessDayOfYear(date.toString())); assertFalse(bCalendar.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone))); assertFalse(bCalendar.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); - date = LocalDate.of(2023,12,30); + date = LocalDate.of(2023, 12, 30); assertFalse(bCalendar.isLastBusinessDayOfYear(date)); assertFalse(bCalendar.isLastBusinessDayOfYear(date.toString())); assertFalse(bCalendar.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone))); assertFalse(bCalendar.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); - date = LocalDate.of(2023,12,31); + date = LocalDate.of(2023, 12, 31); assertTrue(bCalendar.isLastBusinessDayOfYear(date)); assertTrue(bCalendar.isLastBusinessDayOfYear(date.toString())); assertTrue(bCalendar.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone))); @@ -406,19 +404,19 @@ public void testIsLastBusinessDayOfYear() { final Set wd = Set.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY); final BusinessCalendar bc = new BusinessCalendar(name, description, timeZone, firstValidDate, lastValidDate, schedule, wd, holidays); - date = LocalDate.of(2023,12,29); + date = LocalDate.of(2023, 12, 29); assertTrue(bc.isLastBusinessDayOfYear(date)); assertTrue(bc.isLastBusinessDayOfYear(date.toString())); assertTrue(bc.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone))); assertTrue(bc.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); - date = LocalDate.of(2023,12,30); + date = LocalDate.of(2023, 12, 30); assertFalse(bc.isLastBusinessDayOfYear(date)); assertFalse(bc.isLastBusinessDayOfYear(date.toString())); assertFalse(bc.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone))); assertFalse(bc.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone).toInstant())); - date = LocalDate.of(2023,12,31); + date = LocalDate.of(2023, 12, 31); assertFalse(bc.isLastBusinessDayOfYear(date)); assertFalse(bc.isLastBusinessDayOfYear(date.toString())); assertFalse(bc.isLastBusinessDayOfYear(date.atTime(1, 2, 3).atZone(timeZone))); @@ -428,47 +426,308 @@ public void testIsLastBusinessDayOfYear() { assertEquals(bCalendar.isLastBusinessDayOfYear(bCalendar.currentDate()), bCalendar.isLastBusinessDayOfYear()); // Check that all dates in the range work - for(LocalDate d = firstValidDate; d.isBefore(lastValidDate); d = d.plusDays(1)) { + for (LocalDate d = firstValidDate; d.isBefore(lastValidDate); d = d.plusDays(1)) { bCalendar.isLastBusinessDayOfYear(d); } - try{ + try { bCalendar.isLastBusinessDayOfYear(firstValidDate.minusDays(1)); fail("should throw an exception"); - } catch (BusinessCalendar.InvalidDateException ignored){ + } catch (BusinessCalendar.InvalidDateException ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfYear(lastValidDate.plusDays(1)); fail("should throw an exception"); - } catch (BusinessCalendar.InvalidDateException ignored){ + } catch (BusinessCalendar.InvalidDateException ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfYear((LocalDate) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfYear((String) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfYear((ZonedDateTime) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { } - try{ + try { bCalendar.isLastBusinessDayOfYear((Instant) null); fail("should throw an exception"); - }catch (RequirementFailure ignored){ + } catch (RequirementFailure ignored) { + } + } + + public void testIsBusinessTime() { + // Normal bus day + LocalDate date = LocalDate.of(2023, 7, 11); + ZonedDateTime tNotIn = date.atTime(8, 2, 3).atZone(timeZone); + ZonedDateTime tIn = date.atTime(10, 2, 3).atZone(timeZone); + assertFalse(bCalendar.isBusinessTime(tNotIn)); + assertFalse(bCalendar.isBusinessTime(tNotIn.toInstant())); + assertTrue(bCalendar.isBusinessTime(tIn)); + assertTrue(bCalendar.isBusinessTime(tIn.toInstant())); + + // Weekend day -- THURS + date = LocalDate.of(2023, 7, 13); + tNotIn = date.atTime(8, 2, 3).atZone(timeZone); + tIn = date.atTime(10, 2, 3).atZone(timeZone); + assertFalse(bCalendar.isBusinessTime(tNotIn)); + assertFalse(bCalendar.isBusinessTime(tNotIn.toInstant())); + assertFalse(bCalendar.isBusinessTime(tIn)); + assertFalse(bCalendar.isBusinessTime(tIn.toInstant())); + + // Holiday + date = holidayDate1; + tNotIn = date.atTime(8, 2, 3).atZone(timeZone); + tIn = date.atTime(10, 2, 3).atZone(timeZone); + assertFalse(bCalendar.isBusinessTime(tNotIn)); + assertFalse(bCalendar.isBusinessTime(tNotIn.toInstant())); + assertFalse(bCalendar.isBusinessTime(tIn)); + assertFalse(bCalendar.isBusinessTime(tIn.toInstant())); + + // Half day + date = halfDayDate; + tNotIn = date.atTime(8, 2, 3).atZone(timeZone); + tIn = date.atTime(10, 2, 3).atZone(timeZone); + assertFalse(bCalendar.isBusinessTime(tNotIn)); + assertFalse(bCalendar.isBusinessTime(tNotIn.toInstant())); + assertTrue(bCalendar.isBusinessTime(tIn)); + assertTrue(bCalendar.isBusinessTime(tIn.toInstant())); + + // Current date + assertEquals(bCalendar.isBusinessTime(DateTimeUtils.now()), bCalendar.isBusinessTime()); + + // Check that all dates in the range work + for (LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { + bCalendar.isBusinessTime(d.atTime(12, 34).atZone(timeZone)); + } + + try { + bCalendar.isBusinessTime((ZonedDateTime) null); + fail("should throw an exception"); + } catch (RequirementFailure ignored) { + } + + try { + bCalendar.isBusinessTime((Instant) null); + fail("should throw an exception"); + } catch (RequirementFailure ignored) { } } - + + public void testFractionStandardBusinessDay() { + // Normal bus day + LocalDate date = LocalDate.of(2023, 7, 11); + assertEquals(1.0, bCalendar.fractionStandardBusinessDay(date)); + assertEquals(1.0, bCalendar.fractionStandardBusinessDay(date.toString())); + assertEquals(1.0, bCalendar.fractionStandardBusinessDay(date.atTime(11, 23).atZone(timeZone))); + assertEquals(1.0, bCalendar.fractionStandardBusinessDay(date.atTime(11, 23).atZone(timeZone).toInstant())); + + // Weekend day -- THURS + date = LocalDate.of(2023, 7, 13); + assertEquals(0.0, bCalendar.fractionStandardBusinessDay(date)); + assertEquals(0.0, bCalendar.fractionStandardBusinessDay(date.toString())); + assertEquals(0.0, bCalendar.fractionStandardBusinessDay(date.atTime(11, 23).atZone(timeZone))); + assertEquals(0.0, bCalendar.fractionStandardBusinessDay(date.atTime(11, 23).atZone(timeZone).toInstant())); + + // Holiday + date = holidayDate1; + assertEquals(0.0, bCalendar.fractionStandardBusinessDay(date)); + assertEquals(0.0, bCalendar.fractionStandardBusinessDay(date.toString())); + assertEquals(0.0, bCalendar.fractionStandardBusinessDay(date.atTime(11, 23).atZone(timeZone))); + assertEquals(0.0, bCalendar.fractionStandardBusinessDay(date.atTime(11, 23).atZone(timeZone).toInstant())); + + // Half day + date = halfDayDate; + assertEquals((double) halfDay.businessNanos() / (double) schedule.businessNanos(), bCalendar.fractionStandardBusinessDay(date)); + assertEquals((double) halfDay.businessNanos() / (double) schedule.businessNanos(), bCalendar.fractionStandardBusinessDay(date.toString())); + assertEquals((double) halfDay.businessNanos() / (double) schedule.businessNanos(), bCalendar.fractionStandardBusinessDay(date.atTime(11, 23).atZone(timeZone))); + assertEquals((double) halfDay.businessNanos() / (double) schedule.businessNanos(), bCalendar.fractionStandardBusinessDay(date.atTime(11, 23).atZone(timeZone).toInstant())); + + // Current date + assertEquals(bCalendar.fractionStandardBusinessDay(bCalendar.currentDate()), bCalendar.fractionStandardBusinessDay()); + + // Check that all dates in the range work + for (LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { + bCalendar.fractionStandardBusinessDay(d); + } + + try { + bCalendar.fractionStandardBusinessDay((LocalDate) null); + fail("should throw an exception"); + } catch (RequirementFailure ignored) { + } + + try { + bCalendar.fractionStandardBusinessDay((String) null); + fail("should throw an exception"); + } catch (RequirementFailure ignored) { + } + + try { + bCalendar.fractionStandardBusinessDay((ZonedDateTime) null); + fail("should throw an exception"); + } catch (RequirementFailure ignored) { + } + + try { + bCalendar.fractionStandardBusinessDay((Instant) null); + fail("should throw an exception"); + } catch (RequirementFailure ignored) { + } + } + + + public void testFractionBusinessDayComplete() { + // Normal bus day + LocalDate date = LocalDate.of(2023, 7, 11); + ZonedDateTime tBefore = date.atTime(8, 2, 3).atZone(timeZone); + ZonedDateTime tIn = date.atTime(10, 2, 3).atZone(timeZone); + ZonedDateTime tAfter = date.atTime(22, 2, 3).atZone(timeZone); + assertEquals(0.0, bCalendar.fractionBusinessDayComplete(tBefore)); + assertEquals(0.0, bCalendar.fractionBusinessDayComplete(tBefore.toInstant())); + assertEquals((double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) schedule.businessNanos(), bCalendar.fractionBusinessDayComplete(tIn)); + assertEquals((double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) schedule.businessNanos(), bCalendar.fractionBusinessDayComplete(tIn.toInstant())); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tAfter)); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tAfter.toInstant())); + + // Weekend day -- THURS + date = LocalDate.of(2023, 7, 13); + tBefore = date.atTime(8, 2, 3).atZone(timeZone); + tIn = date.atTime(10, 2, 3).atZone(timeZone); + tAfter = date.atTime(22, 2, 3).atZone(timeZone); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tBefore)); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tBefore.toInstant())); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tIn)); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tIn.toInstant())); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tAfter)); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tAfter.toInstant())); + + // Holiday + date = holidayDate1; + tBefore = date.atTime(8, 2, 3).atZone(timeZone); + tIn = date.atTime(10, 2, 3).atZone(timeZone); + tAfter = date.atTime(22, 2, 3).atZone(timeZone); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tBefore)); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tBefore.toInstant())); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tIn)); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tIn.toInstant())); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tAfter)); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tAfter.toInstant())); + + // Half day + date = halfDayDate; + tBefore = date.atTime(8, 2, 3).atZone(timeZone); + tIn = date.atTime(10, 2, 3).atZone(timeZone); + tAfter = date.atTime(22, 2, 3).atZone(timeZone); + assertEquals(0.0, bCalendar.fractionBusinessDayComplete(tBefore)); + assertEquals(0.0, bCalendar.fractionBusinessDayComplete(tBefore.toInstant())); + assertEquals((double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) halfDay.businessNanos(), bCalendar.fractionBusinessDayComplete(tIn)); + assertEquals((double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) halfDay.businessNanos(), bCalendar.fractionBusinessDayComplete(tIn.toInstant())); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tAfter)); + assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tAfter.toInstant())); + + // Current date + assertEquals(bCalendar.fractionBusinessDayComplete(DateTimeUtils.now()), bCalendar.fractionBusinessDayComplete()); + + // Check that all dates in the range work + for (LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { + bCalendar.fractionBusinessDayComplete(d.atTime(12, 34).atZone(timeZone)); + } + + try { + bCalendar.fractionBusinessDayComplete((ZonedDateTime) null); + fail("should throw an exception"); + } catch (RequirementFailure ignored) { + } + + try { + bCalendar.fractionBusinessDayComplete((Instant) null); + fail("should throw an exception"); + } catch (RequirementFailure ignored) { + } + } + + public void testFractionBusinessDayRemaining() { + // Normal bus day + LocalDate date = LocalDate.of(2023, 7, 11); + ZonedDateTime tBefore = date.atTime(8, 2, 3).atZone(timeZone); + ZonedDateTime tIn = date.atTime(10, 2, 3).atZone(timeZone); + ZonedDateTime tAfter = date.atTime(22, 2, 3).atZone(timeZone); + assertEquals(1.0, bCalendar.fractionBusinessDayRemaining(tBefore)); + assertEquals(1.0, bCalendar.fractionBusinessDayRemaining(tBefore.toInstant())); + assertEquals(1 - (double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) schedule.businessNanos(), bCalendar.fractionBusinessDayRemaining(tIn)); + assertEquals(1 - (double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) schedule.businessNanos(), bCalendar.fractionBusinessDayRemaining(tIn.toInstant())); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter)); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter.toInstant())); + + // Weekend day -- THURS + date = LocalDate.of(2023, 7, 13); + tBefore = date.atTime(8, 2, 3).atZone(timeZone); + tIn = date.atTime(10, 2, 3).atZone(timeZone); + tAfter = date.atTime(22, 2, 3).atZone(timeZone); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tBefore)); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tBefore.toInstant())); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tIn)); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tIn.toInstant())); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter)); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter.toInstant())); + + // Holiday + date = holidayDate1; + tBefore = date.atTime(8, 2, 3).atZone(timeZone); + tIn = date.atTime(10, 2, 3).atZone(timeZone); + tAfter = date.atTime(22, 2, 3).atZone(timeZone); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tBefore)); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tBefore.toInstant())); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tIn)); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tIn.toInstant())); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter)); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter.toInstant())); + + // Half day + date = halfDayDate; + tBefore = date.atTime(8, 2, 3).atZone(timeZone); + tIn = date.atTime(10, 2, 3).atZone(timeZone); + tAfter = date.atTime(22, 2, 3).atZone(timeZone); + assertEquals(1.0, bCalendar.fractionBusinessDayRemaining(tBefore)); + assertEquals(1.0, bCalendar.fractionBusinessDayRemaining(tBefore.toInstant())); + assertEquals(1 - (double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) halfDay.businessNanos(), bCalendar.fractionBusinessDayRemaining(tIn)); + assertEquals(1 - (double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) halfDay.businessNanos(), bCalendar.fractionBusinessDayRemaining(tIn.toInstant())); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter)); + assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter.toInstant())); + + // Current date + assertEquals(bCalendar.fractionBusinessDayRemaining(DateTimeUtils.now()), bCalendar.fractionBusinessDayRemaining()); + + // Check that all dates in the range work + for (LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { + bCalendar.fractionBusinessDayRemaining(d.atTime(12, 34).atZone(timeZone)); + } + + try { + bCalendar.fractionBusinessDayRemaining((ZonedDateTime) null); + fail("should throw an exception"); + } catch (RequirementFailure ignored) { + } + + try { + bCalendar.fractionBusinessDayRemaining((Instant) null); + fail("should throw an exception"); + } catch (RequirementFailure ignored) { + } + } + public void testFail() { fail(); } From d92f6c5f614ba255168569318f1ad110b7a3d660 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Mon, 17 Jul 2023 13:04:27 -0600 Subject: [PATCH 041/150] Unit test: * BusinessCalendar - Ranges --- .../io/deephaven/time/calendar/Calendars.java | 2 +- .../time/calendar/TestBusinessCalendar.java | 263 +++++++++++++++++- 2 files changed, 262 insertions(+), 3 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java index ced106d8e3f..09852f65fd3 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java @@ -62,7 +62,7 @@ public static BusinessCalendar calendar(final String name) { /** * Returns the default business calendar. * - * @return default business calendar. The deault is specified by the {@code Calendar.default} property. + * @return default business calendar. The default is specified by the {@code Calendar.default} property. */ public static BusinessCalendar calendar() { return calendar(defaultName); diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java index 93c7a85b235..ca82061b8fe 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java @@ -7,6 +7,7 @@ import io.deephaven.time.DateTimeUtils; import java.time.*; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -638,7 +639,7 @@ public void testFractionBusinessDayComplete() { assertEquals(1.0, bCalendar.fractionBusinessDayComplete(tAfter.toInstant())); // Current date - assertEquals(bCalendar.fractionBusinessDayComplete(DateTimeUtils.now()), bCalendar.fractionBusinessDayComplete()); + assertEquals(bCalendar.fractionBusinessDayComplete(DateTimeUtils.now()), bCalendar.fractionBusinessDayComplete(), 1e-5); // Check that all dates in the range work for (LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { @@ -708,7 +709,7 @@ public void testFractionBusinessDayRemaining() { assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter.toInstant())); // Current date - assertEquals(bCalendar.fractionBusinessDayRemaining(DateTimeUtils.now()), bCalendar.fractionBusinessDayRemaining()); + assertEquals(bCalendar.fractionBusinessDayRemaining(DateTimeUtils.now()), bCalendar.fractionBusinessDayRemaining(), 1e-5); // Check that all dates in the range work for (LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { @@ -728,6 +729,264 @@ public void testFractionBusinessDayRemaining() { } } + public void testBusinessDates() { + + final LocalDate start = LocalDate.of(2023,7,3); + final LocalDate end = LocalDate.of(2023,7,15); + + final LocalDate[] nonBus = { + holidayDate1, // Holiday 2023-07-04 + LocalDate.of(2023, 7, 5), // WED + // halfDayDate, // Half Day 2023-07-06 --> is a business day + LocalDate.of(2023, 7, 12), // WED + LocalDate.of(2023, 7, 13), // THURS + } ; + + final LocalDate[] bus = { + LocalDate.of(2023,7,3), + LocalDate.of(2023,7,6), + LocalDate.of(2023,7,7), + LocalDate.of(2023,7,8), + LocalDate.of(2023,7,9), + LocalDate.of(2023,7,10), + LocalDate.of(2023,7,11), + LocalDate.of(2023,7,14), + LocalDate.of(2023,7,15), + }; + + assertEquals(bus,bCalendar.businessDates(start, end)); + assertEquals(bus,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.copyOfRange(bus,0,bus.length-1),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)); + assertEquals(Arrays.copyOfRange(bus,0,bus.length-1),bCalendar.businessDates(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant(), true, false)); + + assertEquals(Arrays.copyOfRange(bus,1,bus.length),bCalendar.businessDates(start, end, false, true)); + assertEquals(Arrays.copyOfRange(bus,1,bus.length),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)); + assertEquals(Arrays.copyOfRange(bus,1,bus.length),bCalendar.businessDates(start.atTime(1,24).atZone(timeZone).toInstant(), 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.copyOfRange(bus,1,bus.length-1),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)); + assertEquals(Arrays.copyOfRange(bus,1,bus.length-1),bCalendar.businessDates(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant(), false, false)); + } + + public void testNumberBusinessDates() { + + final LocalDate start = LocalDate.of(2023,7,3); + final LocalDate end = LocalDate.of(2023,7,15); + + final LocalDate[] nonBus = { + holidayDate1, // Holiday 2023-07-04 + LocalDate.of(2023, 7, 5), // WED + // halfDayDate, // Half Day 2023-07-06 --> is a business day + LocalDate.of(2023, 7, 12), // WED + LocalDate.of(2023, 7, 13), // THURS + } ; + + final LocalDate[] bus = { + LocalDate.of(2023,7,3), + LocalDate.of(2023,7,6), + LocalDate.of(2023,7,7), + LocalDate.of(2023,7,8), + LocalDate.of(2023,7,9), + LocalDate.of(2023,7,10), + LocalDate.of(2023,7,11), + LocalDate.of(2023,7,14), + LocalDate.of(2023,7,15), + }; + + assertEquals(bus.length,bCalendar.numberBusinessDates(start, end)); + assertEquals(bus.length,bCalendar.numberBusinessDates(start.toString(), end.toString())); + assertEquals(bus.length,bCalendar.numberBusinessDates(start.atTime(1,24).atZone(timeZone), end.atTime(1,24).atZone(timeZone))); + assertEquals(bus.length,bCalendar.numberBusinessDates(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant())); + + assertEquals(bus.length-1,bCalendar.numberBusinessDates(start, end, true, false)); + assertEquals(bus.length-1,bCalendar.numberBusinessDates(start.toString(), end.toString(), true, false)); + assertEquals(bus.length-1,bCalendar.numberBusinessDates(start.atTime(1,24).atZone(timeZone), end.atTime(1,24).atZone(timeZone), true, false)); + assertEquals(bus.length-1,bCalendar.numberBusinessDates(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant(), true, false)); + + assertEquals(bus.length-1,bCalendar.numberBusinessDates(start, end, false, true)); + assertEquals(bus.length-1,bCalendar.numberBusinessDates(start.toString(), end.toString(), false, true)); + assertEquals(bus.length-1,bCalendar.numberBusinessDates(start.atTime(1,24).atZone(timeZone), end.atTime(1,24).atZone(timeZone), false, true)); + assertEquals(bus.length-1,bCalendar.numberBusinessDates(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant(), false, true)); + + assertEquals(bus.length-2,bCalendar.numberBusinessDates(start, end, false, false)); + assertEquals(bus.length-2,bCalendar.numberBusinessDates(start.toString(), end.toString(), false, false)); + assertEquals(bus.length-2,bCalendar.numberBusinessDates(start.atTime(1,24).atZone(timeZone), end.atTime(1,24).atZone(timeZone), false, false)); + assertEquals(bus.length-2,bCalendar.numberBusinessDates(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant(), false, false)); + } + + public void testNonBusinessDates() { + + final LocalDate start = LocalDate.of(2023,7,3); + final LocalDate end = LocalDate.of(2023,7,15); + + final LocalDate[] nonBus = { + holidayDate1, // Holiday 2023-07-04 + LocalDate.of(2023, 7, 5), // WED + // halfDayDate, // Half Day 2023-07-06 --> is a business day + LocalDate.of(2023, 7, 12), // WED + LocalDate.of(2023, 7, 13), // THURS + } ; + + final LocalDate[] bus = { + LocalDate.of(2023,7,3), + LocalDate.of(2023,7,6), + LocalDate.of(2023,7,7), + LocalDate.of(2023,7,8), + LocalDate.of(2023,7,9), + LocalDate.of(2023,7,10), + LocalDate.of(2023,7,11), + LocalDate.of(2023,7,14), + LocalDate.of(2023,7,15), + }; + + assertEquals(nonBus,bCalendar.nonBusinessDates(start, end)); + assertEquals(nonBus,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.copyOfRange(nonBus,0,nonBus.length-1),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), nonBus[nonBus.length-1].atTime(1,24).atZone(timeZone), true, false)); + assertEquals(Arrays.copyOfRange(nonBus,0,nonBus.length-1),bCalendar.nonBusinessDates(nonBus[0].atTime(1,24).atZone(timeZone).toInstant(), nonBus[nonBus.length-1].atTime(1,24).atZone(timeZone).toInstant(), true, false)); + + assertEquals(Arrays.copyOfRange(nonBus,1,nonBus.length),bCalendar.nonBusinessDates(nonBus[0], nonBus[nonBus.length-1], false, true)); + assertEquals(Arrays.copyOfRange(nonBus,1,nonBus.length),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), nonBus[nonBus.length-1].atTime(1,24).atZone(timeZone), false, true)); + assertEquals(Arrays.copyOfRange(nonBus,1,nonBus.length),bCalendar.nonBusinessDates(nonBus[0].atTime(1,24).atZone(timeZone).toInstant(), nonBus[nonBus.length-1].atTime(1,24).atZone(timeZone).toInstant(), false, true)); + + assertEquals(Arrays.copyOfRange(nonBus,1,nonBus.length-1),bCalendar.nonBusinessDates(nonBus[0], nonBus[nonBus.length-1], false, false)); + assertEquals(Arrays.copyOfRange(nonBus,1,nonBus.length-1),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), nonBus[nonBus.length-1].atTime(1,24).atZone(timeZone), false, false)); + assertEquals(Arrays.copyOfRange(nonBus,1,nonBus.length-1),bCalendar.nonBusinessDates(nonBus[0].atTime(1,24).atZone(timeZone).toInstant(), nonBus[nonBus.length-1].atTime(1,24).atZone(timeZone).toInstant(), false, false)); + } + + public void testNumberNonBusinessDates() { + + final LocalDate start = LocalDate.of(2023,7,3); + final LocalDate end = LocalDate.of(2023,7,15); + + final LocalDate[] nonBus = { + holidayDate1, // Holiday 2023-07-04 + LocalDate.of(2023, 7, 5), // WED + // halfDayDate, // Half Day 2023-07-06 --> is a business day + LocalDate.of(2023, 7, 12), // WED + LocalDate.of(2023, 7, 13), // THURS + } ; + + final LocalDate[] bus = { + LocalDate.of(2023,7,3), + LocalDate.of(2023,7,6), + LocalDate.of(2023,7,7), + LocalDate.of(2023,7,8), + LocalDate.of(2023,7,9), + LocalDate.of(2023,7,10), + LocalDate.of(2023,7,11), + LocalDate.of(2023,7,14), + LocalDate.of(2023,7,15), + }; + + assertEquals(nonBus.length,bCalendar.numberNonBusinessDates(start, end)); + assertEquals(nonBus.length,bCalendar.numberNonBusinessDates(start.toString(), end.toString())); + assertEquals(nonBus.length,bCalendar.numberNonBusinessDates(start.atTime(1,24).atZone(timeZone), end.atTime(1,24).atZone(timeZone))); + assertEquals(nonBus.length,bCalendar.numberNonBusinessDates(start.atTime(1,24).atZone(timeZone).toInstant(), end.atTime(1,24).atZone(timeZone).toInstant())); + + assertEquals(nonBus.length-1,bCalendar.numberNonBusinessDates(nonBus[0], nonBus[nonBus.length-1], true, false)); + assertEquals(nonBus.length-1,bCalendar.numberNonBusinessDates(nonBus[0].toString(), nonBus[nonBus.length-1].toString(), true, false)); + assertEquals(nonBus.length-1,bCalendar.numberNonBusinessDates(nonBus[0].atTime(1,24).atZone(timeZone), nonBus[nonBus.length-1].atTime(1,24).atZone(timeZone), true, false)); + assertEquals(nonBus.length-1,bCalendar.numberNonBusinessDates(nonBus[0].atTime(1,24).atZone(timeZone).toInstant(), nonBus[nonBus.length-1].atTime(1,24).atZone(timeZone).toInstant(), true, false)); + + assertEquals(nonBus.length-1,bCalendar.numberNonBusinessDates(nonBus[0], nonBus[nonBus.length-1], false, true)); + assertEquals(nonBus.length-1,bCalendar.numberNonBusinessDates(nonBus[0].toString(), nonBus[nonBus.length-1].toString(), false, true)); + assertEquals(nonBus.length-1,bCalendar.numberNonBusinessDates(nonBus[0].atTime(1,24).atZone(timeZone), nonBus[nonBus.length-1].atTime(1,24).atZone(timeZone), false, true)); + assertEquals(nonBus.length-1,bCalendar.numberNonBusinessDates(nonBus[0].atTime(1,24).atZone(timeZone).toInstant(), nonBus[nonBus.length-1].atTime(1,24).atZone(timeZone).toInstant(), false, true)); + + assertEquals(nonBus.length-2,bCalendar.numberNonBusinessDates(nonBus[0], nonBus[nonBus.length-1], false, false)); + assertEquals(nonBus.length-2,bCalendar.numberNonBusinessDates(nonBus[0].toString(), nonBus[nonBus.length-1].toString(), false, false)); + assertEquals(nonBus.length-2,bCalendar.numberNonBusinessDates(nonBus[0].atTime(1,24).atZone(timeZone), nonBus[nonBus.length-1].atTime(1,24).atZone(timeZone), false, false)); + assertEquals(nonBus.length-2,bCalendar.numberNonBusinessDates(nonBus[0].atTime(1,24).atZone(timeZone).toInstant(), nonBus[nonBus.length-1].atTime(1,24).atZone(timeZone).toInstant(), false, false)); + } + +// public void testNumberBusinessDates() { +// +// bCalendar.businessDates(start, end, startInclusive, endInclusive) +// +// *** +// // Normal bus day +// LocalDate date = LocalDate.of(2023, 7, 11); +// ZonedDateTime tBefore = date.atTime(8, 2, 3).atZone(timeZone); +// ZonedDateTime tIn = date.atTime(10, 2, 3).atZone(timeZone); +// ZonedDateTime tAfter = date.atTime(22, 2, 3).atZone(timeZone); +// assertEquals(1.0, bCalendar.fractionBusinessDayRemaining(tBefore)); +// assertEquals(1.0, bCalendar.fractionBusinessDayRemaining(tBefore.toInstant())); +// assertEquals(1 - (double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) schedule.businessNanos(), bCalendar.fractionBusinessDayRemaining(tIn)); +// assertEquals(1 - (double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) schedule.businessNanos(), bCalendar.fractionBusinessDayRemaining(tIn.toInstant())); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter)); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter.toInstant())); +// +// // Weekend day -- THURS +// date = LocalDate.of(2023, 7, 13); +// tBefore = date.atTime(8, 2, 3).atZone(timeZone); +// tIn = date.atTime(10, 2, 3).atZone(timeZone); +// tAfter = date.atTime(22, 2, 3).atZone(timeZone); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tBefore)); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tBefore.toInstant())); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tIn)); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tIn.toInstant())); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter)); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter.toInstant())); +// +// // Holiday +// date = holidayDate1; +// tBefore = date.atTime(8, 2, 3).atZone(timeZone); +// tIn = date.atTime(10, 2, 3).atZone(timeZone); +// tAfter = date.atTime(22, 2, 3).atZone(timeZone); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tBefore)); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tBefore.toInstant())); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tIn)); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tIn.toInstant())); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter)); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter.toInstant())); +// +// // Half day +// date = halfDayDate; +// tBefore = date.atTime(8, 2, 3).atZone(timeZone); +// tIn = date.atTime(10, 2, 3).atZone(timeZone); +// tAfter = date.atTime(22, 2, 3).atZone(timeZone); +// assertEquals(1.0, bCalendar.fractionBusinessDayRemaining(tBefore)); +// assertEquals(1.0, bCalendar.fractionBusinessDayRemaining(tBefore.toInstant())); +// assertEquals(1 - (double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) halfDay.businessNanos(), bCalendar.fractionBusinessDayRemaining(tIn)); +// assertEquals(1 - (double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) halfDay.businessNanos(), bCalendar.fractionBusinessDayRemaining(tIn.toInstant())); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter)); +// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter.toInstant())); +// +// // Current date +// assertEquals(bCalendar.fractionBusinessDayRemaining(DateTimeUtils.now()), bCalendar.fractionBusinessDayRemaining()); +// +// // Check that all dates in the range work +// for (LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { +// bCalendar.fractionBusinessDayRemaining(d.atTime(12, 34).atZone(timeZone)); +// } +// +// try { +// bCalendar.fractionBusinessDayRemaining((ZonedDateTime) null); +// fail("should throw an exception"); +// } catch (RequirementFailure ignored) { +// } +// +// try { +// bCalendar.fractionBusinessDayRemaining((Instant) null); +// fail("should throw an exception"); +// } catch (RequirementFailure ignored) { +// } +// } + public void testFail() { fail(); } From 03eda36756b66e9a797e389eeb9060c969dd9f63 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Mon, 17 Jul 2023 13:38:40 -0600 Subject: [PATCH 042/150] Unit test: * BusinessCalendar - Differences --- .../time/calendar/TestBusinessCalendar.java | 233 ++++++++++-------- 1 file changed, 124 insertions(+), 109 deletions(-) diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java index ca82061b8fe..5627e6ae56a 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java @@ -7,6 +7,7 @@ import io.deephaven.time.DateTimeUtils; import java.time.*; +import java.time.temporal.ChronoUnit; import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -734,13 +735,13 @@ public void testBusinessDates() { final LocalDate start = LocalDate.of(2023,7,3); final LocalDate end = LocalDate.of(2023,7,15); - final LocalDate[] nonBus = { - holidayDate1, // Holiday 2023-07-04 - LocalDate.of(2023, 7, 5), // WED - // halfDayDate, // Half Day 2023-07-06 --> is a business day - LocalDate.of(2023, 7, 12), // WED - LocalDate.of(2023, 7, 13), // THURS - } ; +// final LocalDate[] nonBus = { +// holidayDate1, // Holiday 2023-07-04 +// LocalDate.of(2023, 7, 5), // WED +// // halfDayDate, // Half Day 2023-07-06 --> is a business day +// LocalDate.of(2023, 7, 12), // WED +// LocalDate.of(2023, 7, 13), // THURS +// } ; final LocalDate[] bus = { LocalDate.of(2023,7,3), @@ -780,13 +781,13 @@ public void testNumberBusinessDates() { final LocalDate start = LocalDate.of(2023,7,3); final LocalDate end = LocalDate.of(2023,7,15); - final LocalDate[] nonBus = { - holidayDate1, // Holiday 2023-07-04 - LocalDate.of(2023, 7, 5), // WED - // halfDayDate, // Half Day 2023-07-06 --> is a business day - LocalDate.of(2023, 7, 12), // WED - LocalDate.of(2023, 7, 13), // THURS - } ; +// final LocalDate[] nonBus = { +// holidayDate1, // Holiday 2023-07-04 +// LocalDate.of(2023, 7, 5), // WED +// // halfDayDate, // Half Day 2023-07-06 --> is a business day +// LocalDate.of(2023, 7, 12), // WED +// LocalDate.of(2023, 7, 13), // THURS +// } ; final LocalDate[] bus = { LocalDate.of(2023,7,3), @@ -834,17 +835,17 @@ public void testNonBusinessDates() { LocalDate.of(2023, 7, 13), // THURS } ; - final LocalDate[] bus = { - LocalDate.of(2023,7,3), - LocalDate.of(2023,7,6), - LocalDate.of(2023,7,7), - LocalDate.of(2023,7,8), - LocalDate.of(2023,7,9), - LocalDate.of(2023,7,10), - LocalDate.of(2023,7,11), - LocalDate.of(2023,7,14), - LocalDate.of(2023,7,15), - }; +// final LocalDate[] bus = { +// LocalDate.of(2023,7,3), +// LocalDate.of(2023,7,6), +// LocalDate.of(2023,7,7), +// LocalDate.of(2023,7,8), +// LocalDate.of(2023,7,9), +// LocalDate.of(2023,7,10), +// LocalDate.of(2023,7,11), +// LocalDate.of(2023,7,14), +// LocalDate.of(2023,7,15), +// }; assertEquals(nonBus,bCalendar.nonBusinessDates(start, end)); assertEquals(nonBus,bCalendar.nonBusinessDates(start.toString(), end.toString())); @@ -880,17 +881,17 @@ public void testNumberNonBusinessDates() { LocalDate.of(2023, 7, 13), // THURS } ; - final LocalDate[] bus = { - LocalDate.of(2023,7,3), - LocalDate.of(2023,7,6), - LocalDate.of(2023,7,7), - LocalDate.of(2023,7,8), - LocalDate.of(2023,7,9), - LocalDate.of(2023,7,10), - LocalDate.of(2023,7,11), - LocalDate.of(2023,7,14), - LocalDate.of(2023,7,15), - }; +// final LocalDate[] bus = { +// LocalDate.of(2023,7,3), +// LocalDate.of(2023,7,6), +// LocalDate.of(2023,7,7), +// LocalDate.of(2023,7,8), +// LocalDate.of(2023,7,9), +// LocalDate.of(2023,7,10), +// LocalDate.of(2023,7,11), +// LocalDate.of(2023,7,14), +// LocalDate.of(2023,7,15), +// }; assertEquals(nonBus.length,bCalendar.numberNonBusinessDates(start, end)); assertEquals(nonBus.length,bCalendar.numberNonBusinessDates(start.toString(), end.toString())); @@ -913,79 +914,93 @@ public void testNumberNonBusinessDates() { assertEquals(nonBus.length-2,bCalendar.numberNonBusinessDates(nonBus[0].atTime(1,24).atZone(timeZone).toInstant(), nonBus[nonBus.length-1].atTime(1,24).atZone(timeZone).toInstant(), false, false)); } -// public void testNumberBusinessDates() { -// -// bCalendar.businessDates(start, end, startInclusive, endInclusive) -// -// *** -// // Normal bus day -// LocalDate date = LocalDate.of(2023, 7, 11); -// ZonedDateTime tBefore = date.atTime(8, 2, 3).atZone(timeZone); -// ZonedDateTime tIn = date.atTime(10, 2, 3).atZone(timeZone); -// ZonedDateTime tAfter = date.atTime(22, 2, 3).atZone(timeZone); -// assertEquals(1.0, bCalendar.fractionBusinessDayRemaining(tBefore)); -// assertEquals(1.0, bCalendar.fractionBusinessDayRemaining(tBefore.toInstant())); -// assertEquals(1 - (double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) schedule.businessNanos(), bCalendar.fractionBusinessDayRemaining(tIn)); -// assertEquals(1 - (double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) schedule.businessNanos(), bCalendar.fractionBusinessDayRemaining(tIn.toInstant())); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter)); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter.toInstant())); -// -// // Weekend day -- THURS -// date = LocalDate.of(2023, 7, 13); -// tBefore = date.atTime(8, 2, 3).atZone(timeZone); -// tIn = date.atTime(10, 2, 3).atZone(timeZone); -// tAfter = date.atTime(22, 2, 3).atZone(timeZone); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tBefore)); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tBefore.toInstant())); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tIn)); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tIn.toInstant())); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter)); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter.toInstant())); -// -// // Holiday -// date = holidayDate1; -// tBefore = date.atTime(8, 2, 3).atZone(timeZone); -// tIn = date.atTime(10, 2, 3).atZone(timeZone); -// tAfter = date.atTime(22, 2, 3).atZone(timeZone); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tBefore)); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tBefore.toInstant())); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tIn)); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tIn.toInstant())); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter)); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter.toInstant())); -// -// // Half day -// date = halfDayDate; -// tBefore = date.atTime(8, 2, 3).atZone(timeZone); -// tIn = date.atTime(10, 2, 3).atZone(timeZone); -// tAfter = date.atTime(22, 2, 3).atZone(timeZone); -// assertEquals(1.0, bCalendar.fractionBusinessDayRemaining(tBefore)); -// assertEquals(1.0, bCalendar.fractionBusinessDayRemaining(tBefore.toInstant())); -// assertEquals(1 - (double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) halfDay.businessNanos(), bCalendar.fractionBusinessDayRemaining(tIn)); -// assertEquals(1 - (double) bCalendar.businessSchedule(date).businessNanosElapsed(tIn.toInstant()) / (double) halfDay.businessNanos(), bCalendar.fractionBusinessDayRemaining(tIn.toInstant())); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter)); -// assertEquals(0.0, bCalendar.fractionBusinessDayRemaining(tAfter.toInstant())); -// -// // Current date -// assertEquals(bCalendar.fractionBusinessDayRemaining(DateTimeUtils.now()), bCalendar.fractionBusinessDayRemaining()); -// -// // Check that all dates in the range work -// for (LocalDate d = firstValidDate; !d.isAfter(lastValidDate); d = d.plusDays(1)) { -// bCalendar.fractionBusinessDayRemaining(d.atTime(12, 34).atZone(timeZone)); -// } -// -// try { -// bCalendar.fractionBusinessDayRemaining((ZonedDateTime) null); -// fail("should throw an exception"); -// } catch (RequirementFailure ignored) { -// } -// -// try { -// bCalendar.fractionBusinessDayRemaining((Instant) null); -// fail("should throw an exception"); -// } catch (RequirementFailure ignored) { -// } -// } + public void testDiffBusinessNanos() { + // Same day + final ZonedDateTime zdt1 = LocalDate.of(2023,7,3).atTime(9,27).atZone(timeZone); + final ZonedDateTime zdt2 = LocalDate.of(2023,7,3).atTime(12,10).atZone(timeZone); + + assertEquals(zdt1.until(zdt2, ChronoUnit.NANOS), bCalendar.diffBusinessNanos(zdt1,zdt2)); + assertEquals(-zdt1.until(zdt2, ChronoUnit.NANOS), bCalendar.diffBusinessNanos(zdt2,zdt1)); + assertEquals(zdt1.until(zdt2, ChronoUnit.NANOS), bCalendar.diffBusinessNanos(zdt1.toInstant(),zdt2.toInstant())); + assertEquals(-zdt1.until(zdt2, ChronoUnit.NANOS), bCalendar.diffBusinessNanos(zdt2.toInstant(),zdt1.toInstant())); + + // Multiple holidays + final ZonedDateTime zdt3 = LocalDate.of(2023,7,8).atTime(12,54).atZone(timeZone); + final long target = schedule.businessNanosRemaining(zdt1.toLocalTime()) // 2023-07-03 + // 2023-07-04 holiday + // 2023-07-05 weekend WED + + halfDay.businessNanos() // 2023-07-06 half day + + schedule.businessNanos() // normal day + + schedule.businessNanosElapsed(zdt3.toLocalTime()); + + assertEquals(target, bCalendar.diffBusinessNanos(zdt1, zdt3)); + assertEquals(-target, bCalendar.diffBusinessNanos(zdt3, zdt1)); + assertEquals(target, bCalendar.diffBusinessNanos(zdt1.toInstant(), zdt3.toInstant())); + assertEquals(-target, bCalendar.diffBusinessNanos(zdt3.toInstant(), zdt1.toInstant())); + } + + public void testDiffNonBusinessNanos() { + // Same day + final ZonedDateTime zdt1 = LocalDate.of(2023,7,3).atTime(6,27).atZone(timeZone); + final ZonedDateTime zdt2 = LocalDate.of(2023,7,3).atTime(15,10).atZone(timeZone); + + assertEquals(DateTimeUtils.diffNanos(zdt1, zdt2) - bCalendar.diffBusinessNanos(zdt1,zdt2), bCalendar.diffNonBusinessNanos(zdt1,zdt2)); + assertEquals(- bCalendar.diffNonBusinessNanos(zdt1,zdt2), bCalendar.diffNonBusinessNanos(zdt2,zdt1)); + assertEquals(DateTimeUtils.diffNanos(zdt1, zdt2) - bCalendar.diffBusinessNanos(zdt1,zdt2), bCalendar.diffNonBusinessNanos(zdt1.toInstant(),zdt2.toInstant())); + assertEquals(- bCalendar.diffNonBusinessNanos(zdt1,zdt2), bCalendar.diffNonBusinessNanos(zdt2.toInstant(),zdt1.toInstant())); + + // Multiple holidays + final ZonedDateTime zdt3 = LocalDate.of(2023,7,8).atTime(12,54).atZone(timeZone); + final long target = DateTimeUtils.diffNanos(zdt1, zdt2) - bCalendar.diffBusinessNanos(zdt1, zdt3); + + assertEquals(DateTimeUtils.diffNanos(zdt1, zdt3) - bCalendar.diffBusinessNanos(zdt1, zdt3), bCalendar.diffNonBusinessNanos(zdt1,zdt3)); + assertEquals(- bCalendar.diffNonBusinessNanos(zdt1,zdt3), bCalendar.diffNonBusinessNanos(zdt3,zdt1)); + assertEquals(DateTimeUtils.diffNanos(zdt1, zdt3) - bCalendar.diffBusinessNanos(zdt1, zdt3), bCalendar.diffNonBusinessNanos(zdt1.toInstant(),zdt3.toInstant())); + assertEquals(- bCalendar.diffNonBusinessNanos(zdt1,zdt3), bCalendar.diffNonBusinessNanos(zdt3.toInstant(),zdt1.toInstant())); + } + + public void testDiffBusinessDays() { + final ZonedDateTime zdt1 = LocalDate.of(2023,7,3).atTime(6,27).atZone(timeZone); + final ZonedDateTime zdt2 = LocalDate.of(2023,7,10).atTime(15,10).atZone(timeZone); + + assertEquals(bCalendar.diffBusinessNanos(zdt1, zdt2)/(double)schedule.businessNanos(), bCalendar.diffBusinessDays(zdt1, zdt2)); + assertEquals(bCalendar.diffBusinessNanos(zdt1, zdt2)/(double)schedule.businessNanos(), bCalendar.diffBusinessDays(zdt1.toInstant(), zdt2.toInstant())); + } + + public void testDiffBusinessYears() { + final ZonedDateTime zdt1 = LocalDate.of(2023,1,1).atTime(6,27).atZone(timeZone); + final ZonedDateTime zdt2 = LocalDate.of(2023,12,31).atTime(15,10).atZone(timeZone); + + assertEquals(1.0, bCalendar.diffBusinessYears(zdt1, zdt2)); + assertEquals(1.0, bCalendar.diffBusinessYears(zdt1.toInstant(), zdt2.toInstant())); + + final ZonedDateTime zdt3 = LocalDate.of(2024,12,31).atTime(15,10).atZone(timeZone); + + assertEquals(2.0, bCalendar.diffBusinessYears(zdt1, zdt3)); + assertEquals(2.0, bCalendar.diffBusinessYears(zdt1.toInstant(), zdt3.toInstant())); + + final ZonedDateTime zdt4 = LocalDate.of(2025,12,31).atTime(15,10).atZone(timeZone); + + assertEquals(3.0, bCalendar.diffBusinessYears(zdt1, zdt4)); + assertEquals(3.0, bCalendar.diffBusinessYears(zdt1.toInstant(), zdt4.toInstant())); + + final ZonedDateTime zdt5 = LocalDate.of(2022,12,1).atTime(15,10).atZone(timeZone); + final ZonedDateTime zdt6 = LocalDate.of(2026,1,31).atTime(15,10).atZone(timeZone); + final long length2022 = bCalendar.diffBusinessNanos( + LocalDate.of(2022,1,1).atTime(0,0).atZone(timeZone), + LocalDate.of(2022,12,31).atTime(23,59).atZone(timeZone) + ); + final long length2026 = bCalendar.diffBusinessNanos( + LocalDate.of(2026,1,1).atTime(0,0).atZone(timeZone), + LocalDate.of(2026,12,31).atTime(23,59).atZone(timeZone) + ); + final double start = bCalendar.diffBusinessNanos(zdt5, zdt1) / (double)length2022; + final double end = bCalendar.diffBusinessNanos(zdt4, zdt6) / (double) length2026; + + assertEquals(3.0+start+end, bCalendar.diffBusinessYears(zdt5, zdt6), 1e-5); + assertEquals(3.0+start+end, bCalendar.diffBusinessYears(zdt5.toInstant(), zdt6.toInstant()), 1e-5); + } + public void testFail() { fail(); From f1bc1be9f56106d3e0d61334bcea274e3153a0d1 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Mon, 17 Jul 2023 14:16:22 -0600 Subject: [PATCH 043/150] Unit test: * BusinessCalendar - Arithmetic --- .../time/calendar/BusinessCalendar.java | 2 +- .../time/calendar/TestBusinessCalendar.java | 1941 +++-------------- 2 files changed, 322 insertions(+), 1621 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index 9bc39059b92..189c06ad574 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -1427,7 +1427,7 @@ public LocalDate plusBusinessDays(final LocalDate date, final int days) { Require.neqNull(date, "date"); if (days == 0) { - return isBusinessDay() ? date : null; + return isBusinessDay(date) ? date : null; } final int step = days > 0 ? 1 : -1; diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java index 5627e6ae56a..3c912789073 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java @@ -13,7 +13,7 @@ import java.util.Map; import java.util.Set; -@SuppressWarnings({"ConstantConditions", "unchecked", "rawtypes"}) +@SuppressWarnings({"unchecked", "rawtypes"}) public class TestBusinessCalendar extends TestCalendar { private final LocalDate firstValidDate = LocalDate.of(2000, 1, 1); private final LocalDate lastValidDate = LocalDate.of(2050, 12, 31); @@ -951,7 +951,6 @@ public void testDiffNonBusinessNanos() { // Multiple holidays final ZonedDateTime zdt3 = LocalDate.of(2023,7,8).atTime(12,54).atZone(timeZone); - final long target = DateTimeUtils.diffNanos(zdt1, zdt2) - bCalendar.diffBusinessNanos(zdt1, zdt3); assertEquals(DateTimeUtils.diffNanos(zdt1, zdt3) - bCalendar.diffBusinessNanos(zdt1, zdt3), bCalendar.diffNonBusinessNanos(zdt1,zdt3)); assertEquals(- bCalendar.diffNonBusinessNanos(zdt1,zdt3), bCalendar.diffNonBusinessNanos(zdt3,zdt1)); @@ -1001,1626 +1000,328 @@ public void testDiffBusinessYears() { assertEquals(3.0+start+end, bCalendar.diffBusinessYears(zdt5.toInstant(), zdt6.toInstant()), 1e-5); } + public void testPlusBusinessDays() { + // 2023-07-03 normal day + // 2023-07-04 holiday + // 2023-07-05 weekend + // 2023-07-06 half day + // 2023-07-07 normal day + // 2023-07-08 normal day + // 2023-07-09 normal day + // 2023-07-10 normal day + // 2023-07-11 normal day + // 2023-07-12 weekend + // 2023-07-13 weekend + // 2023-07-14 normal day + // 2023-07-15 normal day + + LocalDate d = LocalDate.of(2023,7,3); + String s = d.toString(); + ZonedDateTime z = d.atTime(1,24).atZone(timeZone); + Instant i = z.toInstant(); + + assertEquals(d,bCalendar.plusBusinessDays(d, 0)); + assertEquals(d,bCalendar.plusBusinessDays(s, 0)); + assertEquals(d,bCalendar.plusBusinessDays(z, 0)); + assertEquals(d,bCalendar.plusBusinessDays(i, 0)); + + assertEquals(LocalDate.of(2023,7,6),bCalendar.plusBusinessDays(d, 1)); + assertEquals(LocalDate.of(2023,7,6),bCalendar.plusBusinessDays(s, 1)); + assertEquals(LocalDate.of(2023,7,6),bCalendar.plusBusinessDays(z, 1)); + assertEquals(LocalDate.of(2023,7,6),bCalendar.plusBusinessDays(i, 1)); + + assertEquals(LocalDate.of(2023,7,7),bCalendar.plusBusinessDays(d, 2)); + assertEquals(LocalDate.of(2023,7,7),bCalendar.plusBusinessDays(s, 2)); + assertEquals(LocalDate.of(2023,7,7),bCalendar.plusBusinessDays(z, 2)); + assertEquals(LocalDate.of(2023,7,7),bCalendar.plusBusinessDays(i, 2)); + + assertEquals(LocalDate.of(2023,7,14),bCalendar.plusBusinessDays(d, 7)); + assertEquals(LocalDate.of(2023,7,14),bCalendar.plusBusinessDays(s, 7)); + assertEquals(LocalDate.of(2023,7,14),bCalendar.plusBusinessDays(z, 7)); + assertEquals(LocalDate.of(2023,7,14),bCalendar.plusBusinessDays(i, 7)); + + d = LocalDate.of(2023,7,14); + s = d.toString(); + z = d.atTime(1,24).atZone(timeZone); + i = z.toInstant(); + + assertEquals(d,bCalendar.plusBusinessDays(d, 0)); + assertEquals(d,bCalendar.plusBusinessDays(s, 0)); + assertEquals(d,bCalendar.plusBusinessDays(z, 0)); + assertEquals(d,bCalendar.plusBusinessDays(i, 0)); + + assertEquals(LocalDate.of(2023,7,11),bCalendar.plusBusinessDays(d, -1)); + assertEquals(LocalDate.of(2023,7,11),bCalendar.plusBusinessDays(s, -1)); + assertEquals(LocalDate.of(2023,7,11),bCalendar.plusBusinessDays(z, -1)); + assertEquals(LocalDate.of(2023,7,11),bCalendar.plusBusinessDays(i, -1)); + + assertEquals(LocalDate.of(2023,7,10),bCalendar.plusBusinessDays(d, -2)); + assertEquals(LocalDate.of(2023,7,10),bCalendar.plusBusinessDays(s, -2)); + assertEquals(LocalDate.of(2023,7,10),bCalendar.plusBusinessDays(z, -2)); + assertEquals(LocalDate.of(2023,7,10),bCalendar.plusBusinessDays(i, -2)); + + assertEquals(LocalDate.of(2023,7,3),bCalendar.plusBusinessDays(d, -7)); + assertEquals(LocalDate.of(2023,7,3),bCalendar.plusBusinessDays(s, -7)); + assertEquals(LocalDate.of(2023,7,3),bCalendar.plusBusinessDays(z, -7)); + assertEquals(LocalDate.of(2023,7,3),bCalendar.plusBusinessDays(i, -7)); + + d = LocalDate.of(2023,7,4); + s = d.toString(); + z = d.atTime(1,24).atZone(timeZone); + i = z.toInstant(); + + assertNull(bCalendar.plusBusinessDays(d, 0)); + assertNull(bCalendar.plusBusinessDays(s, 0)); + assertNull(bCalendar.plusBusinessDays(z, 0)); + assertNull(bCalendar.plusBusinessDays(i, 0)); + } - public void testFail() { - fail(); + public void testMinusBusinessDays() { + // 2023-07-03 normal day + // 2023-07-04 holiday + // 2023-07-05 weekend + // 2023-07-06 half day + // 2023-07-07 normal day + // 2023-07-08 normal day + // 2023-07-09 normal day + // 2023-07-10 normal day + // 2023-07-11 normal day + // 2023-07-12 weekend + // 2023-07-13 weekend + // 2023-07-14 normal day + // 2023-07-15 normal day + + LocalDate d = LocalDate.of(2023,7,3); + String s = d.toString(); + ZonedDateTime z = d.atTime(1,24).atZone(timeZone); + Instant i = z.toInstant(); + + assertEquals(d,bCalendar.minusBusinessDays(d, 0)); + assertEquals(d,bCalendar.minusBusinessDays(s, 0)); + assertEquals(d,bCalendar.minusBusinessDays(z, 0)); + assertEquals(d,bCalendar.minusBusinessDays(i, 0)); + + assertEquals(LocalDate.of(2023,7,6),bCalendar.minusBusinessDays(d, -1)); + assertEquals(LocalDate.of(2023,7,6),bCalendar.minusBusinessDays(s, -1)); + assertEquals(LocalDate.of(2023,7,6),bCalendar.minusBusinessDays(z, -1)); + assertEquals(LocalDate.of(2023,7,6),bCalendar.minusBusinessDays(i, -1)); + + assertEquals(LocalDate.of(2023,7,7),bCalendar.minusBusinessDays(d, -2)); + assertEquals(LocalDate.of(2023,7,7),bCalendar.minusBusinessDays(s, -2)); + assertEquals(LocalDate.of(2023,7,7),bCalendar.minusBusinessDays(z, -2)); + assertEquals(LocalDate.of(2023,7,7),bCalendar.minusBusinessDays(i, -2)); + + assertEquals(LocalDate.of(2023,7,14),bCalendar.minusBusinessDays(d, -7)); + assertEquals(LocalDate.of(2023,7,14),bCalendar.minusBusinessDays(s, -7)); + assertEquals(LocalDate.of(2023,7,14),bCalendar.minusBusinessDays(z, -7)); + assertEquals(LocalDate.of(2023,7,14),bCalendar.minusBusinessDays(i, -7)); + + d = LocalDate.of(2023,7,14); + s = d.toString(); + z = d.atTime(1,24).atZone(timeZone); + i = z.toInstant(); + + assertEquals(d,bCalendar.minusBusinessDays(d, 0)); + assertEquals(d,bCalendar.minusBusinessDays(s, 0)); + assertEquals(d,bCalendar.minusBusinessDays(z, 0)); + assertEquals(d,bCalendar.minusBusinessDays(i, 0)); + + assertEquals(LocalDate.of(2023,7,11),bCalendar.minusBusinessDays(d, 1)); + assertEquals(LocalDate.of(2023,7,11),bCalendar.minusBusinessDays(s, 1)); + assertEquals(LocalDate.of(2023,7,11),bCalendar.minusBusinessDays(z, 1)); + assertEquals(LocalDate.of(2023,7,11),bCalendar.minusBusinessDays(i, 1)); + + assertEquals(LocalDate.of(2023,7,10),bCalendar.minusBusinessDays(d, 2)); + assertEquals(LocalDate.of(2023,7,10),bCalendar.minusBusinessDays(s, 2)); + assertEquals(LocalDate.of(2023,7,10),bCalendar.minusBusinessDays(z, 2)); + assertEquals(LocalDate.of(2023,7,10),bCalendar.minusBusinessDays(i, 2)); + + assertEquals(LocalDate.of(2023,7,3),bCalendar.minusBusinessDays(d, 7)); + assertEquals(LocalDate.of(2023,7,3),bCalendar.minusBusinessDays(s, 7)); + assertEquals(LocalDate.of(2023,7,3),bCalendar.minusBusinessDays(z, 7)); + assertEquals(LocalDate.of(2023,7,3),bCalendar.minusBusinessDays(i, 7)); + + d = LocalDate.of(2023,7,4); + s = d.toString(); + z = d.atTime(1,24).atZone(timeZone); + i = z.toInstant(); + + assertNull(bCalendar.minusBusinessDays(d, 0)); + assertNull(bCalendar.minusBusinessDays(s, 0)); + assertNull(bCalendar.minusBusinessDays(z, 0)); + assertNull(bCalendar.minusBusinessDays(i, 0)); } + public void testPlusNonBusinessDays() { + // 2023-07-03 normal day + // 2023-07-04 holiday + // 2023-07-05 weekend + // 2023-07-06 half day + // 2023-07-07 normal day + // 2023-07-08 normal day + // 2023-07-09 normal day + // 2023-07-10 normal day + // 2023-07-11 normal day + // 2023-07-12 weekend + // 2023-07-13 weekend + // 2023-07-14 normal day + // 2023-07-15 normal day + + LocalDate d = LocalDate.of(2023,7,3); + String s = d.toString(); + ZonedDateTime z = d.atTime(1,24).atZone(timeZone); + Instant i = z.toInstant(); + + assertNull(bCalendar.plusNonBusinessDays(d, 0)); + assertNull(bCalendar.plusNonBusinessDays(s, 0)); + assertNull(bCalendar.plusNonBusinessDays(z, 0)); + assertNull(bCalendar.plusNonBusinessDays(i, 0)); + + assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(d, 1)); + assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(s, 1)); + assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(z, 1)); + assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(i, 1)); + + assertEquals(LocalDate.of(2023,7,5),bCalendar.plusNonBusinessDays(d, 2)); + assertEquals(LocalDate.of(2023,7,5),bCalendar.plusNonBusinessDays(s, 2)); + assertEquals(LocalDate.of(2023,7,5),bCalendar.plusNonBusinessDays(z, 2)); + assertEquals(LocalDate.of(2023,7,5),bCalendar.plusNonBusinessDays(i, 2)); + + assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(d, 4)); + assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(s, 4)); + assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(z, 4)); + assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(i, 4)); + + d = LocalDate.of(2023,7,14); + s = d.toString(); + z = d.atTime(1,24).atZone(timeZone); + i = z.toInstant(); + + assertNull(bCalendar.plusNonBusinessDays(d, 0)); + assertNull(bCalendar.plusNonBusinessDays(s, 0)); + assertNull(bCalendar.plusNonBusinessDays(z, 0)); + assertNull(bCalendar.plusNonBusinessDays(i, 0)); + + assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(d, -1)); + assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(s, -1)); + assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(z, -1)); + assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(i, -1)); + + assertEquals(LocalDate.of(2023,7,12),bCalendar.plusNonBusinessDays(d, -2)); + assertEquals(LocalDate.of(2023,7,12),bCalendar.plusNonBusinessDays(s, -2)); + assertEquals(LocalDate.of(2023,7,12),bCalendar.plusNonBusinessDays(z, -2)); + assertEquals(LocalDate.of(2023,7,12),bCalendar.plusNonBusinessDays(i, -2)); + + assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(d, -4)); + assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(s, -4)); + assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(z, -4)); + assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(i, -4)); + + d = LocalDate.of(2023,7,4); + s = d.toString(); + z = d.atTime(1,24).atZone(timeZone); + i = z.toInstant(); + + assertNull(bCalendar.plusNonBusinessDays(d, 0)); + assertNull(bCalendar.plusNonBusinessDays(s, 0)); + assertNull(bCalendar.plusNonBusinessDays(z, 0)); + assertNull(bCalendar.plusNonBusinessDays(i, 0)); + } + + public void testMinusNonBusinessDays() { + // 2023-07-03 normal day + // 2023-07-04 holiday + // 2023-07-05 weekend + // 2023-07-06 half day + // 2023-07-07 normal day + // 2023-07-08 normal day + // 2023-07-09 normal day + // 2023-07-10 normal day + // 2023-07-11 normal day + // 2023-07-12 weekend + // 2023-07-13 weekend + // 2023-07-14 normal day + // 2023-07-15 normal day + + LocalDate d = LocalDate.of(2023,7,3); + String s = d.toString(); + ZonedDateTime z = d.atTime(1,24).atZone(timeZone); + Instant i = z.toInstant(); + + assertNull(bCalendar.minusNonBusinessDays(d, 0)); + assertNull(bCalendar.minusNonBusinessDays(s, 0)); + assertNull(bCalendar.minusNonBusinessDays(z, 0)); + assertNull(bCalendar.minusNonBusinessDays(i, 0)); + + assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(d, -1)); + assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(s, -1)); + assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(z, -1)); + assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(i, -1)); + + assertEquals(LocalDate.of(2023,7,5),bCalendar.minusNonBusinessDays(d, -2)); + assertEquals(LocalDate.of(2023,7,5),bCalendar.minusNonBusinessDays(s, -2)); + assertEquals(LocalDate.of(2023,7,5),bCalendar.minusNonBusinessDays(z, -2)); + assertEquals(LocalDate.of(2023,7,5),bCalendar.minusNonBusinessDays(i, -2)); + + assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(d, -4)); + assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(s, -4)); + assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(z, -4)); + assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(i, -4)); + + d = LocalDate.of(2023,7,14); + s = d.toString(); + z = d.atTime(1,24).atZone(timeZone); + i = z.toInstant(); + + assertNull(bCalendar.minusNonBusinessDays(d, 0)); + assertNull(bCalendar.minusNonBusinessDays(s, 0)); + assertNull(bCalendar.minusNonBusinessDays(z, 0)); + assertNull(bCalendar.minusNonBusinessDays(i, 0)); + + assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(d, 1)); + assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(s, 1)); + assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(z, 1)); + assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(i, 1)); + + assertEquals(LocalDate.of(2023,7,12),bCalendar.minusNonBusinessDays(d, 2)); + assertEquals(LocalDate.of(2023,7,12),bCalendar.minusNonBusinessDays(s, 2)); + assertEquals(LocalDate.of(2023,7,12),bCalendar.minusNonBusinessDays(z, 2)); + assertEquals(LocalDate.of(2023,7,12),bCalendar.minusNonBusinessDays(i, 2)); + + assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(d, 4)); + assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(s, 4)); + assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(z, 4)); + assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(i, 4)); + + d = LocalDate.of(2023,7,4); + s = d.toString(); + z = d.atTime(1,24).atZone(timeZone); + i = z.toInstant(); + + assertNull(bCalendar.minusNonBusinessDays(d, 0)); + assertNull(bCalendar.minusNonBusinessDays(s, 0)); + assertNull(bCalendar.minusNonBusinessDays(z, 0)); + assertNull(bCalendar.minusNonBusinessDays(i, 0)); + } + + public void testFutureBusinessDate() { + assertEquals(bCalendar.plusBusinessDays(DateTimeUtils.todayDate(),3), bCalendar.futureBusinessDate(3)); + assertEquals(bCalendar.plusBusinessDays(DateTimeUtils.todayDate(),-3), bCalendar.futureBusinessDate(-3)); + } + + public void testPastBusinessDate() { + assertEquals(bCalendar.minusBusinessDays(DateTimeUtils.todayDate(),3), bCalendar.pastBusinessDate(3)); + assertEquals(bCalendar.minusBusinessDays(DateTimeUtils.todayDate(),-3), bCalendar.pastBusinessDate(-3)); + } + + public void testFutureNonBusinessDate() { + assertEquals(bCalendar.plusNonBusinessDays(DateTimeUtils.todayDate(),3), bCalendar.futureNonBusinessDate(3)); + assertEquals(bCalendar.plusNonBusinessDays(DateTimeUtils.todayDate(),-3), bCalendar.futureNonBusinessDate(-3)); + } + + public void testPastNonBusinessDate() { + assertEquals(bCalendar.minusNonBusinessDays(DateTimeUtils.todayDate(),3), bCalendar.pastNonBusinessDate(3)); + assertEquals(bCalendar.minusNonBusinessDays(DateTimeUtils.todayDate(),-3), bCalendar.pastNonBusinessDate(-3)); + } -// *** rename and implement - -// private static final ZoneId TZ_NY = ZoneId.of("America/New_York"); -// private static final ZoneId TZ_JP = ZoneId.of("Asia/Tokyo"); -// private static final ZoneId TZ_UTC = ZoneId.of("UTC"); -// -// private final BusinessCalendar USNYSE = Calendars.calendar("USNYSE"); -// private final BusinessCalendar JPOSE = Calendars.calendar("JPOSE"); -// private final BusinessCalendar UTC = Calendars.calendar("UTC"); -// -// private final String curDay = "2017-09-27"; -// private File testCal; -// private BusinessCalendar test; -// -// @Override -// public void setUp() throws Exception { -// super.setUp(); -// testCal = File.createTempFile("Test", ".calendar"); -// final FileWriter fw = new FileWriter(testCal); -// fw.write("\n" + -// "\n" + -// "\n" + -// " TEST\n" + -// " NY\n" + -// " en\n" + -// " US\n" + -// " \n" + -// " 09:30,16:00\n" + -// " Saturday\n" + -// " Sunday\n" + -// " \n" + -// ""); -// fw.flush(); -// fw.close(); -// -// -// test = BusinessCalendarParser.loadBusinessCalendar(testCal); -//// test = new BusinessCalendarParser(BusinessCalendarParser.parseBusinessCalendarInputs(testCal)) { -//// @Override -//// public String currentDay() { -//// return curDay; -//// } -//// }; -// } -// -// @Override -// public void tearDown() throws Exception { -// assertTrue(testCal.delete()); -// super.tearDown(); -// } -// -// public void testName() { -// Calendar cal = Calendars.calendar("USNYSE"); -// assertEquals(cal.name(), "USNYSE"); -// } - -// public void testNextDay() { -//// assertEquals("2017-09-28", test.futureDate()); -// assertEquals("2017-09-29", test.futureDate(2)); -// assertEquals("2017-10-11", test.futureDate(14)); -// -// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); -// String day2 = "2016-09-02"; -// assertEquals(USNYSE.futureDate(day1, 2), day2); -// assertEquals(JPOSE.futureDate(day1, 2), day2); -// assertEquals(USNYSE.futureDate(day2, -2), DateTimeUtils.formatDate(day1, TZ_NY)); -// assertEquals(JPOSE.futureDate(day2, -2), DateTimeUtils.formatDate(day1, TZ_JP)); -// -// assertEquals(USNYSE.futureDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_NY)); -// assertEquals(JPOSE.futureDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_JP)); -// -// // leap day -// day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); -// day2 = "2016-02-29"; -// assertEquals(USNYSE.futureDate(day1), day2); -// assertEquals(JPOSE.futureDate(day1), day2); -// -// // new year -// day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); -// day2 = "2014-01-05"; -// assertEquals(USNYSE.futureDate(day1, 5), day2); -// assertEquals(JPOSE.futureDate(day1, 5), day2); -// assertEquals(USNYSE.futureDate(day2, -5), DateTimeUtils.formatDate(day1, TZ_NY)); -// assertEquals(JPOSE.futureDate(day2, -5), DateTimeUtils.formatDate(day1, TZ_JP)); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); -// day2 = "2017-03-13"; -// assertEquals(USNYSE.futureDate(day1), day2); -// assertEquals(JPOSE.futureDate(day1), day2); -// -// // outside calendar range -// day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); -// day2 = "2070-01-01"; -// assertEquals(USNYSE.futureDate(day1), day2); -// assertEquals(JPOSE.futureDate(day1), day2); -// -// day1 = null; -// assertNull(USNYSE.futureDate(day1)); -// assertNull(JPOSE.futureDate(day1)); -// } -// -// public void testNextDayString() { -// String day1 = "2016-08-31"; -// String day2 = "2016-09-04"; -// assertEquals(USNYSE.futureDate(day1, 4), day2); -// assertEquals(JPOSE.futureDate(day1, 4), day2); -// assertEquals(USNYSE.futureDate(day2, -4), day1); -// assertEquals(JPOSE.futureDate(day2, -4), day1); -// -// assertEquals(USNYSE.futureDate(day1, 0), day1); -// assertEquals(JPOSE.futureDate(day1, 0), day1); -// -// // leap day -// day1 = "2016-02-28"; -// day2 = "2016-02-29"; -// assertEquals(USNYSE.futureDate(day1), day2); -// assertEquals(JPOSE.futureDate(day1), day2); -// -// // new year -// day1 = "2013-12-31"; -// day2 = "2014-01-01"; -// assertEquals(USNYSE.futureDate(day1), day2); -// assertEquals(JPOSE.futureDate(day1), day2); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// day1 = "2017-03-12"; -// day2 = "2017-03-15"; -// assertEquals(USNYSE.futureDate(day1, 3), day2); -// assertEquals(JPOSE.futureDate(day1, 3), day2); -// assertEquals(USNYSE.futureDate(day2, -3), day1); -// assertEquals(JPOSE.futureDate(day2, -3), day1); -// -// day1 = null; -// assertNull(USNYSE.futureDate(day1)); -// assertNull(JPOSE.futureDate(day1)); -// -// -// day1 = "2014-03-10"; -// day2 = "2017-03-13"; -// assertEquals(USNYSE.futureDate(day1, 1099), day2); -// -// // incorrectly formatted days -// try { -// USNYSE.futureDate("2018-02-31"); -// fail(); -// } catch (IllegalArgumentException e) { -// // ok -// } -// try { -// USNYSE.futureDate("20193-02-31"); -// fail(); -// } catch (IllegalArgumentException e) { -// // ok -// } -// } -// -// public void testPreviousDay() { -// assertEquals("2017-09-26", test.pastDate()); -// assertEquals("2017-09-25", test.pastDate(2)); -// assertEquals("2017-09-13", test.pastDate(14)); -// -// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); -// Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); -// assertEquals(USNYSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); -// assertEquals(JPOSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); -// -// assertEquals(USNYSE.pastDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_NY)); -// assertEquals(JPOSE.pastDate(day1, 0), DateTimeUtils.formatDate(day1, TZ_JP)); -// -// // leap day -// day1 = DateTimeUtils.parseInstant("2016-02-29T01:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 NY"); -// assertEquals(USNYSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); -// assertEquals(JPOSE.pastDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); -// -// // new year -// day1 = DateTimeUtils.parseInstant("2013-12-29T01:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2014-01-01T01:00:00.000000000 NY"); -// assertEquals(USNYSE.pastDate(day2, 3), DateTimeUtils.formatDate(day1, TZ_NY)); -// assertEquals(JPOSE.pastDate(day2, 3), DateTimeUtils.formatDate(day1, TZ_JP)); -// assertEquals(USNYSE.pastDate(day1, -3), DateTimeUtils.formatDate(day2, TZ_NY)); -// assertEquals(JPOSE.pastDate(day1, -3), DateTimeUtils.formatDate(day2, TZ_JP)); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// day1 = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 NY"); -// assertEquals(USNYSE.pastDate(day2, 2), DateTimeUtils.formatDate(day1, TZ_NY)); -// assertEquals(JPOSE.pastDate(day2, 2), DateTimeUtils.formatDate(day1, TZ_JP)); -// assertEquals(USNYSE.pastDate(day1, -2), DateTimeUtils.formatDate(day2, TZ_NY)); -// assertEquals(JPOSE.pastDate(day1, -2), DateTimeUtils.formatDate(day2, TZ_JP)); -// -// day1 = null; -// assertNull(USNYSE.pastDate(day1)); -// assertNull(JPOSE.pastDate(day1)); -// } -// -// public void testPreviousDayString() { -// String day1 = "2016-08-30"; -// String day2 = "2016-09-01"; -// assertEquals(USNYSE.pastDate(day2, 2), day1); -// assertEquals(JPOSE.pastDate(day2, 2), day1); -// assertEquals(USNYSE.pastDate(day1, -2), day2); -// assertEquals(JPOSE.pastDate(day1, -2), day2); -// -// assertEquals(USNYSE.pastDate(day1, 0), day1); -// assertEquals(JPOSE.pastDate(day1, 0), day1); -// -// // leap day -// day1 = "2016-02-29"; -// day2 = "2016-03-01"; -// assertEquals(USNYSE.pastDate(day2), day1); -// assertEquals(JPOSE.pastDate(day2), day1); -// -// // new year -// day1 = "2013-12-31"; -// day2 = "2014-01-01"; -// assertEquals(USNYSE.pastDate(day2), day1); -// assertEquals(JPOSE.pastDate(day2), day1); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// day1 = "2017-03-10"; -// day2 = "2017-03-13"; -// assertEquals(USNYSE.pastDate(day2, 3), day1); -// assertEquals(JPOSE.pastDate(day2, 3), day1); -// assertEquals(USNYSE.pastDate(day1, -3), day2); -// assertEquals(JPOSE.pastDate(day1, -3), day2); -// -// day1 = null; -// assertNull(USNYSE.pastDate(day1)); -// assertNull(JPOSE.pastDate(day1)); -// -// day1 = "2014-03-10"; -// day2 = "2017-03-13"; -// assertEquals(USNYSE.pastDate(day2, 1099), day1); -// -// // incorrectly formatted days -// try { -// USNYSE.pastDate("2018-02-31"); -// fail(); -// } catch (IllegalArgumentException e) { -// // ok -// } -// try { -// USNYSE.pastDate("20193-02-31"); -// fail(); -// } catch (IllegalArgumentException e) { -// // ok -// } -// } -// -// public void testDateRange() { -// // day light savings -// Instant startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); -// Instant endDate = DateTimeUtils.parseInstant("2017-03-14T01:00:00.000000000 NY"); -// -// String[] goodResults = new String[] { -// "2017-03-11", -// "2017-03-12", -// "2017-03-13", -// "2017-03-14" -// }; -// -// String[] results = USNYSE.calendarDates(startDate, endDate); -// Arrays.sort(goodResults); -// Arrays.sort(results); -// boolean answer = Arrays.equals(goodResults, results); -// assertTrue(answer); -// -// -// startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 JP"); -// endDate = DateTimeUtils.parseInstant("2017-03-14T01:00:00.000000000 JP"); -// results = JPOSE.calendarDates(startDate, endDate); -// Arrays.sort(goodResults); -// Arrays.sort(results); -// answer = Arrays.equals(goodResults, results); -// assertTrue(answer); -// -// -// startDate = null; -// assertEquals(USNYSE.calendarDates(startDate, endDate).length, 0); -// assertEquals(JPOSE.calendarDates(startDate, endDate).length, 0); -// } -// -// public void testDateStringRange() { -// String startDate = "2014-02-18"; -// String endDate = "2014-03-05"; -// String[] goodResults = new String[] { -// "2014-02-18", "2014-02-19", "2014-02-20", "2014-02-21", "2014-02-22", "2014-02-23", -// "2014-02-24", "2014-02-25", "2014-02-26", "2014-02-27", "2014-02-28", -// "2014-03-01", "2014-03-02", "2014-03-03", "2014-03-04", "2014-03-05" -// }; -// -// String[] results = USNYSE.calendarDates(startDate, endDate); -// Arrays.sort(goodResults); -// Arrays.sort(results); -// boolean answer = Arrays.equals(goodResults, results); -// assertTrue(answer); -// -// results = JPOSE.calendarDates(startDate, endDate); -// Arrays.sort(goodResults); -// Arrays.sort(results); -// answer = Arrays.equals(goodResults, results); -// assertTrue(answer); -// -// startDate = "2020-01-01"; -// endDate = "2020-01-20"; -// -// results = USNYSE.calendarDates(startDate, endDate); -// assertEquals(results.length, 20); -// -// results = JPOSE.calendarDates(startDate, endDate); -// assertEquals(results.length, 20); -// -// startDate = null; -// assertEquals(USNYSE.calendarDates(startDate, endDate).length, 0); -// assertEquals(JPOSE.calendarDates(startDate, endDate).length, 0); -// -// -// // incorrectly formatted days -// assertEquals(new String[0], USNYSE.calendarDates("2018-02-31", "2019-02-31")); -// } -// -// public void testNumberOfDays() { -// Instant startDate = DateTimeUtils.parseInstant("2014-02-18T01:00:00.000000000 NY"); -// Instant endDate = DateTimeUtils.parseInstant("2014-03-05T01:00:00.000000000 NY"); -// -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 15); -// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 11); -// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, false), 11); -// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 12); -// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 4); -// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, false), 4); -// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 4); -// -// -// startDate = DateTimeUtils.parseInstant("2020-01-01T01:00:00.000000000 NY"); -// endDate = DateTimeUtils.parseInstant("2020-01-20T01:00:00.000000000 NY"); -// -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 19); -// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 12); -// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 12); -// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 7); -// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 8); -// -// startDate = endDate; -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 0); -// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 0); -// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 0); -// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 0); -// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 1); -// -// startDate = DateTimeUtils.parseInstant("2020-01-02T01:00:00.000000000 NY"); -// endDate = startDate; -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 0); -// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 0); -// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 1); -// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 0); -// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 0); -// -// startDate = null; -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); -// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); -// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); -// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); -// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); -// -// startDate = DateTimeUtils.parseInstant("2014-02-18T01:00:00.000000000 NY"); -// endDate = null; -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); -// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); -// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); -// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); -// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), QueryConstants.NULL_INT); -// -// startDate = DateTimeUtils.parseInstant("2014-02-18T01:00:00.000000000 NY"); -// endDate = DateTimeUtils.parseInstant("2017-02-18T01:00:00.000000000 NY"); -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 1096); -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate, true), 1097); -// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 758); -// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 758); -// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 338); -// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 339); -// } -// -// public void testNumberOfDaysString() { -// String startDate = "2014-02-18"; -// String endDate = "2014-03-05"; -// -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 15); -// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 11); -// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 4); -// -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate, false), 15); -// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, false), 11); -// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, false), 4); -// -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate, true), 16); -// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 12); -// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 4); -// -// assertEquals(USNYSE.numberCalendarDates(endDate, startDate), -15); -// assertEquals(USNYSE.numberOfBusinessDays(endDate, startDate), -11); -// assertEquals(USNYSE.numberOfNonBusinessDays(endDate, startDate), -4); -// -// assertEquals(USNYSE.numberCalendarDates(endDate, startDate, false), -15); -// assertEquals(USNYSE.numberBusinessDates(endDate, startDate, false), -11); -// assertEquals(USNYSE.numberNonBusinessDates(endDate, startDate, false), -4); -// -// assertEquals(USNYSE.numberCalendarDates(endDate, startDate, true), -16); -// assertEquals(USNYSE.numberBusinessDates(endDate, startDate, true), -12); -// assertEquals(USNYSE.numberNonBusinessDates(endDate, startDate, true), -4); -// -// endDate = startDate; -// -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 0); -// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 0); -// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 0); -// -// -// startDate = "2020-01-01"; -// endDate = "2020-01-20"; -// -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 19); -// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 12); -// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 7); -// -// startDate = null; -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); -// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); -// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); -// -// startDate = "2014-02-18"; -// endDate = null; -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), QueryConstants.NULL_INT); -// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), QueryConstants.NULL_INT); -// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), QueryConstants.NULL_INT); -// -// -// -// startDate = "2014-02-18"; -// endDate = "2017-02-18"; -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate), 1096); -// assertEquals(USNYSE.numberCalendarDates(startDate, endDate, true), 1097); -// assertEquals(USNYSE.numberOfBusinessDays(startDate, endDate), 758); -// assertEquals(USNYSE.numberBusinessDates(startDate, endDate, true), 758); -// assertEquals(USNYSE.numberOfNonBusinessDays(startDate, endDate), 338); -// assertEquals(USNYSE.numberNonBusinessDates(startDate, endDate, true), 339); -// -// -// // incorrectly formatted days -// try { -// USNYSE.numberCalendarDates("2018-02-31", "2019-02-31"); -// fail(); -// } catch (IllegalArgumentException e) { -// // ok -// } -// } -// -// public void testIsBusinessDay() { -// assertTrue(test.isBusinessDay()); -// -// Instant businessDay = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); -// Instant halfDay = DateTimeUtils.parseInstant("2014-07-03T01:00:00.000000000 NY"); -// Instant holiday = DateTimeUtils.parseInstant("2002-01-01T01:00:00.000000000 NY"); -// Instant holiday2 = DateTimeUtils.parseInstant("2002-01-21T01:00:00.000000000 NY"); -// -// assertTrue(USNYSE.isBusinessDay(businessDay)); -// assertTrue(USNYSE.isBusinessDay(halfDay)); -// assertFalse(USNYSE.isBusinessDay(holiday)); -// assertFalse(USNYSE.isBusinessDay(holiday2)); -// -// businessDay = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); -// halfDay = DateTimeUtils.parseInstant("2006-01-04T01:00:00.000000000 JP"); -// holiday = DateTimeUtils.parseInstant("2006-01-02T01:00:00.000000000 JP"); -// holiday2 = DateTimeUtils.parseInstant("2007-12-23T01:00:00.000000000 JP"); -// -// assertTrue(JPOSE.isBusinessDay(businessDay)); -// assertTrue(JPOSE.isBusinessDay(halfDay)); -// assertFalse(JPOSE.isBusinessDay(holiday)); -// assertFalse(JPOSE.isBusinessDay(holiday2)); -// -// -// businessDay = null; -// // noinspection ConstantConditions -// assertFalse(USNYSE.isBusinessDay(businessDay)); -// // noinspection ConstantConditions -// assertFalse(JPOSE.isBusinessDay(businessDay)); -// } -// -// public void testIsBusinessTime() { -// Instant businessDayNotTime = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); -// Instant halfDayTime = DateTimeUtils.parseInstant("2014-07-03T12:00:00.000000000 NY"); -// Instant holiday = DateTimeUtils.parseInstant("2002-01-01T01:00:00.000000000 NY"); -// Instant holiday2 = DateTimeUtils.parseInstant("2002-01-21T01:00:00.000000000 NY"); -// -// assertFalse(USNYSE.isBusinessTime(businessDayNotTime)); -// assertTrue(USNYSE.isBusinessTime(halfDayTime)); -// assertFalse(USNYSE.isBusinessTime(holiday)); -// assertFalse(USNYSE.isBusinessTime(holiday2)); -// -// Instant businessDayTime = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); -// halfDayTime = DateTimeUtils.parseInstant("2006-01-04T11:00:00.000000000 JP"); -// holiday = DateTimeUtils.parseInstant("2006-01-02T01:00:00.000000000 JP"); -// holiday2 = DateTimeUtils.parseInstant("2007-12-23T01:00:00.000000000 JP"); -// -// assertFalse(JPOSE.isBusinessTime(businessDayTime)); -// assertTrue(JPOSE.isBusinessTime(halfDayTime)); -// assertFalse(JPOSE.isBusinessTime(holiday)); -// assertFalse(JPOSE.isBusinessTime(holiday2)); -// -// -// holiday = null; -// // noinspection ConstantConditions -// assertFalse(USNYSE.isBusinessTime(holiday)); -// // noinspection ConstantConditions -// assertFalse(JPOSE.isBusinessTime(holiday)); -// } -// -// public void testIsBusinessDayString() { -// String businessDay = "2016-08-31"; -// String halfDay = "2014-07-03"; -// String holiday = "2002-01-01"; -// String holiday2 = "2002-01-21"; -// -// assertTrue(USNYSE.isBusinessDay(businessDay)); -// assertTrue(USNYSE.isBusinessDay(halfDay)); -// assertFalse(USNYSE.isBusinessDay(holiday)); -// assertFalse(USNYSE.isBusinessDay(holiday2)); -// -// businessDay = "2016-08-31"; -// halfDay = "2006-01-04"; -// holiday = "2007-09-17"; -// holiday2 = "2006-02-11"; -// -// assertTrue(JPOSE.isBusinessDay(businessDay)); -// assertTrue(JPOSE.isBusinessDay(halfDay)); -// assertFalse(JPOSE.isBusinessDay(holiday)); -// assertFalse(JPOSE.isBusinessDay(holiday2)); -// -// businessDay = null; -// assertFalse(JPOSE.isBusinessDay(businessDay)); -// assertFalse(JPOSE.isBusinessDay(businessDay)); -// -// -// // incorrectly formatted days -// try { -// USNYSE.isBusinessDay("2018-09-31"); -// fail(); -// } catch (IllegalArgumentException e) { -// // ok -// } -// } -// -// public void testNextBusinessDay() { -// assertEquals("2017-09-28", test.futureBusinessDate()); -// assertEquals("2017-09-29", test.futureBusinessDate(2)); -// assertEquals("2017-10-17", test.futureBusinessDate(14)); -// -// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); -// Instant day1JP = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); -// String day2 = "2016-09-01"; -// assertNull(USNYSE.futureBusinessDate((Instant) null)); -// assertEquals(USNYSE.futureBusinessDate(day1), day2); -// assertEquals(JPOSE.futureBusinessDate(day1JP), day2); -// -// assertNull(USNYSE.futureBusinessDate((Instant) null, 2)); -// assertEquals(USNYSE.futureBusinessDate(day1, 2), "2016-09-02"); -// assertEquals(JPOSE.futureBusinessDate(day1JP, 2), "2016-09-02"); -// -// assertEquals(USNYSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 NY"), -2), -// "2016-08-31"); -// assertEquals(JPOSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 JP"), -2), -// "2016-08-31"); -// -// assertEquals(USNYSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"), 0), -// "2016-08-30"); -// assertNull(USNYSE.futureBusinessDate(DateTimeUtils.parseInstant("2016-08-28T01:00:00.000000000 NY"), 0)); -// -// // leap day -// day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 JP"); -// day2 = "2016-02-29"; -// assertEquals(USNYSE.futureBusinessDate(day1), day2); -// assertEquals(JPOSE.futureBusinessDate(day1JP), day2); -// -// // new year -// day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 JP"); -// day2 = "2014-01-02"; -// assertEquals(USNYSE.futureBusinessDate(day1), day2); -// -// day2 = "2014-01-01"; -// assertEquals(JPOSE.futureBusinessDate(day1JP), day2); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// // Japan doesn't observe day light savings -// day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); -// day2 = "2017-03-13"; -// assertEquals(USNYSE.futureBusinessDate(day1), day2); -// assertEquals(JPOSE.futureBusinessDate(day1JP), day2); -// -// // outside calendar range, so no day off for new years, but weekend should still be off -// day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 JP"); -// day2 = "2070-01-01"; -// assertEquals(USNYSE.futureBusinessDate(day1).compareTo(day2), 0); -// assertEquals(JPOSE.futureBusinessDate(day1JP), day2); -// -// day1 = DateTimeUtils.parseInstant("2070-01-03T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2070-01-03T01:00:00.000000000 JP"); -// day2 = "2070-01-06"; -// assertEquals(USNYSE.futureBusinessDate(day1), day2); -// assertEquals(JPOSE.futureBusinessDate(day1JP), day2); -// -// day1 = null; -// assertNull(USNYSE.futureBusinessDate(day1)); -// assertNull(JPOSE.futureBusinessDate(day1)); -// } -// -// public void testNextBusinessDayString() { -// String day1 = "2016-08-31"; -// String day2 = "2016-09-01"; -// assertNull(USNYSE.futureBusinessDate((String) null)); -// assertEquals(USNYSE.futureBusinessDate(day1), day2); -// assertEquals(JPOSE.futureBusinessDate(day1), day2); -// -// assertNull(USNYSE.futureBusinessDate((String) null, 2)); -// assertEquals(USNYSE.futureBusinessDate(day1, 2), "2016-09-02"); -// assertEquals(JPOSE.futureBusinessDate(day1, 2), "2016-09-02"); -// -// assertEquals(USNYSE.futureBusinessDate("2016-09-02", -2), "2016-08-31"); -// assertEquals(JPOSE.futureBusinessDate("2016-09-02", -2), "2016-08-31"); -// -// assertEquals(USNYSE.futureBusinessDate("2016-08-30", 0), "2016-08-30"); -// assertNull(USNYSE.futureBusinessDate("2016-08-28", 0)); -// -// // leap day -// day1 = "2016-02-28"; -// day2 = "2016-02-29"; -// assertEquals(USNYSE.futureBusinessDate(day1), day2); -// assertEquals(JPOSE.futureBusinessDate(day1), day2); -// -// // new year -// day1 = "2013-12-31"; -// day2 = "2014-01-02"; -// assertEquals(USNYSE.futureBusinessDate(day1), day2); -// -// day1 = "2007-01-01"; -// day2 = "2007-01-04"; -// assertEquals(JPOSE.futureBusinessDate(day1), day2); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// day1 = "2017-03-12"; -// day2 = "2017-03-13"; -// assertEquals(USNYSE.futureBusinessDate(day1), day2); -// assertEquals(JPOSE.futureBusinessDate(day1), day2); -// -// day1 = null; -// assertNull(USNYSE.futureBusinessDate(day1)); -// assertNull(JPOSE.futureBusinessDate(day1)); -// -// // incorrectly formatted days -// try { -// USNYSE.futureBusinessDate("2018-09-31"); -// fail(); -// } catch (IllegalArgumentException e) { -// // ok -// } -// } -// -// public void testNextBusinessSchedule() { -// assertEquals(test.nextBusinessSchedule(curDay), test.nextBusinessSchedule()); -// assertEquals(test.nextBusinessSchedule(curDay, 2), test.nextBusinessSchedule(2)); -// -// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); -// Instant day1JP = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); -// String day2 = "2016-09-01"; -// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); -// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); -// -// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1, 2).getSOBD(), TZ_NY), "2016-09-02"); -// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP, 2).getSOBD(), TZ_JP), "2016-09-02"); -// -// assertEquals(DateTimeUtils.formatDate( -// USNYSE.nextBusinessSchedule(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 NY"), -2) -// .getSOBD(), -// TZ_NY), "2016-08-31"); -// assertEquals(DateTimeUtils.formatDate( -// JPOSE.nextBusinessSchedule(DateTimeUtils.parseInstant("2016-09-02T01:00:00.000000000 JP"), -2) -// .getSOBD(), -// TZ_JP), "2016-08-31"); -// -// assertEquals(DateTimeUtils.formatDate( -// USNYSE.nextBusinessSchedule(DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"), 0) -// .getSOBD(), -// TZ_NY), "2016-08-30"); -// -// // leap day -// day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 JP"); -// day2 = "2016-02-29"; -// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); -// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); -// -// // new year -// day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 JP"); -// day2 = "2014-01-03"; -// assertEquals( -// DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(USNYSE.futureBusinessDate(day1)).getSOBD(), TZ_NY), -// day2); -// -// day2 = "2014-01-01"; -// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// // Japan doesn't observe day light savings -// day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); -// day2 = "2017-03-13"; -// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); -// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); -// -// // outside calendar range, so no day off for new years, but weekend should still be off -// day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 JP"); -// day2 = "2070-01-01"; -// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY).compareTo(day2), 0); -// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); -// -// day1 = DateTimeUtils.parseInstant("2070-01-05T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2070-01-05T01:00:00.000000000 JP"); -// day2 = "2070-01-06"; -// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); -// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1JP).getSOBD(), TZ_JP), day2); -// -// day1 = null; -// assertNull(USNYSE.nextBusinessSchedule(day1)); -// assertNull(JPOSE.nextBusinessSchedule(day1)); -// -// -// // holiday -// final BusinessSchedule holiday = USNYSE.businessSchedule("2017-12-25"); -// assertEquals(0, holiday.periods().length); -// assertEquals(0, holiday.businessNanos()); -// try { -// // noinspection ResultOfMethodCallIgnored -// holiday.businessEnd(); -// fail("Expected an exception!"); -// } catch (UnsupportedOperationException e) { -// // pass -// } -// try { -// // noinspection ResultOfMethodCallIgnored -// holiday.businessStart(); -// fail("Expected an exception!"); -// } catch (UnsupportedOperationException e) { -// // pass -// } -// } -// -// public void testNextBusinessScheduleString() { -// String day1 = "2016-08-31"; -// String day2 = "2016-09-01"; -// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); -// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1).getSOBD(), TZ_JP), day2); -// -// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1, 2).getSOBD(), TZ_NY), "2016-09-02"); -// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1, 2).getSOBD(), TZ_JP), "2016-09-02"); -// -// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule("2016-09-02", -2).getSOBD(), TZ_NY), -// "2016-08-31"); -// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule("2016-09-02", -2).getSOBD(), TZ_JP), -// "2016-08-31"); -// -// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule("2016-08-30", 0).getSOBD(), TZ_NY), -// "2016-08-30"); -// assertNull(USNYSE.nextBusinessSchedule((String) null, 0)); -// -// // leap day -// day1 = "2016-02-28"; -// day2 = "2016-02-29"; -// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); -// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1).getSOBD(), TZ_JP), day2); -// -// // new year -// day1 = "2014-01-01"; -// day2 = "2014-01-02"; -// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); -// -// day1 = "2007-01-03"; -// day2 = "2007-01-04"; -// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1).getSOBD(), TZ_JP), day2); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// day1 = "2017-03-12"; -// day2 = "2017-03-13"; -// assertEquals(DateTimeUtils.formatDate(USNYSE.nextBusinessSchedule(day1).getSOBD(), TZ_NY), day2); -// assertEquals(DateTimeUtils.formatDate(JPOSE.nextBusinessSchedule(day1).getSOBD(), TZ_JP), day2); -// -// day1 = null; -// assertNull(USNYSE.nextBusinessSchedule(day1)); -// assertNull(JPOSE.nextBusinessSchedule(day1)); -// } -// -// public void testNextNonBusinessDay() { -// assertEquals("2017-09-30", test.futureNonBusinessDate()); -// assertEquals("2017-10-01", test.futureNonBusinessDate(2)); -// assertEquals("2017-10-08", test.futureNonBusinessDate(4)); -// -// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); -// Instant day1JP = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); -// String day2 = "2016-09-03"; -// assertNull(USNYSE.futureNonBusinessDate((Instant) null)); -// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); -// assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); -// -// assertNull(USNYSE.futureNonBusinessDate((Instant) null, 2)); -// assertEquals(USNYSE.futureNonBusinessDate(day1, 2), "2016-09-04"); -// assertEquals(JPOSE.futureNonBusinessDate(day1JP, 2), "2016-09-04"); -// -// assertEquals(USNYSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-09-04T01:00:00.000000000 NY"), -2), -// "2016-08-28"); -// assertEquals(JPOSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-09-04T01:00:00.000000000 JP"), -2), -// "2016-08-28"); -// -// assertNull(USNYSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"), 0)); -// assertEquals(USNYSE.futureNonBusinessDate(DateTimeUtils.parseInstant("2016-08-28T01:00:00.000000000 NY"), 0), -// "2016-08-28"); -// -// // leap day -// day1 = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2016-02-28T01:00:00.000000000 JP"); -// day2 = "2016-03-05"; -// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); -// assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); -// -// // new year -// day1 = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2013-12-31T01:00:00.000000000 JP"); -// day2 = "2014-01-01"; -// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); -// -// day2 = "2014-01-04"; -// assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); -// day2 = "2017-03-18"; -// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); -// assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); -// -// // outside calendar range, so no day off for new years, but weekend should still be off -// day1 = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 NY"); -// day1JP = DateTimeUtils.parseInstant("2069-12-31T01:00:00.000000000 JP"); -// day2 = "2070-01-04"; -// assertEquals(USNYSE.futureNonBusinessDate(day1).compareTo(day2), 0); -// assertEquals(JPOSE.futureNonBusinessDate(day1JP), day2); -// -// day1 = null; -// assertNull(USNYSE.futureNonBusinessDate(day1)); -// assertNull(JPOSE.futureNonBusinessDate(day1)); -// } -// -// public void testNextNonBusinessDayString() { -// String day1 = "2016-08-31"; -// String day2 = "2016-09-03"; -// assertNull(USNYSE.futureNonBusinessDate((String) null)); -// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); -// assertEquals(JPOSE.futureNonBusinessDate(day1), day2); -// -// assertNull(USNYSE.futureNonBusinessDate((String) null, 2)); -// assertEquals(USNYSE.futureNonBusinessDate(day1, 2), "2016-09-04"); -// assertEquals(JPOSE.futureNonBusinessDate(day1, 2), "2016-09-04"); -// -// assertEquals(USNYSE.futureNonBusinessDate("2016-09-04", -2), "2016-08-28"); -// assertEquals(JPOSE.futureNonBusinessDate("2016-09-04", -2), "2016-08-28"); -// -// assertNull(USNYSE.futureNonBusinessDate("2016-08-30", 0)); -// assertEquals(USNYSE.futureNonBusinessDate("2016-08-28", 0), "2016-08-28"); -// -// // leap day -// day1 = "2016-02-28"; -// day2 = "2016-03-05"; -// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); -// assertEquals(JPOSE.futureNonBusinessDate(day1), day2); -// -// // new year -// day1 = "2013-12-31"; -// day2 = "2014-01-01"; -// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// day1 = "2017-03-12"; -// day2 = "2017-03-18"; -// assertEquals(USNYSE.futureNonBusinessDate(day1), day2); -// assertEquals(JPOSE.futureNonBusinessDate(day1), day2); -// -// day1 = null; -// assertNull(USNYSE.futureNonBusinessDate(day1)); -// assertNull(JPOSE.futureNonBusinessDate(day1)); -// -// // incorrectly formatted days -// try { -// USNYSE.futureNonBusinessDate("2018-09-31"); -// fail(); -// } catch (IllegalArgumentException e) { -// // ok -// } -// } -// -// public void testLastBusinessDay() { -// assertEquals("2017-09-26", test.pastBusinessDate()); -// assertEquals("2017-09-25", test.pastBusinessDate(2)); -// assertEquals("2017-09-07", test.pastBusinessDate(14)); -// -// assertEquals("2017-09-24", test.pastNonBusinessDate()); -// assertEquals("2017-09-23", test.pastNonBusinessDate(2)); -// assertEquals("2017-09-16", test.pastNonBusinessDate(4)); -// -// -// Instant day1 = DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"); -// Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); -// assertNull(USNYSE.pastBusinessDate((Instant) null, 2)); -// assertEquals(USNYSE.pastBusinessDate(day2, 2), DateTimeUtils.formatDate(day1, TZ_NY)); -// assertEquals(USNYSE.pastBusinessDate(day1, -2), DateTimeUtils.formatDate(day2, TZ_NY)); -// -// assertEquals(USNYSE.pastBusinessDate(DateTimeUtils.parseInstant("2016-08-30T15:00:00.000000000 NY"), 0), -// "2016-08-30"); -// assertNull(USNYSE.pastBusinessDate(DateTimeUtils.parseInstant("2016-08-28T15:00:00.000000000 NY"), 0)); -// -// assertNull(USNYSE.pastNonBusinessDate((Instant) null, 0)); -// assertNull(USNYSE.pastNonBusinessDate(DateTimeUtils.parseInstant("2016-08-30T21:00:00.000000000 NY"), 0)); -// assertEquals( -// USNYSE.pastNonBusinessDate(DateTimeUtils.parseInstant("2016-08-28T21:00:00.000000000 NY"), 0), -// "2016-08-28"); -// -// // leap day -// day1 = DateTimeUtils.parseInstant("2016-02-29T21:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 NY"); -// assertEquals(USNYSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); -// -// // new year -// day1 = DateTimeUtils.parseInstant("2013-12-26T01:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2014-01-02T01:00:00.000000000 NY"); -// assertEquals(USNYSE.pastBusinessDate(day2, 4), DateTimeUtils.formatDate(day1, TZ_NY)); -// assertEquals(USNYSE.pastBusinessDate(day1, -4), DateTimeUtils.formatDate(day2, TZ_NY)); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// day1 = DateTimeUtils.parseInstant("2017-02-26T01:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 NY"); -// assertEquals(USNYSE.pastNonBusinessDate(day2, 5), DateTimeUtils.formatDate(day1, TZ_NY)); -// assertEquals(USNYSE.pastNonBusinessDate(day1, -5), "2017-03-18"); -// -// day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 NY"); -// assertEquals(USNYSE.pastNonBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); -// -// day1 = DateTimeUtils.parseInstant("2017-07-04T01:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2017-07-07T01:00:00.000000000 NY"); -// assertEquals(USNYSE.pastNonBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_NY)); -// -// day1 = null; -// assertNull(USNYSE.pastBusinessDate(day1)); -// assertNull(USNYSE.pastNonBusinessDate(day1)); -// -// -// -// day1 = DateTimeUtils.parseInstant("2016-08-31T21:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2016-09-01T21:00:00.000000000 JP"); -// assertEquals(JPOSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); -// -// // leap day -// day1 = DateTimeUtils.parseInstant("2016-02-29T01:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 JP"); -// assertEquals(JPOSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); -// -// // new year -// day1 = DateTimeUtils.parseInstant("2013-12-31T11:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2014-01-01T11:00:00.000000000 JP"); -// assertEquals(JPOSE.pastBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); -// -// // Daylight savings starts in JP (UTC-7:00) at 2 AM 2017-03-12 -// day1 = DateTimeUtils.parseInstant("2017-03-12T01:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2017-03-13T01:00:00.000000000 JP"); -// assertEquals(JPOSE.pastNonBusinessDate(day2), DateTimeUtils.formatDate(day1, TZ_JP)); -// -// -// day1 = null; -// assertNull(JPOSE.pastBusinessDate(day1)); -// assertNull(JPOSE.pastNonBusinessDate(day1)); -// } -// -// public void testLastBusinessDayString() { -// String day1 = "2016-08-31"; -// String day2 = "2016-09-01"; -// assertNull(USNYSE.pastBusinessDate((String) null)); -// assertEquals(USNYSE.pastBusinessDate(day2), day1); -// assertEquals(JPOSE.pastBusinessDate(day2), day1); -// -// assertNull(USNYSE.pastBusinessDate((String) null, 2)); -// assertEquals(USNYSE.pastBusinessDate("2016-08-30", 0), "2016-08-30"); -// assertNull(USNYSE.pastBusinessDate("2016-08-28", 0)); -// -// day1 = "2016-08-29"; -// assertEquals(USNYSE.pastBusinessDate(day2, 3), day1); -// assertEquals(JPOSE.pastBusinessDate(day2, 3), day1); -// assertEquals(USNYSE.pastBusinessDate(day1, -3), day2); -// assertEquals(JPOSE.pastBusinessDate(day1, -3), day2); -// -// // leap day -// day1 = "2016-02-29"; -// day2 = "2016-03-01"; -// assertEquals(USNYSE.pastBusinessDate(day2), day1); -// assertEquals(JPOSE.pastBusinessDate(day2), day1); -// -// // new year -// day1 = "2013-12-30"; -// day2 = "2014-01-01"; -// assertEquals(USNYSE.pastBusinessDate(day2, 2), day1); -// assertEquals(JPOSE.pastBusinessDate(day2, 2), day1); -// assertEquals(USNYSE.pastBusinessDate(day1, -2), "2014-01-02"); -// assertEquals(JPOSE.pastBusinessDate(day1, -2), day2); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// day1 = "2017-03-10"; -// day2 = "2017-03-13"; -// assertEquals(USNYSE.pastBusinessDate(day2), day1); -// assertEquals(JPOSE.pastBusinessDate(day2), day1); -// -// day1 = null; -// assertNull(USNYSE.pastBusinessDate(day1)); -// assertNull(JPOSE.pastBusinessDate(day1)); -// -// // incorrectly formatted days -// try { -// USNYSE.pastBusinessDate("2018-09-31"); -// fail(); -// } catch (IllegalArgumentException e) { -// // ok -// } -// } -// -// public void testLastBusinessSchedule() { -// assertEquals(test.previousBusinessSchedule(curDay), test.previousBusinessSchedule()); -// assertEquals(test.previousBusinessSchedule(curDay, 2), test.previousBusinessSchedule(2)); -// -// -// Instant day1 = DateTimeUtils.parseInstant("2016-08-30T01:00:00.000000000 NY"); -// Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); -// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2, 2).getSOBD(), TZ_NY), -// DateTimeUtils.formatDate(day1, TZ_NY)); -// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day1, -2).getSOBD(), TZ_NY), -// DateTimeUtils.formatDate(day2, TZ_NY)); -// -// assertEquals( -// DateTimeUtils.formatDate(USNYSE -// .previousBusinessSchedule(DateTimeUtils.parseInstant("2016-08-30T15:00:00.000000000 NY"), 0) -// .getSOBD(), TZ_NY), -// "2016-08-30"); -// assertNull(USNYSE.previousBusinessSchedule((Instant) null, 0)); -// -// // leap day -// day1 = DateTimeUtils.parseInstant("2016-02-29T21:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 NY"); -// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2).getSOBD(), TZ_NY), -// DateTimeUtils.formatDate(day1, TZ_NY)); -// -// // new year -// day1 = DateTimeUtils.parseInstant("2013-12-26T01:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2014-01-02T01:00:00.000000000 NY"); -// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2, 7).getSOBD(), TZ_NY), -// DateTimeUtils.formatDate(day1, TZ_NY)); -// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day1, -7).getSOBD(), TZ_NY), -// DateTimeUtils.formatDate(day2, TZ_NY)); -// -// day1 = null; -// assertNull(USNYSE.previousBusinessSchedule(day1)); -// -// -// day1 = DateTimeUtils.parseInstant("2016-08-31T21:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2016-09-01T21:00:00.000000000 JP"); -// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), -// DateTimeUtils.formatDate(day1, TZ_JP)); -// -// // leap day -// day1 = DateTimeUtils.parseInstant("2016-02-29T01:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2016-03-01T01:00:00.000000000 JP"); -// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), -// DateTimeUtils.formatDate(day1, TZ_JP)); -// -// // new year -// day1 = DateTimeUtils.parseInstant("2013-12-31T11:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2014-01-01T11:00:00.000000000 JP"); -// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), -// DateTimeUtils.formatDate(day1, TZ_JP)); -// -// -// day1 = null; -// assertNull(JPOSE.previousBusinessSchedule(day1)); -// } -// -// public void testLastBusinessScheduleString() { -// String day1 = "2016-08-31"; -// String day2 = "2016-09-01"; -// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2).getSOBD(), TZ_NY), day1); -// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), day1); -// -// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule("2016-08-30", 0).getSOBD(), TZ_NY), -// "2016-08-30"); -// assertNull(USNYSE.previousBusinessSchedule((String) null, 0)); -// -// day1 = "2016-08-29"; -// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2, 3).getSOBD(), TZ_NY), day1); -// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2, 3).getSOBD(), TZ_JP), day1); -// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day1, -3).getSOBD(), TZ_NY), day2); -// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day1, -3).getSOBD(), TZ_JP), day2); -// -// // leap day -// day1 = "2016-02-29"; -// day2 = "2016-03-01"; -// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2).getSOBD(), TZ_NY), day1); -// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2).getSOBD(), TZ_JP), day1); -// -// // new year -// day1 = "2014-12-29"; -// day2 = "2014-12-31"; -// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day2, 2).getSOBD(), TZ_NY), day1); -// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day2, 2).getSOBD(), TZ_JP), day1); -// assertEquals(DateTimeUtils.formatDate(USNYSE.previousBusinessSchedule(day1, -2).getSOBD(), TZ_NY), day2); -// assertEquals(DateTimeUtils.formatDate(JPOSE.previousBusinessSchedule(day1, -2).getSOBD(), TZ_JP), day2); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// day1 = "2017-03-10"; -// day2 = "2017-03-13"; -// assertEquals( -// DateTimeUtils.formatDate( -// USNYSE.previousBusinessSchedule(USNYSE.pastDate(USNYSE.pastDate(day2))).getSOBD(), TZ_NY), -// day1); -// assertEquals( -// DateTimeUtils.formatDate( -// JPOSE.previousBusinessSchedule(JPOSE.pastDate(JPOSE.pastDate(day2))).getSOBD(), TZ_JP), -// day1); -// -// day1 = null; -// assertNull(USNYSE.previousBusinessSchedule(day1)); -// assertNull(JPOSE.previousBusinessSchedule(day1)); -// -// // incorrectly formatted days -// try { -// USNYSE.previousBusinessSchedule("2018-09-31"); -// fail(); -// } catch (IllegalArgumentException e) { -// // ok -// } -// } -// -// public void testLastNonBusinessDayString() { -// String day1 = "2016-08-28"; -// String day2 = "2016-09-01"; -// assertNull(USNYSE.pastNonBusinessDate((String) null)); -// assertEquals(USNYSE.pastNonBusinessDate(day2), day1); -// assertEquals(JPOSE.pastNonBusinessDate(day2), day1); -// -// assertNull(USNYSE.pastNonBusinessDate((String) null, 2)); -// assertNull(USNYSE.pastNonBusinessDate("2016-08-30", 0)); -// assertEquals(USNYSE.pastNonBusinessDate("2016-08-28", 0), "2016-08-28"); -// -// // leap day -// day1 = "2016-02-27"; -// day2 = "2016-03-01"; -// assertEquals(USNYSE.pastNonBusinessDate(day2, 2), day1); -// assertEquals(JPOSE.pastNonBusinessDate(day2, 2), day1); -// assertEquals(USNYSE.pastNonBusinessDate(day1, -2), "2016-03-05"); -// assertEquals(JPOSE.pastNonBusinessDate(day1, -2), "2016-03-05"); -// -// // new year -// day1 = "2013-12-29"; -// day2 = "2014-01-01"; -// assertEquals(USNYSE.pastNonBusinessDate(day2), day1); -// assertEquals(JPOSE.pastNonBusinessDate(day2), day1); -// -// // Daylight savings starts in NY (UTC-7:00) at 2 AM 2017-03-12 -// day1 = "2017-03-05"; -// day2 = "2017-03-13"; -// assertEquals(USNYSE.pastNonBusinessDate(day2, 3), day1); -// assertEquals(JPOSE.pastNonBusinessDate(day2, 3), day1); -// assertEquals(USNYSE.pastNonBusinessDate(day1, -3), "2017-03-18"); -// assertEquals(JPOSE.pastNonBusinessDate(day1, -3), "2017-03-18"); -// -// day1 = null; -// assertNull(USNYSE.pastNonBusinessDate(day1)); -// assertNull(JPOSE.pastNonBusinessDate(day1)); -// -// // incorrectly formatted days -// try { -// USNYSE.pastNonBusinessDate("2018-09-31"); -// fail(); -// } catch (IllegalArgumentException e) { -// // ok -// } -// } -// -// public void testDiff() { -// // standard business day -// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); -// Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); -// assertEquals(USNYSE.diffDay(day1, day2), 1.0); -// assertEquals(USNYSE.diffNanos(day1, day2), DateTimeUtils.DAY); -// assertEquals(JPOSE.diffYear365(day1, day2), (double) DateTimeUtils.DAY / (double) DateTimeUtils.YEAR_365); -// assertEquals(JPOSE.diffYearAvg(day1, day2), (double) DateTimeUtils.DAY / (double) DateTimeUtils.YEAR_AVG); -// } -// -// public void testBusinessTimeDiff() { -// // standard business day -// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); -// Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); -// assertEquals(USNYSE.diffBusinessDays(day1, day2), 1.0); -// assertEquals(JPOSE.diffBusinessDays(day1, day2), 1.0); -// -// // 2.5 standard business days -// day1 = DateTimeUtils.parseInstant("2017-01-23T01:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2017-01-25T12:45:00.000000000 NY"); -// assertEquals(USNYSE.diffBusinessDays(day1, day2), 2.5); -// -// day1 = DateTimeUtils.parseInstant("2017-01-23T01:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2017-01-25T12:45:00.000000000 JP"); -// assertEquals(JPOSE.diffBusinessDays(day1, day2), 2.55); -// -// // middle of a business period -// day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2017-01-23T13:00:00.000000000 JP"); -// assertEquals(JPOSE.diffBusinessNanos(day1, day2), 2 * DateTimeUtils.HOUR); -// -// // after a business period -// day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2017-01-23T16:15:00.000000000 JP"); -// assertEquals(JPOSE.diffBusinessNanos(day1, day2), 4 * DateTimeUtils.HOUR); -// -// // middle of the second business period -// day1 = DateTimeUtils.parseInstant("2017-01-23T08:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2017-01-23T14:00:00.000000000 JP"); -// assertEquals(JPOSE.diffBusinessNanos(day1, day2), 4 * DateTimeUtils.HOUR); -// -// // weekend non business -// day1 = DateTimeUtils.parseInstant("2017-01-21T01:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2017-01-23T01:00:00.000000000 NY"); -// assertEquals(USNYSE.diffBusinessDays(day1, day2), 0.0); -// -// // one business year -// day1 = DateTimeUtils.parseInstant("2016-01-01T01:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2016-12-31T23:59:00.000000000 NY"); -// double yearDiff = USNYSE.diffBusinessYears(day1, day2); -// assertTrue(yearDiff < 1.004); -// assertTrue(yearDiff > 0.996); -// yearDiff = JPOSE.diffBusinessYears(day1, day2); -// assertTrue(yearDiff < 1.004); -// assertTrue(yearDiff > 0.996); -// -// // half year -// day1 = DateTimeUtils.parseInstant("2017-01-01T01:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2017-07-02T01:00:00.000000000 NY"); -// yearDiff = USNYSE.diffBusinessYears(day1, day2); -// assertTrue(yearDiff < 0.503); -// assertTrue(yearDiff > 0.497); -// yearDiff = JPOSE.diffBusinessYears(day1, day2); -// assertTrue(yearDiff < 0.503); -// assertTrue(yearDiff > 0.497); -// -// -// day1 = null; -// assertEquals(USNYSE.diffBusinessYears(day1, day2), QueryConstants.NULL_DOUBLE); -// assertEquals(USNYSE.diffBusinessDays(day1, day2), QueryConstants.NULL_DOUBLE); -// assertEquals(USNYSE.diffBusinessNanos(day1, day2), QueryConstants.NULL_LONG); -// -// day1 = day2; -// assertEquals(USNYSE.diffBusinessYears(day1, day2), 0.0); -// assertEquals(USNYSE.diffBusinessDays(day1, day2), 0.0); -// assertEquals(USNYSE.diffBusinessNanos(day1, day2), 0); -// } -// -// public void testNonBusinessTimeDiff() { -// // USNYSE -// // standard business day -// Instant day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); -// Instant day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 NY"); -// assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), 63000000000000L); // 17.5 hours -// assertEquals(USNYSE.diffNonBusinessNanos(day2, day1), -63000000000000L); // 17.5 hours -// -// // middle of a business period -// day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2017-01-23T12:30:00.000000000 NY"); -// assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), 0); -// -// // after a business period -// day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 NY"); -// day2 = DateTimeUtils.parseInstant("2017-01-23T16:15:00.000000000 NY"); -// assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), 15 * DateTimeUtils.MINUTE); -// -// // JPOSE -// // standard business day -// day1 = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2016-09-01T01:00:00.000000000 JP"); -// assertEquals(JPOSE.diffNonBusinessNanos(day1, day2), 19 * DateTimeUtils.HOUR); // 17.5 hours -// -// // middle of a business period -// day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2017-01-23T11:30:00.000000000 JP"); -// assertEquals(JPOSE.diffNonBusinessNanos(day1, day2), 0); -// -// // after a business period -// day1 = DateTimeUtils.parseInstant("2017-01-23T10:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2017-01-23T16:00:00.000000000 JP"); -// assertEquals(JPOSE.diffNonBusinessNanos(day1, day2), 2 * DateTimeUtils.HOUR); -// assertEquals(JPOSE.diffNonBusinessDays(day1, day2), -// ((double) (2 * DateTimeUtils.HOUR)) / (double) JPOSE.standardBusinessNanos()); -// -// -// -// day1 = null; -// assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), QueryConstants.NULL_LONG); -// -// day1 = day2; -// assertEquals(USNYSE.diffNonBusinessNanos(day1, day2), 0); -// -// day1 = null; -// assertEquals(USNYSE.diffNonBusinessDays(day1, day2), QueryConstants.NULL_DOUBLE); -// } -// -// public void testBusinessDateRange() { -// // day light savings -// Instant startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); -// Instant endDate = DateTimeUtils.parseInstant("2017-03-14T01:00:00.000000000 NY"); -// -// String[] goodResults = new String[] { -// "2017-03-13", -// "2017-03-14" -// }; -// -// String[] results = USNYSE.businessDates(startDate, endDate); -// Arrays.sort(goodResults); -// Arrays.sort(results); -// boolean answer = Arrays.equals(goodResults, results); -// assertTrue(answer); -// -// assertEquals(new String[0], USNYSE.businessDates(endDate, startDate)); -// -// startDate = DateTimeUtils.parseInstant("2017-11-23T01:00:00.000000000 JP"); -// endDate = DateTimeUtils.parseInstant("2017-11-25T01:00:00.000000000 JP"); -// -// goodResults = new String[] { -// "2017-11-24" -// }; -// -// results = JPOSE.businessDates(startDate, endDate); -// Arrays.sort(goodResults); -// Arrays.sort(results); -// answer = Arrays.equals(goodResults, results); -// assertTrue(answer); -// -// startDate = null; -// assertEquals(JPOSE.businessDates(startDate, endDate).length, 0); -// -// // non business -// startDate = DateTimeUtils.parseInstant("2017-03-11T01:00:00.000000000 NY"); -// endDate = DateTimeUtils.parseInstant("2017-03-14T01:00:00.000000000 NY"); -// -// goodResults = new String[] { -// "2017-03-11", -// "2017-03-12" -// }; -// -// results = USNYSE.nonBusinessDates(startDate, endDate); -// Arrays.sort(goodResults); -// Arrays.sort(results); -// answer = Arrays.equals(goodResults, results); -// assertTrue(answer); -// -// -// startDate = DateTimeUtils.parseInstant("2017-11-23T01:00:00.000000000 JP"); -// endDate = DateTimeUtils.parseInstant("2017-11-25T01:00:00.000000000 JP"); -// -// goodResults = new String[] { -// "2017-11-23", -// "2017-11-25" -// }; -// -// assertEquals(new String[0], USNYSE.nonBusinessDates(endDate, startDate)); -// results = JPOSE.nonBusinessDates(startDate, endDate); -// Arrays.sort(goodResults); -// Arrays.sort(results); -// answer = Arrays.equals(goodResults, results); -// assertTrue(answer); -// -// startDate = null; -// assertEquals(JPOSE.nonBusinessDates(startDate, endDate).length, 0); -// -// startDate = null; -// assertEquals(USNYSE.nonBusinessDates(startDate, endDate).length, 0); -// } -// -// public void testBusinessDateStringRange() { -// // USNYSE -// String startDate = "2014-02-16"; -// String endDate = "2014-03-05"; -// String[] goodResults = new String[] { -// "2014-02-18", "2014-02-19", "2014-02-20", "2014-02-21", -// "2014-02-24", "2014-02-25", "2014-02-26", "2014-02-27", "2014-02-28", -// "2014-03-03", "2014-03-04", "2014-03-05", -// }; -// -// assertEquals(new String[0], USNYSE.businessDates(endDate, startDate)); -// String[] results = USNYSE.businessDates(startDate, endDate); -// Arrays.sort(goodResults); -// Arrays.sort(results); -// boolean answer = Arrays.equals(goodResults, results); -// assertTrue(answer); -// -// startDate = null; -// assertEquals(USNYSE.businessDates(startDate, endDate).length, 0); -// -// startDate = endDate; -// assertEquals(USNYSE.businessDates(startDate, endDate).length, 1); -// -// // JPOSE -// startDate = "2018-01-01"; -// endDate = "2018-01-05"; -// goodResults = new String[] { -// "2018-01-04", -// "2018-01-05" -// }; -// -// results = JPOSE.businessDates(startDate, endDate); -// Arrays.sort(goodResults); -// Arrays.sort(results); -// answer = Arrays.equals(goodResults, results); -// assertTrue(answer); -// -// -// // non business -// startDate = "2020-01-01"; -// endDate = "2020-01-20"; -// goodResults = new String[] { -// "2020-01-01", "2020-01-04", "2020-01-05", "2020-01-11", "2020-01-12", -// "2020-01-18", "2020-01-19", "2020-01-20" -// }; -// -// assertEquals(new String[0], USNYSE.nonBusinessDates(endDate, startDate)); -// results = USNYSE.nonBusinessDates(startDate, endDate); -// Arrays.sort(goodResults); -// Arrays.sort(results); -// answer = Arrays.equals(goodResults, results); -// assertTrue(answer); -// -// -// // JPOSE -// startDate = "2018-01-01"; -// endDate = "2018-01-05"; -// goodResults = new String[] { -// "2018-01-01", -// "2018-01-02", -// "2018-01-03" -// }; -// -// results = JPOSE.nonBusinessDates(startDate, endDate); -// Arrays.sort(goodResults); -// Arrays.sort(results); -// answer = Arrays.equals(goodResults, results); -// assertTrue(answer); -// -// -// // null tests -// startDate = null; -// assertEquals(USNYSE.nonBusinessDates(startDate, endDate).length, 0); -// -// startDate = endDate = "2018-01-06"; -// assertEquals(USNYSE.nonBusinessDates(startDate, endDate).length, 1); -// -// // incorrectly formatted days -// try { -// USNYSE.nonBusinessDates("2018-09-31", "2018-010-31"); -// fail(); -// } catch (IllegalArgumentException e) { -// // ok -// } -// } -// -// public void testDayOfWeek() { -// assertEquals(DayOfWeek.WEDNESDAY, test.dayOfWeek()); -// -// String dateString = "2017-02-06"; -// assertEquals(USNYSE.dayOfWeek(dateString), DayOfWeek.MONDAY); -// assertEquals(JPOSE.dayOfWeek(dateString), DayOfWeek.MONDAY); -// -// Instant dateTime = DateTimeUtils.parseInstant("2017-09-01T00:00:00.000000000 NY"); -// assertEquals(USNYSE.dayOfWeek(dateTime), DayOfWeek.FRIDAY); -// assertEquals(JPOSE.dayOfWeek(dateTime), DayOfWeek.FRIDAY); -// -// dateString = null; -// dateTime = null; -// assertNull(USNYSE.dayOfWeek(dateString)); -// assertNull(USNYSE.dayOfWeek(dateTime)); -// -// // incorrectly formatted days -// try { -// USNYSE.dayOfWeek("2018-09-31"); -// fail(); -// } catch (DateTimeException e) { -// // ok -// } -// } -// -// public void testLastBusinessDayOfWeek() { -// assertFalse(test.isLastBusinessDayOfWeek()); -// -// String dateString = "2017-02-10"; -// Instant dateTime = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 NY"); -// assertTrue(USNYSE.isLastBusinessDayOfWeek(dateString)); -// assertFalse(USNYSE.isLastBusinessDayOfWeek(dateTime)); -// assertTrue(JPOSE.isLastBusinessDayOfWeek(dateString)); -// assertFalse(JPOSE.isLastBusinessDayOfWeek(dateTime)); -// -// dateString = null; -// assertFalse(USNYSE.isLastBusinessDayOfWeek(dateString)); -// } -// -// public void testLastBusinessDayOfMonth() { -// assertFalse(test.isLastBusinessDayOfMonth()); -// -// String dateString = "2017-02-28"; -// Instant dateTime = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 NY"); -// assertTrue(USNYSE.isLastBusinessDayOfMonth(dateString)); -// assertFalse(USNYSE.isLastBusinessDayOfMonth(dateTime)); -// assertTrue(JPOSE.isLastBusinessDayOfMonth(dateString)); -// assertFalse(JPOSE.isLastBusinessDayOfMonth(dateTime)); -// -// dateString = null; -// assertFalse(USNYSE.isLastBusinessDayOfMonth(dateString)); -// assertFalse(JPOSE.isLastBusinessDayOfMonth(dateString)); -// } -// -// public void testFractionOfBusinessDay() { -// assertEquals(1.0, test.fractionStandardBusinessDay()); -// -// -// // half day, USNYSE market open from 0930 to 1300 -// String dateString = "2018-11-23"; -// -// // full day -// Instant dateTime = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 NY"); -// -// assertEquals(USNYSE.fractionStandardBusinessDay(dateString), 3.5 / 6.5); -// assertEquals(1.0, USNYSE.fractionStandardBusinessDay(dateTime)); -// -// // half day, JPOSE market open from 0930 to 1300 -// dateString = "2006-01-04"; -// -// assertEquals(JPOSE.fractionStandardBusinessDay(dateString), 0.5); -// assertEquals(1.0, JPOSE.fractionStandardBusinessDay(dateTime)); -// -// -// dateString = null; -// dateTime = null; -// assertEquals(JPOSE.fractionStandardBusinessDay(dateString), 0.0); -// assertEquals(JPOSE.fractionStandardBusinessDay(dateTime), 0.0); -// } -// -// public void testFractionOfBusinessDayLeft() { -// // half day, market open from 0930 to 1300 -// Instant day1 = DateTimeUtils.parseInstant("2018-11-23T10:00:00.000000000 NY"); -// -// // full day -// Instant day2 = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 NY"); -// -// // holiday -// Instant day3 = DateTimeUtils.parseInstant("2017-07-04T00:00:00.000000000 NY"); -// -// assertEquals(USNYSE.fractionBusinessDayRemaining(day1), 3.0 / 3.5); -// assertEquals(USNYSE.fractionBusinessDayComplete(day1), 0.5 / 3.5, 0.0000001); -// assertEquals(USNYSE.fractionBusinessDayRemaining(day2), 1.0); -// assertEquals(USNYSE.fractionBusinessDayComplete(day2), 0.0); -// assertEquals(USNYSE.fractionBusinessDayRemaining(day3), 0.0); -// -// // half day, market open from 0900 to 1130 -// day1 = DateTimeUtils.parseInstant("2006-01-04T10:00:00.000000000 JP"); -// day2 = DateTimeUtils.parseInstant("2017-02-07T00:00:00.000000000 JP"); -// assertEquals(JPOSE.fractionBusinessDayRemaining(day1), 1.5 / 2.5); -// assertEquals(JPOSE.fractionBusinessDayComplete(day1), 1.0 / 2.5); -// assertEquals(JPOSE.fractionBusinessDayRemaining(day2), 1.0); -// assertEquals(JPOSE.fractionBusinessDayComplete(day2), 0.0); -// -// -// assertEquals(JPOSE.fractionOfBusinessDayRemaining(null), QueryConstants.NULL_DOUBLE); -// assertEquals(JPOSE.fractionOfBusinessDayComplete(null), QueryConstants.NULL_DOUBLE); -// } -// -// public void testCurrentBusinessSchedule() { -// assertEquals(test.nextBusinessSchedule("2017-09-26"), test.businessSchedule()); -// } -// -// public void testMidnightClose() { -// assertEquals(DateTimeUtils.DAY, UTC.standardBusinessNanos()); -// assertEquals("2019-04-16", UTC.futureDate("2019-04-15")); -// assertEquals("2019-04-16", UTC.futureBusinessDate("2019-04-15")); -// assertEquals("2019-04-18", UTC.futureBusinessDate("2019-04-15", 3)); -// assertEquals("2019-08-19", -// UTC.futureBusinessDate(DateTimeUtils.parseInstant("2019-08-18T00:00:00.000000000 UTC"))); -// -// assertEquals("2019-05-16", DateTimeUtils.formatDate(UTC.businessSchedule("2019-05-16").businessStart(), TZ_UTC)); -// assertEquals("2019-05-17", DateTimeUtils.formatDate(UTC.businessSchedule("2019-05-16").businessEnd(), TZ_UTC)); -// } } From 54b0d655a8e34ee3f63aac80441cedec5570b1cf Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Mon, 17 Jul 2023 14:18:15 -0600 Subject: [PATCH 044/150] Unit test: * BusinessCalendar - Getters --- .../time/calendar/BusinessCalendar.java | 23 +++++++++++++++++++ .../time/calendar/TestBusinessCalendar.java | 5 ++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index 189c06ad574..2a916027a65 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -139,6 +139,29 @@ public BusinessCalendar(final String name, final String description, final ZoneI populateCachedYearData(); } + // endregion + + // region Getters + + /** + * Returns the first valid date for the business calendar. + * + * @return first valid date for the business calendar. + */ + public LocalDate firstValidDate() { + return firstValidDate; + } + + /** + * Returns the last valid date for the business calendar. + * + * @return last valid date for the business calendar. + */ + public LocalDate lastValidDate() { + return lastValidDate; + } + + // endregion // region Business Schedule diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java index 3c912789073..c2d72448715 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java @@ -47,9 +47,8 @@ public void testBusinessGetters() { assertEquals(schedule, bCalendar.standardBusinessSchedule()); assertEquals(schedule.businessNanos(), bCalendar.standardBusinessNanos()); assertEquals(holidays, bCalendar.holidays()); - //TODO: implement -// assertEquals(firstValidDate, bCalendar.firstValidDate()); -// assertEquals(lastValidDate, bCalendar.lastValidDate()); + assertEquals(firstValidDate, bCalendar.firstValidDate()); + assertEquals(lastValidDate, bCalendar.lastValidDate()); } public void testBusinessSchedule() { From c4b67fdde62ac573bd65ecd689a09010243aaf97 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Mon, 17 Jul 2023 14:29:34 -0600 Subject: [PATCH 045/150] Committing to rebase --- .../impl/QueryLibraryImportsDefaults.java | 2 + .../util/TestCalendarMethodsFromTable.java | 32 +- .../time/calendar/StaticCalendarMethods.java | 1193 +++++++++++------ .../calendar/StaticCalendarMethodsTest.java | 344 ++--- py/server/deephaven/calendar.py | 71 +- py/server/deephaven/time.py | 35 +- 6 files changed, 1068 insertions(+), 609 deletions(-) diff --git a/engine/table/src/main/java/io/deephaven/engine/table/lang/impl/QueryLibraryImportsDefaults.java b/engine/table/src/main/java/io/deephaven/engine/table/lang/impl/QueryLibraryImportsDefaults.java index 256a5359fae..1226d44b388 100644 --- a/engine/table/src/main/java/io/deephaven/engine/table/lang/impl/QueryLibraryImportsDefaults.java +++ b/engine/table/src/main/java/io/deephaven/engine/table/lang/impl/QueryLibraryImportsDefaults.java @@ -22,6 +22,7 @@ import io.deephaven.function.*; import io.deephaven.gui.color.Color; import io.deephaven.time.DateTimeUtils; +import io.deephaven.time.calendar.Calendars; import io.deephaven.time.calendar.StaticCalendarMethods; import io.deephaven.util.QueryConstants; import io.deephaven.util.datastructures.LongSizedDataStructure; @@ -119,6 +120,7 @@ public Set> statics() { Color.class, ColorUtilImpl.class, TableAssertions.class, + Calendars.class, StaticCalendarMethods.class)); } } diff --git a/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java b/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java index 6082dc9de6d..fb4223830a6 100644 --- a/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java +++ b/engine/table/src/test/java/io/deephaven/engine/util/TestCalendarMethodsFromTable.java @@ -62,27 +62,27 @@ public void testCalendarMethodsTable() { assertEquals(calendar.currentDate(), getVal(emptyTable(1).update("currentDay = currentDay()"), "currentDay")); - assertEquals(calendar.pastDate(), + assertEquals(calendar..pastDate(1), getVal(emptyTable(1).update("previousDay = previousDay()"), "previousDay")); assertEquals(calendar.pastDate(4), getVal(emptyTable(1).update("previousDay = previousDay(4)"), "previousDay")); - assertEquals(calendar.pastDate(time1), + assertEquals(calendar.minusDays(time1,1), getVal(emptyTable(1).update("previousDay = previousDay(time1)"), "previousDay")); - assertEquals(calendar.pastDate(time1, 4), + assertEquals(calendar.minusDays(time1, 4), getVal(emptyTable(1).update("previousDay = previousDay(time1, 4)"), "previousDay")); - assertEquals(calendar.pastDate(date1), + assertEquals(calendar.minusDays(date1,1), getVal(emptyTable(1).update("previousDay = previousDay(date1)"), "previousDay")); - assertEquals(calendar.pastDate(date1, 14), + assertEquals(calendar.minusDays(date1, 14), getVal(emptyTable(1).update("previousDay = previousDay(date1, 14)"), "previousDay")); - assertEquals(calendar.futureDate(), getVal(emptyTable(1).update("nextDay = nextDay()"), "nextDay")); + assertEquals(calendar.futureDate(1), getVal(emptyTable(1).update("nextDay = nextDay(1)"), "nextDay")); assertEquals(calendar.futureDate(4), getVal(emptyTable(1).update("nextDay = nextDay(4)"), "nextDay")); - assertEquals(calendar.futureDate(time1), getVal(emptyTable(1).update("nextDay = nextDay(time1)"), "nextDay")); - assertEquals(calendar.futureDate(time1, 4), + assertEquals(calendar.plusDays(time1,1), getVal(emptyTable(1).update("nextDay = nextDay(time1)"), "nextDay")); + assertEquals(calendar.plusDays(time1, 4), getVal(emptyTable(1).update("nextDay = nextDay(time1, 4)"), "nextDay")); - assertEquals(calendar.futureDate(date1), getVal(emptyTable(1).update("nextDay = nextDay(date1)"), "nextDay")); - assertEquals(calendar.futureDate(date1, 14), + assertEquals(calendar.plusDays(date1,1), getVal(emptyTable(1).update("nextDay = nextDay(date1)"), "nextDay")); + assertEquals(calendar.plusDays(date1, 14), getVal(emptyTable(1).update("nextDay = nextDay(date1, 14)"), "nextDay")); assertEquals(calendar.calendarDates(time1, time2), @@ -257,7 +257,7 @@ public void testBusinessCalendarMethodsTable() { "nonBusinessDaysInRange")); - assertEquals(calendar.standardBusinessDayLengthNanos(), + assertEquals(calendar.standardBusinessNanos(), getVal(emptyTable(1).update("standardBusinessDayLengthNanos = standardBusinessDayLengthNanos()"), "standardBusinessDayLengthNanos")); @@ -304,21 +304,21 @@ public void testBusinessCalendarMethodsTable() { "numberOfNonBusinessDays")); - assertEquals(calendar.fractionOfStandardBusinessDay(), + assertEquals(calendar.fractionStandardBusinessDay(), getVal(emptyTable(1).update("fractionOfStandardBusinessDay = fractionOfStandardBusinessDay()"), "fractionOfStandardBusinessDay")); - assertEquals(calendar.fractionOfStandardBusinessDay(time1), + assertEquals(calendar.fractionStandardBusinessDay(time1), getVal(emptyTable(1).update("fractionOfStandardBusinessDay = fractionOfStandardBusinessDay(time1)"), "fractionOfStandardBusinessDay")); - assertEquals(calendar.fractionOfStandardBusinessDay(date1), + assertEquals(calendar.fractionStandardBusinessDay(date1), getVal(emptyTable(1).update("fractionOfStandardBusinessDay = fractionOfStandardBusinessDay(date1)"), "fractionOfStandardBusinessDay")); - assertEquals(calendar.fractionOfBusinessDayRemaining(time1), + assertEquals(calendar.fractionBusinessDayRemaining(time1), getVal(emptyTable(1).update("fractionOfBusinessDayRemaining = fractionOfBusinessDayRemaining(time1)"), "fractionOfBusinessDayRemaining")); - assertEquals(calendar.fractionOfBusinessDayComplete(time1), + assertEquals(calendar.fractionBusinessDayComplete(time1), getVal(emptyTable(1).update("fractionOfBusinessDayComplete = fractionOfBusinessDayComplete(time1)"), "fractionOfBusinessDayComplete")); diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/StaticCalendarMethods.java b/engine/time/src/main/java/io/deephaven/time/calendar/StaticCalendarMethods.java index 4e7a4a728dd..f886aa888d8 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/StaticCalendarMethods.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/StaticCalendarMethods.java @@ -1,12 +1,14 @@ /** * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending */ +//TODO: update copyrights package io.deephaven.time.calendar; -import java.time.DayOfWeek; -import java.time.Instant; -import java.time.LocalDate; -import java.time.ZoneId; +import java.time.*; + +//TODO: major cleanup + +** /** * Convenience methods for {@link BusinessCalendar} and {@link Calendar}. @@ -21,394 +23,803 @@ public class StaticCalendarMethods { // public static long diffYear(final Instant start, final Instant end) { private StaticCalendarMethods() { - - } - - public static String name() { - return Calendars.calendar().name(); - } - - public static String currentDay() { - return Calendars.calendar().currentDate(); - } - - public static String previousDay() { - return Calendars.calendar().pastDate(); - } - - public static String previousDay(int days) { - return Calendars.calendar().pastDate(days); - } - - public static String previousDay(final Instant time) { - return Calendars.calendar().pastDate(time); - } - - public static String previousDay(final Instant time, final int days) { - return Calendars.calendar().pastDate(time, days); - } - - public static String previousDay(final String date) { - return Calendars.calendar().pastDate(date); - } - - public static String previousDay(final String date, final int days) { - return Calendars.calendar().pastDate(date, days); - } - - public static String nextDay() { - return Calendars.calendar().futureDate(); - } - - public static String nextDay(int days) { - return Calendars.calendar().futureDate(days); - } - - public static String nextDay(final Instant time) { - return Calendars.calendar().futureDate(time); - } - - public static String nextDay(final Instant time, final int days) { - return Calendars.calendar().futureDate(time, days); - } - - public static String nextDay(final String date) { - return Calendars.calendar().futureDate(date); - } - - public static String nextDay(final String date, final int days) { - return Calendars.calendar().futureDate(date, days); - } - - public static String[] daysInRange(Instant start, Instant end) { - return Calendars.calendar().calendarDates(start, end); - } - - public static String[] daysInRange(final String start, final String end) { - return Calendars.calendar().calendarDates(start, end); - } - - public static int numberOfDays(final Instant start, final Instant end) { - return Calendars.calendar().numberCalendarDates(start, end); - } - - public static int numberOfDays(final Instant start, final Instant end, final boolean endInclusive) { - return Calendars.calendar().numberCalendarDates(start, end, endInclusive); - } - - public static int numberOfDays(final String start, final String end) { - return Calendars.calendar().numberCalendarDates(start, end); - } - - public static int numberOfDays(final String start, final String end, final boolean endInclusive) { - return Calendars.calendar().numberCalendarDates(start, end, endInclusive); - } - - public static DayOfWeek dayOfWeek() { - return Calendars.calendar().dayOfWeek(); - } - - public static DayOfWeek dayOfWeek(final Instant time) { - return Calendars.calendar().dayOfWeek(time); - } - - public static DayOfWeek dayOfWeek(final String date) { - return Calendars.calendar().dayOfWeek(date); } - public static ZoneId calendarTimeZone() { - return Calendars.calendar().timeZone(); - } - - public static boolean isBusinessDay() { - return Calendars.calendar().isBusinessDay(); - } - - public static boolean isBusinessDay(Instant time) { - return Calendars.calendar().isBusinessDay(time); - } - - public static boolean isBusinessDay(String date) { - return Calendars.calendar().isBusinessDay(date); - } - - public static boolean isBusinessDay(LocalDate date) { - return Calendars.calendar().isBusinessDay(date); - } - - public static boolean isBusinessTime(Instant time) { - return Calendars.calendar().isBusinessTime(time); - } - - public static String previousBusinessDay() { - return Calendars.calendar().pastBusinessDate(); - } - - public static String previousBusinessDay(int days) { - return Calendars.calendar().pastBusinessDate(days); - } - - public static String previousBusinessDay(Instant time) { - return Calendars.calendar().pastBusinessDate(time); - } - - public static String previousBusinessDay(Instant time, int days) { - return Calendars.calendar().pastBusinessDate(time, days); - } - - public static String previousBusinessDay(String date) { - return Calendars.calendar().pastBusinessDate(date); - } - - public static String previousBusinessDay(String date, int days) { - return Calendars.calendar().pastBusinessDate(date, days); - } - - public static BusinessSchedule previousBusinessSchedule() { - return Calendars.calendar().previousBusinessSchedule(); - } - - public static BusinessSchedule previousBusinessSchedule(int days) { - return Calendars.calendar().previousBusinessSchedule(days); - } - - public static BusinessSchedule previousBusinessSchedule(Instant time) { - return Calendars.calendar().previousBusinessSchedule(time); - } - - public static BusinessSchedule previousBusinessSchedule(Instant time, int days) { - return Calendars.calendar().previousBusinessSchedule(time, days); - } - - public static BusinessSchedule previousBusinessSchedule(String date) { - return Calendars.calendar().previousBusinessSchedule(date); - } - - public static BusinessSchedule previousBusinessSchedule(String date, int days) { - return Calendars.calendar().previousBusinessSchedule(date, days); - } - - public static String previousNonBusinessDay() { - return Calendars.calendar().pastNonBusinessDate(); - } - - public static String previousNonBusinessDay(int days) { - return Calendars.calendar().pastNonBusinessDate(days); - } - - public static String previousNonBusinessDay(Instant time) { - return Calendars.calendar().pastNonBusinessDate(time); - } - - public static String previousNonBusinessDay(Instant time, int days) { - return Calendars.calendar().pastNonBusinessDate(time, days); - } - - public static String previousNonBusinessDay(String date) { - return Calendars.calendar().pastNonBusinessDate(date); - } - - public static String previousNonBusinessDay(String date, int days) { - return Calendars.calendar().pastNonBusinessDate(date, days); - } - - public static String nextBusinessDay() { - return Calendars.calendar().futureBusinessDate(); - } - public static String nextBusinessDay(int days) { - return Calendars.calendar().futureBusinessDate(days); - } - - public static String nextBusinessDay(Instant time) { - return Calendars.calendar().futureBusinessDate(time); - } - - public static String nextBusinessDay(Instant time, int days) { - return Calendars.calendar().futureBusinessDate(time, days); - } - - public static String nextBusinessDay(String date) { - return Calendars.calendar().futureBusinessDate(date); - } - - public static String nextBusinessDay(String date, int days) { - return Calendars.calendar().futureBusinessDate(date, days); - } - - public static BusinessSchedule nextBusinessSchedule() { - return Calendars.calendar().nextBusinessSchedule(); - } - - public static BusinessSchedule nextBusinessSchedule(int days) { - return Calendars.calendar().nextBusinessSchedule(days); - } - - public static BusinessSchedule nextBusinessSchedule(Instant time) { - return Calendars.calendar().nextBusinessSchedule(time); - } - - public static BusinessSchedule nextBusinessSchedule(Instant time, int days) { - return Calendars.calendar().nextBusinessSchedule(time, days); - } - - public static BusinessSchedule nextBusinessSchedule(String date) { - return Calendars.calendar().nextBusinessSchedule(date); - } - - public static BusinessSchedule nextBusinessSchedule(String date, int days) { - return Calendars.calendar().nextBusinessSchedule(date, days); - } - - public static String nextNonBusinessDay() { - return Calendars.calendar().futureNonBusinessDate(); - } - - public static String nextNonBusinessDay(int days) { - return Calendars.calendar().futureNonBusinessDate(days); - } - - public static String nextNonBusinessDay(Instant time) { - return Calendars.calendar().futureNonBusinessDate(time); - } - - public static String nextNonBusinessDay(Instant time, int days) { - return Calendars.calendar().futureNonBusinessDate(time, days); - } - - public static String nextNonBusinessDay(String date) { - return Calendars.calendar().futureNonBusinessDate(date); - } - - public static String nextNonBusinessDay(String date, int days) { - return Calendars.calendar().futureNonBusinessDate(date, days); - } - - public static String[] businessDaysInRange(Instant start, Instant end) { - return Calendars.calendar().businessDates(start, end); - } - - public static String[] businessDaysInRange(String start, String end) { - return Calendars.calendar().businessDates(start, end); - } - - public static String[] nonBusinessDaysInRange(Instant start, Instant end) { - return Calendars.calendar().nonBusinessDates(start, end); - } - - public static String[] nonBusinessDaysInRange(String start, String end) { - return Calendars.calendar().nonBusinessDates(start, end); - } - - public static long standardBusinessDayLengthNanos() { - return Calendars.calendar().standardBusinessDayLengthNanos(); - } - - public static long diffBusinessNanos(Instant start, Instant end) { - return Calendars.calendar().diffBusinessNanos(start, end); - } - - public static long diffNonBusinessNanos(Instant start, Instant end) { - return Calendars.calendar().diffNonBusinessNanos(start, end); - } - - public static double diffBusinessDay(Instant start, Instant end) { - return Calendars.calendar().diffBusinessDays(start, end); - } - - public static double diffNonBusinessDay(Instant start, Instant end) { - return Calendars.calendar().diffNonBusinessDays(start, end); - } - - public static double diffBusinessYear(Instant start, Instant end) { - return Calendars.calendar().diffBusinessYears(start, end); - } - - public static int numberOfBusinessDays(Instant start, Instant end) { - return Calendars.calendar().numberOfBusinessDays(start, end); - } - - public static int numberOfBusinessDays(Instant start, Instant end, boolean endInclusive) { - return Calendars.calendar().numberBusinessDates(start, end, endInclusive); - } - - public static int numberOfBusinessDays(String start, String end) { - return Calendars.calendar().numberOfBusinessDays(start, end); - } - - public static int numberOfBusinessDays(String start, String end, boolean endInclusive) { - return Calendars.calendar().numberBusinessDates(start, end, endInclusive); - } - - public static int numberOfNonBusinessDays(Instant start, Instant end) { - return Calendars.calendar().numberOfNonBusinessDays(start, end); - } - - public static int numberOfNonBusinessDays(Instant start, Instant end, boolean endInclusive) { - return Calendars.calendar().numberNonBusinessDates(start, end, endInclusive); - } - - public static int numberOfNonBusinessDays(String start, String end) { - return Calendars.calendar().numberOfNonBusinessDays(start, end); - } - - public static int numberOfNonBusinessDays(String start, String end, boolean endInclusive) { - return Calendars.calendar().numberNonBusinessDates(start, end, endInclusive); - } - - public static double fractionOfStandardBusinessDay() { - return Calendars.calendar().fractionOfStandardBusinessDay(); - } - - public static double fractionOfStandardBusinessDay(Instant time) { - return Calendars.calendar().fractionOfStandardBusinessDay(time); - } - - public static double fractionOfStandardBusinessDay(String date) { - return Calendars.calendar().fractionOfStandardBusinessDay(date); - } - - public static double fractionOfBusinessDayRemaining(Instant time) { - return Calendars.calendar().fractionOfBusinessDayRemaining(time); - } - - public static double fractionOfBusinessDayComplete(Instant time) { - return Calendars.calendar().fractionOfBusinessDayComplete(time); - } - - public static boolean isLastBusinessDayOfMonth() { - return Calendars.calendar().isLastBusinessDayOfMonth(); - } - - public static boolean isLastBusinessDayOfMonth(Instant time) { - return Calendars.calendar().isLastBusinessDayOfMonth(time); - } - - public static boolean isLastBusinessDayOfMonth(String date) { - return Calendars.calendar().isLastBusinessDayOfMonth(date); - } - - public static boolean isLastBusinessDayOfWeek() { - return Calendars.calendar().isLastBusinessDayOfWeek(); - } - - public static boolean isLastBusinessDayOfWeek(Instant time) { - return Calendars.calendar().isLastBusinessDayOfWeek(time); - } - - public static boolean isLastBusinessDayOfWeek(String date) { - return Calendars.calendar().isLastBusinessDayOfWeek(date); - } - - public static BusinessSchedule getBusinessSchedule(Instant time) { - return Calendars.calendar().businessSchedule(time); - } - - public static BusinessSchedule getBusinessSchedule(String date) { - return Calendars.calendar().businessSchedule(date); - } - - public static BusinessSchedule getBusinessSchedule(LocalDate date) { - return Calendars.calendar().businessSchedule(date); - } +// +// +// +// ***** +// +// public static String name() { +// } +// +// public static String description() { +// } +// +// public static ZoneId timeZone() { +// } +// +// public static LocalDate plusDays(final LocalDate date, final int days) { +// } +// +// public static LocalDate plusDays(final String date, final int days) { +// } +// +// public static LocalDate plusDays(final Instant time, final int days) { +// } +// +// public static LocalDate plusDays(final ZonedDateTime time, final int days) { +// } +// +// public static LocalDate minusDays(final LocalDate date, final int days) { +// } +// +// public static LocalDate minusDays(final String date, final int days) { +// } +// +// public static LocalDate minusDays(final Instant time, final int days) { +// } +// +// public static LocalDate minusDays(final ZonedDateTime time, final int days) { +// } +// +// public static LocalDate currentDate() { +// } +// +// public static LocalDate futureDate(final int days) { +// } +// +// public static LocalDate pastDate(final int days) { +// } +// +// public static LocalDate[] calendarDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static LocalDate[] calendarDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static LocalDate[] calendarDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static LocalDate[] calendarDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static LocalDate[] calendarDates(final LocalDate start, final LocalDate end) { +// } +// +// public static LocalDate[] calendarDates(final String start, final String end) { +// } +// +// public static LocalDate[] calendarDates(final ZonedDateTime start, final ZonedDateTime end) { +// } +// +// public static LocalDate[] calendarDates(final Instant start, final Instant end) { +// } +// +// public static int numberCalendarDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static int numberCalendarDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static int numberCalendarDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static int numberCalendarDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static int numberCalendarDates(final LocalDate start, final LocalDate end) { +// } +// +// public static int numberCalendarDates(final String start, final String end) { +// } +// +// public static int numberCalendarDates(final ZonedDateTime start, final ZonedDateTime end) { +// } +// +// public static int numberCalendarDates(final Instant start, final Instant end) { +// } +// +// ***** +// +// public static static class InvalidDateException extends RuntimeException { +// } +// +// public static InvalidDateException(final String message, final Throwable cause) { +// } +// +// public static YearData(final Instant start, final Instant end, final long businessTimeNanos) { +// } +// +// public static BusinessCalendar(final String name, final String description, final ZoneId timeZone, final LocalDate firstValidDate, final LocalDate lastValidDate, final BusinessSchedule standardBusinessSchedule, final Set weekendDays, final Map> holidays) { +// } +// +// public static BusinessSchedule standardBusinessSchedule() { +// } +// +// public static long standardBusinessNanos() { +// } +// +// public static Map> holidays() { +// } +// +// public static BusinessSchedule businessSchedule(final LocalDate date) { +// } +// +// public static BusinessSchedule businessSchedule(final ZonedDateTime time) { +// } +// +// public static BusinessSchedule businessSchedule(final Instant time) { +// } +// +// public static BusinessSchedule businessSchedule(final String date) { +// } +// +// public static BusinessSchedule businessSchedule() { +// } +// +// public static boolean isBusinessDay(final LocalDate date) { +// } +// +// public static boolean isBusinessDay(final String date) { +// } +// +// public static boolean isBusinessDay(final ZonedDateTime time) { +// } +// +// public static boolean isBusinessDay(final Instant time) { +// } +// +// public static boolean isBusinessDay(final DayOfWeek day) { +// } +// +// public static boolean isBusinessDay() { +// } +// +// public static boolean isLastBusinessDayOfMonth(final ZonedDateTime time) { +// } +// +// public static boolean isLastBusinessDayOfMonth(final Instant time) { +// } +// +// public static boolean isLastBusinessDayOfMonth() { +// } +// +// public static boolean isLastBusinessDayOfWeek(final LocalDate date) { +// } +// +// public static boolean isLastBusinessDayOfWeek(final ZonedDateTime time) { +// } +// +// public static boolean isLastBusinessDayOfWeek(final Instant time) { +// } +// +// public static boolean isLastBusinessDayOfWeek(final String date) { +// } +// +// public static boolean isLastBusinessDayOfWeek() { +// } +// +// public static boolean isLastBusinessDayOfYear(final ZonedDateTime time) { +// } +// +// public static boolean isLastBusinessDayOfYear(final Instant time) { +// } +// +// public static boolean isLastBusinessDayOfYear() { +// } +// +// public static boolean isBusinessTime(final ZonedDateTime time) { +// } +// +// public static boolean isBusinessTime(final Instant time) { +// } +// +// public static boolean isBusinessTime() { +// } +// +// public static double fractionStandardBusinessDay(final LocalDate date) { +// } +// +// public static double fractionStandardBusinessDay(final String date) { +// } +// +// public static double fractionStandardBusinessDay(final Instant time) { +// } +// +// public static double fractionStandardBusinessDay(final ZonedDateTime time) { +// } +// +// public static double fractionStandardBusinessDay() { +// } +// +// public static double fractionBusinessDayComplete(final Instant time) { +// } +// +// public static double fractionBusinessDayComplete(final ZonedDateTime time) { +// } +// +// public static double fractionBusinessDayComplete() { +// } +// +// public static double fractionBusinessDayRemaining(final Instant time) { +// } +// +// public static double fractionBusinessDayRemaining(final ZonedDateTime time) { +// } +// +// public static double fractionBusinessDayRemaining() { +// } +// +// public static int numberBusinessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static int numberBusinessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static int numberBusinessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static int numberBusinessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static int numberBusinessDates(final LocalDate start, final LocalDate end) { +// } +// +// public static int numberBusinessDates(final String start, final String end) { +// } +// +// public static int numberBusinessDates(final ZonedDateTime start, final ZonedDateTime end) { +// } +// +// public static int numberBusinessDates(final Instant start, final Instant end) { +// } +// +// public static int numberNonBusinessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static int numberNonBusinessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static int numberNonBusinessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static int numberNonBusinessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static int numberNonBusinessDates(final LocalDate start, final LocalDate end) { +// } +// +// public static int numberNonBusinessDates(final String start, final String end) { +// } +// +// public static int numberNonBusinessDates(final ZonedDateTime start, final ZonedDateTime end) { +// } +// +// public static int numberNonBusinessDates(final Instant start, final Instant end) { +// } +// +// public static LocalDate[] businessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static LocalDate[] businessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static LocalDate[] businessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static LocalDate[] businessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static LocalDate[] businessDates(final LocalDate start, final LocalDate end) { +// } +// +// public static LocalDate[] businessDates(final String start, final String end) { +// } +// +// public static LocalDate[] businessDates(final ZonedDateTime start, final ZonedDateTime end) { +// } +// +// public static LocalDate[] businessDates(final Instant start, final Instant end) { +// } +// +// public static LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static LocalDate[] nonBusinessDates(final String start, final String end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static LocalDate[] nonBusinessDates(final ZonedDateTime start, final ZonedDateTime end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static LocalDate[] nonBusinessDates(final Instant start, final Instant end, final boolean startInclusive, final boolean endInclusive) { +// } +// +// public static LocalDate[] nonBusinessDates(final LocalDate start, final LocalDate end) { +// } +// +// public static LocalDate[] nonBusinessDates(final String start, final String end) { +// } +// +// public static LocalDate[] nonBusinessDates(final ZonedDateTime start, final ZonedDateTime end) { +// } +// +// public static LocalDate[] nonBusinessDates(final Instant start, final Instant end) { +// } +// +// public static long diffBusinessNanos(final Instant start, final Instant end) { +// } +// +// public static long diffBusinessNanos(final ZonedDateTime start, final ZonedDateTime end) { +// } +// +// public static long diffNonBusinessNanos(final Instant start, final Instant end) { +// } +// +// public static long diffNonBusinessNanos(final ZonedDateTime start, final ZonedDateTime end) { +// } +// +// public static double diffBusinessDays(final Instant start, final Instant end) { +// } +// +// public static double diffBusinessDays(final ZonedDateTime start, final ZonedDateTime end) { +// } +// +// public static double diffBusinessYears(final Instant start, final Instant end) { +// } +// +// public static double diffBusinessYears(final ZonedDateTime start, final ZonedDateTime end) { +// } +// +// public static LocalDate plusBusinessDays(final LocalDate date, final int days) { +// } +// +// public static LocalDate plusBusinessDays(final String date, final int days) { +// } +// +// public static LocalDate plusBusinessDays(final Instant time, final int days) { +// } +// +// public static LocalDate plusBusinessDays(final ZonedDateTime time, final int days) { +// } +// +// public static LocalDate minusBusinessDays(final LocalDate date, final int days) { +// } +// +// public static LocalDate minusBusinessDays(final String date, final int days) { +// } +// +// public static LocalDate minusBusinessDays(final Instant time, final int days) { +// } +// +// public static LocalDate minusBusinessDays(final ZonedDateTime time, final int days) { +// } +// +// public static LocalDate plusNonBusinessDays(final LocalDate date, final int days) { +// } +// +// public static LocalDate plusNonBusinessDays(final String date, final int days) { +// } +// +// public static LocalDate plusNonBusinessDays(final Instant time, final int days) { +// } +// +// public static LocalDate plusNonBusinessDays(final ZonedDateTime time, final int days) { +// } +// +// public static LocalDate minusNonBusinessDays(final LocalDate date, final int days) { +// } +// +// public static LocalDate minusNonBusinessDays(final String date, final int days) { +// } +// +// public static LocalDate minusNonBusinessDays(final Instant time, final int days) { +// } +// +// public static LocalDate minusNonBusinessDays(final ZonedDateTime time, final int days) { +// } +// +// public static LocalDate futureBusinessDate(final int days) { +// } +// +// public static LocalDate pastBusinessDate(final int days) { +// } +// +// public static LocalDate futureNonBusinessDate(final int days) { +// } +// +// public static LocalDate pastNonBusinessDate(final int days) { +// } +// +// +// ***** +// +// public static String name() { +// return Calendars.calendar().name(); +// } +// +// public static String currentDay() { +// return Calendars.calendar().currentDate(); +// } +// +// public static String previousDay() { +// return Calendars.calendar().pastDate(); +// } +// +// public static String previousDay(int days) { +// return Calendars.calendar().pastDate(days); +// } +// +// public static String previousDay(final Instant time) { +// return Calendars.calendar().pastDate(time); +// } +// +// public static String previousDay(final Instant time, final int days) { +// return Calendars.calendar().pastDate(time, days); +// } +// +// public static String previousDay(final String date) { +// return Calendars.calendar().pastDate(date); +// } +// +// public static String previousDay(final String date, final int days) { +// return Calendars.calendar().pastDate(date, days); +// } +// +// public static String nextDay() { +// return Calendars.calendar().futureDate(); +// } +// +// public static String nextDay(int days) { +// return Calendars.calendar().futureDate(days); +// } +// +// public static String nextDay(final Instant time) { +// return Calendars.calendar().futureDate(time); +// } +// +// public static String nextDay(final Instant time, final int days) { +// return Calendars.calendar().futureDate(time, days); +// } +// +// public static String nextDay(final String date) { +// return Calendars.calendar().futureDate(date); +// } +// +// public static String nextDay(final String date, final int days) { +// return Calendars.calendar().futureDate(date, days); +// } +// +// public static String[] daysInRange(Instant start, Instant end) { +// return Calendars.calendar().calendarDates(start, end); +// } +// +// public static String[] daysInRange(final String start, final String end) { +// return Calendars.calendar().calendarDates(start, end); +// } +// +// public static int numberOfDays(final Instant start, final Instant end) { +// return Calendars.calendar().numberCalendarDates(start, end); +// } +// +// public static int numberOfDays(final Instant start, final Instant end, final boolean endInclusive) { +// return Calendars.calendar().numberCalendarDates(start, end, endInclusive); +// } +// +// public static int numberOfDays(final String start, final String end) { +// return Calendars.calendar().numberCalendarDates(start, end); +// } +// +// public static int numberOfDays(final String start, final String end, final boolean endInclusive) { +// return Calendars.calendar().numberCalendarDates(start, end, endInclusive); +// } +// +// public static DayOfWeek dayOfWeek() { +// return Calendars.calendar().dayOfWeek(); +// } +// +// public static DayOfWeek dayOfWeek(final Instant time) { +// return Calendars.calendar().dayOfWeek(time); +// } +// +// public static DayOfWeek dayOfWeek(final String date) { +// return Calendars.calendar().dayOfWeek(date); +// } +// +// public static ZoneId calendarTimeZone() { +// return Calendars.calendar().timeZone(); +// } +// +// public static boolean isBusinessDay() { +// return Calendars.calendar().isBusinessDay(); +// } +// +// public static boolean isBusinessDay(Instant time) { +// return Calendars.calendar().isBusinessDay(time); +// } +// +// public static boolean isBusinessDay(String date) { +// return Calendars.calendar().isBusinessDay(date); +// } +// +// public static boolean isBusinessDay(LocalDate date) { +// return Calendars.calendar().isBusinessDay(date); +// } +// +// public static boolean isBusinessTime(Instant time) { +// return Calendars.calendar().isBusinessTime(time); +// } +// +// public static String previousBusinessDay() { +// return Calendars.calendar().pastBusinessDate(); +// } +// +// public static String previousBusinessDay(int days) { +// return Calendars.calendar().pastBusinessDate(days); +// } +// +// public static String previousBusinessDay(Instant time) { +// return Calendars.calendar().pastBusinessDate(time); +// } +// +// public static String previousBusinessDay(Instant time, int days) { +// return Calendars.calendar().pastBusinessDate(time, days); +// } +// +// public static String previousBusinessDay(String date) { +// return Calendars.calendar().pastBusinessDate(date); +// } +// +// public static String previousBusinessDay(String date, int days) { +// return Calendars.calendar().pastBusinessDate(date, days); +// } +// +// public static BusinessSchedule previousBusinessSchedule() { +// return Calendars.calendar().previousBusinessSchedule(); +// } +// +// public static BusinessSchedule previousBusinessSchedule(int days) { +// return Calendars.calendar().previousBusinessSchedule(days); +// } +// +// public static BusinessSchedule previousBusinessSchedule(Instant time) { +// return Calendars.calendar().previousBusinessSchedule(time); +// } +// +// public static BusinessSchedule previousBusinessSchedule(Instant time, int days) { +// return Calendars.calendar().previousBusinessSchedule(time, days); +// } +// +// public static BusinessSchedule previousBusinessSchedule(String date) { +// return Calendars.calendar().previousBusinessSchedule(date); +// } +// +// public static BusinessSchedule previousBusinessSchedule(String date, int days) { +// return Calendars.calendar().previousBusinessSchedule(date, days); +// } +// +// public static String previousNonBusinessDay() { +// return Calendars.calendar().pastNonBusinessDate(); +// } +// +// public static String previousNonBusinessDay(int days) { +// return Calendars.calendar().pastNonBusinessDate(days); +// } +// +// public static String previousNonBusinessDay(Instant time) { +// return Calendars.calendar().pastNonBusinessDate(time); +// } +// +// public static String previousNonBusinessDay(Instant time, int days) { +// return Calendars.calendar().pastNonBusinessDate(time, days); +// } +// +// public static String previousNonBusinessDay(String date) { +// return Calendars.calendar().pastNonBusinessDate(date); +// } +// +// public static String previousNonBusinessDay(String date, int days) { +// return Calendars.calendar().pastNonBusinessDate(date, days); +// } +// +// public static String nextBusinessDay() { +// return Calendars.calendar().futureBusinessDate(); +// } +// +// public static String nextBusinessDay(int days) { +// return Calendars.calendar().futureBusinessDate(days); +// } +// +// public static String nextBusinessDay(Instant time) { +// return Calendars.calendar().futureBusinessDate(time); +// } +// +// public static String nextBusinessDay(Instant time, int days) { +// return Calendars.calendar().futureBusinessDate(time, days); +// } +// +// public static String nextBusinessDay(String date) { +// return Calendars.calendar().futureBusinessDate(date); +// } +// +// public static String nextBusinessDay(String date, int days) { +// return Calendars.calendar().futureBusinessDate(date, days); +// } +// +// public static BusinessSchedule nextBusinessSchedule() { +// return Calendars.calendar().nextBusinessSchedule(); +// } +// +// public static BusinessSchedule nextBusinessSchedule(int days) { +// return Calendars.calendar().nextBusinessSchedule(days); +// } +// +// public static BusinessSchedule nextBusinessSchedule(Instant time) { +// return Calendars.calendar().nextBusinessSchedule(time); +// } +// +// public static BusinessSchedule nextBusinessSchedule(Instant time, int days) { +// return Calendars.calendar().nextBusinessSchedule(time, days); +// } +// +// public static BusinessSchedule nextBusinessSchedule(String date) { +// return Calendars.calendar().nextBusinessSchedule(date); +// } +// +// public static BusinessSchedule nextBusinessSchedule(String date, int days) { +// return Calendars.calendar().nextBusinessSchedule(date, days); +// } +// +// public static String nextNonBusinessDay() { +// return Calendars.calendar().futureNonBusinessDate(); +// } +// +// public static String nextNonBusinessDay(int days) { +// return Calendars.calendar().futureNonBusinessDate(days); +// } +// +// public static String nextNonBusinessDay(Instant time) { +// return Calendars.calendar().futureNonBusinessDate(time); +// } +// +// public static String nextNonBusinessDay(Instant time, int days) { +// return Calendars.calendar().futureNonBusinessDate(time, days); +// } +// +// public static String nextNonBusinessDay(String date) { +// return Calendars.calendar().futureNonBusinessDate(date); +// } +// +// public static String nextNonBusinessDay(String date, int days) { +// return Calendars.calendar().futureNonBusinessDate(date, days); +// } +// +// public static String[] businessDaysInRange(Instant start, Instant end) { +// return Calendars.calendar().businessDates(start, end); +// } +// +// public static String[] businessDaysInRange(String start, String end) { +// return Calendars.calendar().businessDates(start, end); +// } +// +// public static String[] nonBusinessDaysInRange(Instant start, Instant end) { +// return Calendars.calendar().nonBusinessDates(start, end); +// } +// +// public static String[] nonBusinessDaysInRange(String start, String end) { +// return Calendars.calendar().nonBusinessDates(start, end); +// } +// +// public static long standardBusinessDayLengthNanos() { +// return Calendars.calendar().standardBusinessNanos(); +// } +// +// public static long diffBusinessNanos(Instant start, Instant end) { +// return Calendars.calendar().diffBusinessNanos(start, end); +// } +// +// public static long diffNonBusinessNanos(Instant start, Instant end) { +// return Calendars.calendar().diffNonBusinessNanos(start, end); +// } +// +// public static double diffBusinessDay(Instant start, Instant end) { +// return Calendars.calendar().diffBusinessDays(start, end); +// } +// +// public static double diffNonBusinessDay(Instant start, Instant end) { +// return Calendars.calendar().diffNonBusinessDays(start, end); +// } +// +// public static double diffBusinessYear(Instant start, Instant end) { +// return Calendars.calendar().diffBusinessYears(start, end); +// } +// +// public static int numberOfBusinessDays(Instant start, Instant end) { +// return Calendars.calendar().numberOfBusinessDays(start, end); +// } +// +// public static int numberOfBusinessDays(Instant start, Instant end, boolean endInclusive) { +// return Calendars.calendar().numberBusinessDates(start, end, endInclusive); +// } +// +// public static int numberOfBusinessDays(String start, String end) { +// return Calendars.calendar().numberOfBusinessDays(start, end); +// } +// +// public static int numberOfBusinessDays(String start, String end, boolean endInclusive) { +// return Calendars.calendar().numberBusinessDates(start, end, endInclusive); +// } +// +// public static int numberOfNonBusinessDays(Instant start, Instant end) { +// return Calendars.calendar().numberOfNonBusinessDays(start, end); +// } +// +// public static int numberOfNonBusinessDays(Instant start, Instant end, boolean endInclusive) { +// return Calendars.calendar().numberNonBusinessDates(start, end, endInclusive); +// } +// +// public static int numberOfNonBusinessDays(String start, String end) { +// return Calendars.calendar().numberOfNonBusinessDays(start, end); +// } +// +// public static int numberOfNonBusinessDays(String start, String end, boolean endInclusive) { +// return Calendars.calendar().numberNonBusinessDates(start, end, endInclusive); +// } +// +// public static double fractionOfStandardBusinessDay() { +// return Calendars.calendar().fractionStandardBusinessDay(); +// } +// +// public static double fractionOfStandardBusinessDay(Instant time) { +// return Calendars.calendar().fractionStandardBusinessDay(time); +// } +// +// public static double fractionOfStandardBusinessDay(String date) { +// return Calendars.calendar().fractionStandardBusinessDay(date); +// } +// +// public static double fractionOfBusinessDayRemaining(Instant time) { +// return Calendars.calendar().fractionBusinessDayRemaining(time); +// } +// +// public static double fractionOfBusinessDayComplete(Instant time) { +// return Calendars.calendar().fractionBusinessDayComplete(time); +// } +// +// public static boolean isLastBusinessDayOfMonth() { +// return Calendars.calendar().isLastBusinessDayOfMonth(); +// } +// +// public static boolean isLastBusinessDayOfMonth(Instant time) { +// return Calendars.calendar().isLastBusinessDayOfMonth(time); +// } +// +// public static boolean isLastBusinessDayOfMonth(String date) { +// return Calendars.calendar().isLastBusinessDayOfMonth(date); +// } +// +// public static boolean isLastBusinessDayOfWeek() { +// return Calendars.calendar().isLastBusinessDayOfWeek(); +// } +// +// public static boolean isLastBusinessDayOfWeek(Instant time) { +// return Calendars.calendar().isLastBusinessDayOfWeek(time); +// } +// +// public static boolean isLastBusinessDayOfWeek(String date) { +// return Calendars.calendar().isLastBusinessDayOfWeek(date); +// } +// +// public static BusinessSchedule getBusinessSchedule(Instant time) { +// return Calendars.calendar().businessSchedule(time); +// } +// +// public static BusinessSchedule getBusinessSchedule(String date) { +// return Calendars.calendar().businessSchedule(date); +// } +// +// public static BusinessSchedule getBusinessSchedule(LocalDate date) { +// return Calendars.calendar().businessSchedule(date); +// } } diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java b/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java index a1c1979fee7..ba716e1d17c 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/StaticCalendarMethodsTest.java @@ -20,176 +20,180 @@ public class StaticCalendarMethodsTest extends BaseArrayTestCase { private final String date1 = "2017-08-01"; private final String date2 = "2017-08-05"; - public void testCalendarMethods() { - assertEquals(calendar.name(), StaticCalendarMethods.name()); - - assertEquals(calendar.currentDate(), StaticCalendarMethods.currentDay()); - - assertEquals(calendar.pastDate(), StaticCalendarMethods.previousDay()); - assertEquals(calendar.pastDate(4), StaticCalendarMethods.previousDay(4)); - assertEquals(calendar.pastDate(time1), StaticCalendarMethods.previousDay(time1)); - assertEquals(calendar.pastDate(time1, 4), StaticCalendarMethods.previousDay(time1, 4)); - assertEquals(calendar.pastDate(date1), StaticCalendarMethods.previousDay(date1)); - assertEquals(calendar.pastDate(date1, 14), StaticCalendarMethods.previousDay(date1, 14)); - - assertEquals(calendar.futureDate(), StaticCalendarMethods.nextDay()); - assertEquals(calendar.futureDate(4), StaticCalendarMethods.nextDay(4)); - assertEquals(calendar.futureDate(time2), StaticCalendarMethods.nextDay(time2)); - assertEquals(calendar.futureDate(time2, 4), StaticCalendarMethods.nextDay(time2, 4)); - assertEquals(calendar.futureDate(date2), StaticCalendarMethods.nextDay(date2)); - assertEquals(calendar.futureDate(date2, 14), StaticCalendarMethods.nextDay(date2, 14)); - - assertEquals(calendar.calendarDates(time1, time2), StaticCalendarMethods.daysInRange(time1, time2)); - assertEquals(calendar.calendarDates(date1, date2), StaticCalendarMethods.daysInRange(date1, date2)); - - assertEquals(calendar.numberCalendarDates(time1, time2), StaticCalendarMethods.numberOfDays(time1, time2)); - assertEquals(calendar.numberCalendarDates(time1, time2, true), StaticCalendarMethods.numberOfDays(time1, time2, true)); - assertEquals(calendar.numberCalendarDates(date1, date2), StaticCalendarMethods.numberOfDays(date1, date2)); - assertEquals(calendar.numberCalendarDates(date1, date2, true), StaticCalendarMethods.numberOfDays(date1, date2, true)); - - - assertEquals(calendar.dayOfWeek(), StaticCalendarMethods.dayOfWeek()); - assertEquals(calendar.dayOfWeek(time2), StaticCalendarMethods.dayOfWeek(time2)); - assertEquals(calendar.dayOfWeek(date2), StaticCalendarMethods.dayOfWeek(date2)); - - assertEquals(calendar.timeZone(), StaticCalendarMethods.calendarTimeZone()); + public void testFail() { + fail("implement"); } - public void testBusinessCalendarMethods() { - assertEquals(calendar.isBusinessDay(), StaticCalendarMethods.isBusinessDay()); - assertEquals(calendar.isBusinessDay(time2), StaticCalendarMethods.isBusinessDay(time2)); - assertEquals(calendar.isBusinessDay(date2), StaticCalendarMethods.isBusinessDay(date2)); - - - assertEquals(calendar.isBusinessDay(), StaticCalendarMethods.isBusinessDay()); - assertEquals(calendar.isBusinessDay(time1), StaticCalendarMethods.isBusinessDay(time1)); - assertEquals(calendar.isBusinessDay(date1), StaticCalendarMethods.isBusinessDay(date1)); - assertEquals(calendar.isBusinessDay(LocalDate.now()), StaticCalendarMethods.isBusinessDay(LocalDate.now())); - - - assertEquals(calendar.isBusinessTime(time1), StaticCalendarMethods.isBusinessTime(time1)); - assertEquals(calendar.isBusinessTime(time2), StaticCalendarMethods.isBusinessTime(time2)); - - - assertEquals(calendar.pastBusinessDate(), StaticCalendarMethods.previousBusinessDay()); - assertEquals(calendar.pastBusinessDate(12), StaticCalendarMethods.previousBusinessDay(12)); - assertEquals(calendar.pastBusinessDate(time1), StaticCalendarMethods.previousBusinessDay(time1)); - assertEquals(calendar.pastBusinessDate(time1, 6), StaticCalendarMethods.previousBusinessDay(time1, 6)); - assertEquals(calendar.pastBusinessDate(date1), StaticCalendarMethods.previousBusinessDay(date1)); - assertEquals(calendar.pastBusinessDate(date1, 16), StaticCalendarMethods.previousBusinessDay(date1, 16)); - - - assertEquals(calendar.previousBusinessSchedule(), StaticCalendarMethods.previousBusinessSchedule()); - assertEquals(calendar.previousBusinessSchedule(12), StaticCalendarMethods.previousBusinessSchedule(12)); - assertEquals(calendar.previousBusinessSchedule(time1), StaticCalendarMethods.previousBusinessSchedule(time1)); - assertEquals(calendar.previousBusinessSchedule(time1, 6), - StaticCalendarMethods.previousBusinessSchedule(time1, 6)); - assertEquals(calendar.previousBusinessSchedule(date1), StaticCalendarMethods.previousBusinessSchedule(date1)); - assertEquals(calendar.previousBusinessSchedule(date1, 16), - StaticCalendarMethods.previousBusinessSchedule(date1, 16)); - - - assertEquals(calendar.pastNonBusinessDate(), StaticCalendarMethods.previousNonBusinessDay()); - assertEquals(calendar.pastNonBusinessDate(12), StaticCalendarMethods.previousNonBusinessDay(12)); - assertEquals(calendar.pastNonBusinessDate(time1), StaticCalendarMethods.previousNonBusinessDay(time1)); - assertEquals(calendar.pastNonBusinessDate(time1, 6), StaticCalendarMethods.previousNonBusinessDay(time1, 6)); - assertEquals(calendar.pastNonBusinessDate(date1), StaticCalendarMethods.previousNonBusinessDay(date1)); - assertEquals(calendar.pastNonBusinessDate(date1, 16), - StaticCalendarMethods.previousNonBusinessDay(date1, 16)); - - - assertEquals(calendar.futureBusinessDate(), StaticCalendarMethods.nextBusinessDay()); - assertEquals(calendar.futureBusinessDate(12), StaticCalendarMethods.nextBusinessDay(12)); - assertEquals(calendar.futureBusinessDate(time1), StaticCalendarMethods.nextBusinessDay(time1)); - assertEquals(calendar.futureBusinessDate(time1, 6), StaticCalendarMethods.nextBusinessDay(time1, 6)); - assertEquals(calendar.futureBusinessDate(date1), StaticCalendarMethods.nextBusinessDay(date1)); - assertEquals(calendar.futureBusinessDate(date1, 16), StaticCalendarMethods.nextBusinessDay(date1, 16)); - - - assertEquals(calendar.nextBusinessSchedule(), StaticCalendarMethods.nextBusinessSchedule()); - assertEquals(calendar.nextBusinessSchedule(12), StaticCalendarMethods.nextBusinessSchedule(12)); - assertEquals(calendar.nextBusinessSchedule(time1), StaticCalendarMethods.nextBusinessSchedule(time1)); - assertEquals(calendar.nextBusinessSchedule(time1, 6), StaticCalendarMethods.nextBusinessSchedule(time1, 6)); - assertEquals(calendar.nextBusinessSchedule(date1), StaticCalendarMethods.nextBusinessSchedule(date1)); - assertEquals(calendar.nextBusinessSchedule(date1, 16), StaticCalendarMethods.nextBusinessSchedule(date1, 16)); - - - assertEquals(calendar.futureNonBusinessDate(), StaticCalendarMethods.nextNonBusinessDay()); - assertEquals(calendar.futureNonBusinessDate(12), StaticCalendarMethods.nextNonBusinessDay(12)); - assertEquals(calendar.futureNonBusinessDate(time1), StaticCalendarMethods.nextNonBusinessDay(time1)); - assertEquals(calendar.futureNonBusinessDate(time1, 6), StaticCalendarMethods.nextNonBusinessDay(time1, 6)); - assertEquals(calendar.futureNonBusinessDate(date1), StaticCalendarMethods.nextNonBusinessDay(date1)); - assertEquals(calendar.futureNonBusinessDate(date1, 16), StaticCalendarMethods.nextNonBusinessDay(date1, 16)); - - - assertEquals(calendar.businessDates(time1, time2), - StaticCalendarMethods.businessDaysInRange(time1, time2)); - assertEquals(calendar.businessDates(date1, date2), - StaticCalendarMethods.businessDaysInRange(date1, date2)); - - - assertEquals(calendar.nonBusinessDates(time1, time2), - StaticCalendarMethods.nonBusinessDaysInRange(time1, time2)); - assertEquals(calendar.nonBusinessDates(date1, date2), - StaticCalendarMethods.nonBusinessDaysInRange(date1, date2)); - - - assertEquals(calendar.standardBusinessDayLengthNanos(), StaticCalendarMethods.standardBusinessDayLengthNanos()); - - - assertEquals(calendar.diffBusinessNanos(time1, time2), StaticCalendarMethods.diffBusinessNanos(time1, time2)); - assertEquals(calendar.diffNonBusinessNanos(time1, time2), - StaticCalendarMethods.diffNonBusinessNanos(time1, time2)); - assertEquals(calendar.diffBusinessDays(time1, time2), StaticCalendarMethods.diffBusinessDay(time1, time2)); - assertEquals(calendar.diffNonBusinessDays(time1, time2), StaticCalendarMethods.diffNonBusinessDay(time1, time2)); - assertEquals(calendar.diffBusinessYears(time1, time2), StaticCalendarMethods.diffBusinessYear(time1, time2)); - - - assertEquals(calendar.numberOfBusinessDays(time1, time2), - StaticCalendarMethods.numberOfBusinessDays(time1, time2)); - assertEquals(calendar.numberBusinessDates(time1, time2, true), - StaticCalendarMethods.numberOfBusinessDays(time1, time2, true)); - assertEquals(calendar.numberOfBusinessDays(date1, date2), - StaticCalendarMethods.numberOfBusinessDays(date1, date2)); - assertEquals(calendar.numberBusinessDates(date1, date2, true), - StaticCalendarMethods.numberOfBusinessDays(date1, date2, true)); - - - assertEquals(calendar.numberOfNonBusinessDays(time1, time2), - StaticCalendarMethods.numberOfNonBusinessDays(time1, time2)); - assertEquals(calendar.numberNonBusinessDates(time1, time2, true), - StaticCalendarMethods.numberOfNonBusinessDays(time1, time2, true)); - assertEquals(calendar.numberOfNonBusinessDays(date1, date2), - StaticCalendarMethods.numberOfNonBusinessDays(date1, date2)); - assertEquals(calendar.numberNonBusinessDates(date1, date2, true), - StaticCalendarMethods.numberOfNonBusinessDays(date1, date2, true)); - - - assertEquals(calendar.fractionOfStandardBusinessDay(), StaticCalendarMethods.fractionOfStandardBusinessDay()); - assertEquals(calendar.fractionOfStandardBusinessDay(time1), - StaticCalendarMethods.fractionOfStandardBusinessDay(time1)); - assertEquals(calendar.fractionOfStandardBusinessDay(date1), - StaticCalendarMethods.fractionOfStandardBusinessDay(date1)); - - - assertEquals(calendar.fractionOfBusinessDayRemaining(time1), - StaticCalendarMethods.fractionOfBusinessDayRemaining(time1)); - assertEquals(calendar.fractionOfBusinessDayComplete(time1), - StaticCalendarMethods.fractionOfBusinessDayComplete(time1)); - - - assertEquals(calendar.isLastBusinessDayOfMonth(), StaticCalendarMethods.isLastBusinessDayOfMonth()); - assertEquals(calendar.isLastBusinessDayOfMonth(time1), StaticCalendarMethods.isLastBusinessDayOfMonth(time1)); - assertEquals(calendar.isLastBusinessDayOfMonth(date1), StaticCalendarMethods.isLastBusinessDayOfMonth(date1)); - - - assertEquals(calendar.isLastBusinessDayOfWeek(), StaticCalendarMethods.isLastBusinessDayOfWeek()); - assertEquals(calendar.isLastBusinessDayOfWeek(time1), StaticCalendarMethods.isLastBusinessDayOfWeek(time1)); - assertEquals(calendar.isLastBusinessDayOfWeek(date1), StaticCalendarMethods.isLastBusinessDayOfWeek(date1)); - - assertEquals(calendar.businessSchedule(time1), StaticCalendarMethods.getBusinessSchedule(time1)); - assertEquals(calendar.businessSchedule(date1), StaticCalendarMethods.getBusinessSchedule(date1)); - assertEquals(calendar.businessSchedule(LocalDate.now()), - StaticCalendarMethods.getBusinessSchedule(LocalDate.now())); - } +// public void testCalendarMethods() { +// assertEquals(calendar.name(), StaticCalendarMethods.name()); +// +// assertEquals(calendar.currentDate(), StaticCalendarMethods.currentDay()); +// +// assertEquals(calendar.pastDate(), StaticCalendarMethods.previousDay()); +// assertEquals(calendar.pastDate(4), StaticCalendarMethods.previousDay(4)); +// assertEquals(calendar.pastDate(time1), StaticCalendarMethods.previousDay(time1)); +// assertEquals(calendar.pastDate(time1, 4), StaticCalendarMethods.previousDay(time1, 4)); +// assertEquals(calendar.pastDate(date1), StaticCalendarMethods.previousDay(date1)); +// assertEquals(calendar.pastDate(date1, 14), StaticCalendarMethods.previousDay(date1, 14)); +// +// assertEquals(calendar.futureDate(), StaticCalendarMethods.nextDay()); +// assertEquals(calendar.futureDate(4), StaticCalendarMethods.nextDay(4)); +// assertEquals(calendar.futureDate(time2), StaticCalendarMethods.nextDay(time2)); +// assertEquals(calendar.futureDate(time2, 4), StaticCalendarMethods.nextDay(time2, 4)); +// assertEquals(calendar.futureDate(date2), StaticCalendarMethods.nextDay(date2)); +// assertEquals(calendar.futureDate(date2, 14), StaticCalendarMethods.nextDay(date2, 14)); +// +// assertEquals(calendar.calendarDates(time1, time2), StaticCalendarMethods.daysInRange(time1, time2)); +// assertEquals(calendar.calendarDates(date1, date2), StaticCalendarMethods.daysInRange(date1, date2)); +// +// assertEquals(calendar.numberCalendarDates(time1, time2), StaticCalendarMethods.numberOfDays(time1, time2)); +// assertEquals(calendar.numberCalendarDates(time1, time2, true), StaticCalendarMethods.numberOfDays(time1, time2, true)); +// assertEquals(calendar.numberCalendarDates(date1, date2), StaticCalendarMethods.numberOfDays(date1, date2)); +// assertEquals(calendar.numberCalendarDates(date1, date2, true), StaticCalendarMethods.numberOfDays(date1, date2, true)); +// +// +// assertEquals(calendar.dayOfWeek(), StaticCalendarMethods.dayOfWeek()); +// assertEquals(calendar.dayOfWeek(time2), StaticCalendarMethods.dayOfWeek(time2)); +// assertEquals(calendar.dayOfWeek(date2), StaticCalendarMethods.dayOfWeek(date2)); +// +// assertEquals(calendar.timeZone(), StaticCalendarMethods.calendarTimeZone()); +// } +// +// public void testBusinessCalendarMethods() { +// assertEquals(calendar.isBusinessDay(), StaticCalendarMethods.isBusinessDay()); +// assertEquals(calendar.isBusinessDay(time2), StaticCalendarMethods.isBusinessDay(time2)); +// assertEquals(calendar.isBusinessDay(date2), StaticCalendarMethods.isBusinessDay(date2)); +// +// +// assertEquals(calendar.isBusinessDay(), StaticCalendarMethods.isBusinessDay()); +// assertEquals(calendar.isBusinessDay(time1), StaticCalendarMethods.isBusinessDay(time1)); +// assertEquals(calendar.isBusinessDay(date1), StaticCalendarMethods.isBusinessDay(date1)); +// assertEquals(calendar.isBusinessDay(LocalDate.now()), StaticCalendarMethods.isBusinessDay(LocalDate.now())); +// +// +// assertEquals(calendar.isBusinessTime(time1), StaticCalendarMethods.isBusinessTime(time1)); +// assertEquals(calendar.isBusinessTime(time2), StaticCalendarMethods.isBusinessTime(time2)); +// +// +// assertEquals(calendar.pastBusinessDate(), StaticCalendarMethods.previousBusinessDay()); +// assertEquals(calendar.pastBusinessDate(12), StaticCalendarMethods.previousBusinessDay(12)); +// assertEquals(calendar.pastBusinessDate(time1), StaticCalendarMethods.previousBusinessDay(time1)); +// assertEquals(calendar.pastBusinessDate(time1, 6), StaticCalendarMethods.previousBusinessDay(time1, 6)); +// assertEquals(calendar.pastBusinessDate(date1), StaticCalendarMethods.previousBusinessDay(date1)); +// assertEquals(calendar.pastBusinessDate(date1, 16), StaticCalendarMethods.previousBusinessDay(date1, 16)); +// +// +// assertEquals(calendar.previousBusinessSchedule(), StaticCalendarMethods.previousBusinessSchedule()); +// assertEquals(calendar.previousBusinessSchedule(12), StaticCalendarMethods.previousBusinessSchedule(12)); +// assertEquals(calendar.previousBusinessSchedule(time1), StaticCalendarMethods.previousBusinessSchedule(time1)); +// assertEquals(calendar.previousBusinessSchedule(time1, 6), +// StaticCalendarMethods.previousBusinessSchedule(time1, 6)); +// assertEquals(calendar.previousBusinessSchedule(date1), StaticCalendarMethods.previousBusinessSchedule(date1)); +// assertEquals(calendar.previousBusinessSchedule(date1, 16), +// StaticCalendarMethods.previousBusinessSchedule(date1, 16)); +// +// +// assertEquals(calendar.pastNonBusinessDate(), StaticCalendarMethods.previousNonBusinessDay()); +// assertEquals(calendar.pastNonBusinessDate(12), StaticCalendarMethods.previousNonBusinessDay(12)); +// assertEquals(calendar.pastNonBusinessDate(time1), StaticCalendarMethods.previousNonBusinessDay(time1)); +// assertEquals(calendar.pastNonBusinessDate(time1, 6), StaticCalendarMethods.previousNonBusinessDay(time1, 6)); +// assertEquals(calendar.pastNonBusinessDate(date1), StaticCalendarMethods.previousNonBusinessDay(date1)); +// assertEquals(calendar.pastNonBusinessDate(date1, 16), +// StaticCalendarMethods.previousNonBusinessDay(date1, 16)); +// +// +// assertEquals(calendar.futureBusinessDate(), StaticCalendarMethods.nextBusinessDay()); +// assertEquals(calendar.futureBusinessDate(12), StaticCalendarMethods.nextBusinessDay(12)); +// assertEquals(calendar.futureBusinessDate(time1), StaticCalendarMethods.nextBusinessDay(time1)); +// assertEquals(calendar.futureBusinessDate(time1, 6), StaticCalendarMethods.nextBusinessDay(time1, 6)); +// assertEquals(calendar.futureBusinessDate(date1), StaticCalendarMethods.nextBusinessDay(date1)); +// assertEquals(calendar.futureBusinessDate(date1, 16), StaticCalendarMethods.nextBusinessDay(date1, 16)); +// +// +// assertEquals(calendar.nextBusinessSchedule(), StaticCalendarMethods.nextBusinessSchedule()); +// assertEquals(calendar.nextBusinessSchedule(12), StaticCalendarMethods.nextBusinessSchedule(12)); +// assertEquals(calendar.nextBusinessSchedule(time1), StaticCalendarMethods.nextBusinessSchedule(time1)); +// assertEquals(calendar.nextBusinessSchedule(time1, 6), StaticCalendarMethods.nextBusinessSchedule(time1, 6)); +// assertEquals(calendar.nextBusinessSchedule(date1), StaticCalendarMethods.nextBusinessSchedule(date1)); +// assertEquals(calendar.nextBusinessSchedule(date1, 16), StaticCalendarMethods.nextBusinessSchedule(date1, 16)); +// +// +// assertEquals(calendar.futureNonBusinessDate(), StaticCalendarMethods.nextNonBusinessDay()); +// assertEquals(calendar.futureNonBusinessDate(12), StaticCalendarMethods.nextNonBusinessDay(12)); +// assertEquals(calendar.futureNonBusinessDate(time1), StaticCalendarMethods.nextNonBusinessDay(time1)); +// assertEquals(calendar.futureNonBusinessDate(time1, 6), StaticCalendarMethods.nextNonBusinessDay(time1, 6)); +// assertEquals(calendar.futureNonBusinessDate(date1), StaticCalendarMethods.nextNonBusinessDay(date1)); +// assertEquals(calendar.futureNonBusinessDate(date1, 16), StaticCalendarMethods.nextNonBusinessDay(date1, 16)); +// +// +// assertEquals(calendar.businessDates(time1, time2), +// StaticCalendarMethods.businessDaysInRange(time1, time2)); +// assertEquals(calendar.businessDates(date1, date2), +// StaticCalendarMethods.businessDaysInRange(date1, date2)); +// +// +// assertEquals(calendar.nonBusinessDates(time1, time2), +// StaticCalendarMethods.nonBusinessDaysInRange(time1, time2)); +// assertEquals(calendar.nonBusinessDates(date1, date2), +// StaticCalendarMethods.nonBusinessDaysInRange(date1, date2)); +// +// +// assertEquals(calendar.standardBusinessNanos(), StaticCalendarMethods.standardBusinessDayLengthNanos()); +// +// +// assertEquals(calendar.diffBusinessNanos(time1, time2), StaticCalendarMethods.diffBusinessNanos(time1, time2)); +// assertEquals(calendar.diffNonBusinessNanos(time1, time2), +// StaticCalendarMethods.diffNonBusinessNanos(time1, time2)); +// assertEquals(calendar.diffBusinessDays(time1, time2), StaticCalendarMethods.diffBusinessDay(time1, time2)); +// assertEquals(calendar.diffNonBusinessDays(time1, time2), StaticCalendarMethods.diffNonBusinessDay(time1, time2)); +// assertEquals(calendar.diffBusinessYears(time1, time2), StaticCalendarMethods.diffBusinessYear(time1, time2)); +// +// +// assertEquals(calendar.numberOfBusinessDays(time1, time2), +// StaticCalendarMethods.numberOfBusinessDays(time1, time2)); +// assertEquals(calendar.numberBusinessDates(time1, time2, true), +// StaticCalendarMethods.numberOfBusinessDays(time1, time2, true)); +// assertEquals(calendar.numberOfBusinessDays(date1, date2), +// StaticCalendarMethods.numberOfBusinessDays(date1, date2)); +// assertEquals(calendar.numberBusinessDates(date1, date2, true), +// StaticCalendarMethods.numberOfBusinessDays(date1, date2, true)); +// +// +// assertEquals(calendar.numberOfNonBusinessDays(time1, time2), +// StaticCalendarMethods.numberOfNonBusinessDays(time1, time2)); +// assertEquals(calendar.numberNonBusinessDates(time1, time2, true), +// StaticCalendarMethods.numberOfNonBusinessDays(time1, time2, true)); +// assertEquals(calendar.numberOfNonBusinessDays(date1, date2), +// StaticCalendarMethods.numberOfNonBusinessDays(date1, date2)); +// assertEquals(calendar.numberNonBusinessDates(date1, date2, true), +// StaticCalendarMethods.numberOfNonBusinessDays(date1, date2, true)); +// +// +// assertEquals(calendar.fractionStandardBusinessDay(), StaticCalendarMethods.fractionOfStandardBusinessDay()); +// assertEquals(calendar.fractionStandardBusinessDay(time1), +// StaticCalendarMethods.fractionOfStandardBusinessDay(time1)); +// assertEquals(calendar.fractionStandardBusinessDay(date1), +// StaticCalendarMethods.fractionOfStandardBusinessDay(date1)); +// +// +// assertEquals(calendar.fractionBusinessDayRemaining(time1), +// StaticCalendarMethods.fractionOfBusinessDayRemaining(time1)); +// assertEquals(calendar.fractionBusinessDayComplete(time1), +// StaticCalendarMethods.fractionOfBusinessDayComplete(time1)); +// +// +// assertEquals(calendar.isLastBusinessDayOfMonth(), StaticCalendarMethods.isLastBusinessDayOfMonth()); +// assertEquals(calendar.isLastBusinessDayOfMonth(time1), StaticCalendarMethods.isLastBusinessDayOfMonth(time1)); +// assertEquals(calendar.isLastBusinessDayOfMonth(date1), StaticCalendarMethods.isLastBusinessDayOfMonth(date1)); +// +// +// assertEquals(calendar.isLastBusinessDayOfWeek(), StaticCalendarMethods.isLastBusinessDayOfWeek()); +// assertEquals(calendar.isLastBusinessDayOfWeek(time1), StaticCalendarMethods.isLastBusinessDayOfWeek(time1)); +// assertEquals(calendar.isLastBusinessDayOfWeek(date1), StaticCalendarMethods.isLastBusinessDayOfWeek(date1)); +// +// assertEquals(calendar.businessSchedule(time1), StaticCalendarMethods.getBusinessSchedule(time1)); +// assertEquals(calendar.businessSchedule(date1), StaticCalendarMethods.getBusinessSchedule(date1)); +// assertEquals(calendar.businessSchedule(LocalDate.now()), +// StaticCalendarMethods.getBusinessSchedule(LocalDate.now())); +// } } diff --git a/py/server/deephaven/calendar.py b/py/server/deephaven/calendar.py index a7380006481..aa73e0e2e6d 100644 --- a/py/server/deephaven/calendar.py +++ b/py/server/deephaven/calendar.py @@ -5,7 +5,7 @@ """ This module provides a collection of business calendars and convenient calendar functions. """ from enum import Enum -from typing import List +from typing import Optional, Union, List import jpy @@ -21,6 +21,7 @@ _JBusinessSchedule = jpy.get_type("io.deephaven.time.calendar.BusinessSchedule") _JBusinessCalendar = jpy.get_type("io.deephaven.time.calendar.BusinessCalendar") +#TODO: all inputs as Instants as well def calendar_names() -> List[str]: """ Returns the names of all available calendars. @@ -171,6 +172,25 @@ class Calendar(JObjectWrapper): def j_object(self) -> jpy.JType: return self.j_calendar + #TODO: ??? + @property + def today(self) -> str: + """ Today. """ + return self.j_calendar.currentDay() + + #TODO: ??? + @property + def tomorrow(self) -> str: + """ Tomorrow. """ + return self.j_calendar.currentDay(***) + + #TODO: ??? + @property + def yesterday(self) -> str: + """ Yesterday. """ + return self.j_calendar.previousDay(***) + + #TODO: deprecate??? @property def current_day(self) -> str: """ The current day. """ @@ -181,11 +201,12 @@ def time_zone(self) -> TimeZone: """ Returns the timezone of the calendar. """ return self.j_calendar.timeZone() - def previous_day(self, date: str) -> str: - """ Gets the day prior to the given date. + def previous_day(self, date: Union[str,Instant,None]=None, days: int=1) -> str: + """ Gets a day prior to the given date. Args: - date (str): the date of interest + date (Union[str,Instant,None]): the date of interest. Defaults to the current date. + days (int): number of days prior. Defaults to 1. Returns: str @@ -194,15 +215,19 @@ def previous_day(self, date: str) -> str: DHError """ try: - return self.j_calendar.previousDay(date) + if date: + return self.j_calendar.previousDay(date, days) + else: + return self.j_calendar.previousDay(days) except Exception as e: raise DHError(e, "failed in previous_day.") from e - def next_day(self, date: str) -> str: - """ Gets the day after the given date. + def next_day(self, date: Union[str,Instant,None]=None, days: int=1) -> str: + """ Gets a day after the given date. Args: - date (str): the date of interest + date (Union[str,Instant,None]): the date of interest. Defaults to the current date. + days (int): number of days later. Defaults to 1. Returns: str @@ -211,15 +236,18 @@ def next_day(self, date: str) -> str: DHError """ try: - return self.j_calendar.nextDay(date) + if date: + return self.j_calendar.nextDay(date, days) + else: + return self.j_calendar.nextDay(days) except Exception as e: raise DHError(e, "failed in next_day.") from e - def day_of_week(self, date: str) -> DayOfWeek: + def day_of_week(self, date: Union[str,Instant,None]) -> DayOfWeek: """ The day of week for the given date. Args: - date (str): the date of interest + date (Union[str,Instant,None]): the date of interest. Defaults to the current date. Returns: str @@ -228,16 +256,19 @@ def day_of_week(self, date: str) -> DayOfWeek: DHError """ try: - return DayOfWeek(self.j_calendar.dayOfWeek(date)) + if date: + return DayOfWeek(self.j_calendar.dayOfWeek(date)) + else: + return DayOfWeek(self.j_calendar.dayOfWeek()) except Exception as e: raise DHError(e, "failed in day_of_week.") from e - def days_in_range(self, start: str, end: str) -> List[str]: + def days_in_range(self, start: Union[str,Instant], end: Union[str,Instant]) -> List[str]: """ Returns the days between the specified start and end dates. Args: - start (str): the start day of the range - end (str): the end day of the range + start (Union[str,Instant]): the start day of the range + end (Union[str,Instant]): the end day of the range Returns: List[str]: a list of dates @@ -251,12 +282,12 @@ def days_in_range(self, start: str, end: str) -> List[str]: except Exception as e: raise DHError(e, "failed in days_in_range.") from e - def number_of_days(self, start: str, end: str, end_inclusive: bool = False) -> int: + def number_of_days(self, start: Union[str,Instant], end: Union[str,Instant], end_inclusive: bool = False) -> int: """ Returns the number of days between the start and end dates. Args: - start (str): the start day of the range - end (str): the end day of the range + start (Union[str,Instant]): the start day of the range + end (Union[str,Instant]): the end day of the range end_inclusive (bool): whether to include the end date, default is False Returns: @@ -330,6 +361,7 @@ def business_schedule(self, date: str) -> BusinessSchedule: except Exception as e: raise DHError(e, "failed in get_business_schedule.") from e + #TODO: optional def previous_business_day(self, date: str) -> str: """ Gets the business day prior to the given date. @@ -347,6 +379,7 @@ def previous_business_day(self, date: str) -> str: except Exception as e: raise DHError(e, "failed in previous_business_day.") from e + #TODO: optional def previous_non_business_day(self, date: str) -> str: """ Gets the non-business day prior to the given date. @@ -364,6 +397,7 @@ def previous_non_business_day(self, date: str) -> str: except Exception as e: raise DHError(e, "failed in previous_non_business_day.") from e + #TODO: optional def next_business_day(self, date: str) -> str: """ Gets the business day after the given date. @@ -381,6 +415,7 @@ def next_business_day(self, date: str) -> str: except Exception as e: raise DHError(e, "failed in next_business_day.") from e + #TODO: optional def next_non_business_day(self, date: str) -> str: """ Gets the non-business day after the given date. diff --git a/py/server/deephaven/time.py b/py/server/deephaven/time.py index 20262f4d295..b731d4c0933 100644 --- a/py/server/deephaven/time.py +++ b/py/server/deephaven/time.py @@ -1505,12 +1505,13 @@ def hour_of_day(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> int: raise DHError(e) from e -def day_of_week(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> int: +#TODO: *** localdate with tz +def day_of_week(dt: Union[LocalDate, Instant, ZonedDateTime], tz: TimeZone) -> int: """ Returns a 1-based int value of the day of the week for a date time in the specified time zone, with 1 being Monday and 7 being Sunday. Args: - dt (Union[Instant,ZonedDateTime]): Date time. + dt (Union[LocalDate,Instant,ZonedDateTime]): Date time. tz (TimeZone): Time zone. Returns: @@ -1531,12 +1532,13 @@ def day_of_week(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> int: raise DHError(e) from e -def day_of_month(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> int: +#TODO: *** localdate with tz +def day_of_month(dt: Union[LocalDate, Instant, ZonedDateTime], tz: TimeZone) -> int: """ Returns a 1-based int value of the day of the month for a date time and specified time zone. The first day of the month returns 1, the second day returns 2, etc. Args: - dt (Union[Instant,ZonedDateTime]): Date time. + dt (Union[LocalDate,Instant,ZonedDateTime]): Date time. tz (TimeZone): Time zone. Returns: @@ -1557,12 +1559,13 @@ def day_of_month(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> int: raise DHError(e) from e -def day_of_year(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> int: +#TODO: *** localdate with tz +def day_of_year(dt: Union[LocalDate, Instant, ZonedDateTime], tz: TimeZone) -> int: """ Returns a 1-based int value of the day of the year (Julian date) for a date time in the specified time zone. The first day of the year returns 1, the second day returns 2, etc. Args: - dt (Union[Instant,ZonedDateTime]): Date time. + dt (Union[LocalDate,Instant,ZonedDateTime]): Date time. tz (TimeZone): Time zone. Returns: @@ -1583,12 +1586,13 @@ def day_of_year(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> int: raise DHError(e) from e -def month_of_year(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> int: +#TODO: *** localdate with tz +def month_of_year(dt: Union[LocalDate, Instant, ZonedDateTime], tz: TimeZone) -> int: """ Returns a 1-based int value of the month of the year (Julian date) for a date time in the specified time zone. January is 1, February is 2, etc. Args: - dt (Union[Instant,ZonedDateTime]): Date time. + dt (Union[LocalDate,Instant,ZonedDateTime]): Date time. tz (TimeZone): Time zone. Returns: @@ -1609,11 +1613,12 @@ def month_of_year(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> int: raise DHError(e) from e -def year(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> int: +#TODO: *** localdate with tz +def year(dt: Union[LocalDate, Instant, ZonedDateTime], tz: TimeZone) -> int: """ Returns the year for a date time in the specified time zone. Args: - dt (Union[Instant,ZonedDateTime]): Date time. + dt (Union[LocalDate,Instant,ZonedDateTime]): Date time. tz (TimeZone): Time zone. Returns: @@ -1634,11 +1639,12 @@ def year(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> int: raise DHError(e) from e -def year_of_century(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> int: +#TODO: *** localdate with tz +def year_of_century(dt: Union[LocalDate, Instant, ZonedDateTime], tz: TimeZone) -> int: """ Returns the year of the century (two-digit year) for a date time in the specified time zone. Args: - dt (Union[Instant,ZonedDateTime]): Date time. + dt (Union[LocalDate,Instant,ZonedDateTime]): Date time. tz (TimeZone): Time zone. Returns: @@ -1659,11 +1665,12 @@ def year_of_century(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> int: raise DHError(e) from e -def at_midnight(dt: Union[Instant, ZonedDateTime], tz: TimeZone) -> Union[Instant, ZonedDateTime]: +#TODO: *** localdate with tz +def at_midnight(dt: Union[LocalDate, Instant, ZonedDateTime], tz: TimeZone) -> Union[Instant, ZonedDateTime]: """ Returns a date time for the prior midnight in the specified time zone. Args: - dt (Union[Instant,ZonedDateTime]): Date time. + dt (Union[LocalDate,Instant,ZonedDateTime]): Date time. tz (TimeZone): Time zone. Returns: From fdaef8d153baeeb392fa15cbe99ef365ad99a972 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 18 Jul 2023 14:16:37 -0600 Subject: [PATCH 046/150] Committing to rebase --- .../io/deephaven/time/calendar/Calendars.java | 202 ++--- .../time/calendar/TestCalendars.java | 117 +-- .../main/resources/calendar/BEIJING.calendar | 15 - .../src/main/resources/calendar/CAL1.calendar | 178 ++++ .../src/main/resources/calendar/CAL2.calendar | 178 ++++ .../src/main/resources/calendar/DTB.calendar | 175 ---- .../src/main/resources/calendar/GBLO.calendar | 355 -------- .../main/resources/calendar/GLOBAL.calendar | 31 - .../main/resources/calendar/JPOSE.calendar | 492 ---------- .../src/main/resources/calendar/LSE.calendar | 217 ----- .../main/resources/calendar/MOSCOW.calendar | 839 ----------------- .../main/resources/calendar/MUMBAI.calendar | 370 -------- .../src/main/resources/calendar/USNY.calendar | 547 ----------- .../main/resources/calendar/USNYSE.calendar | 856 ------------------ .../calendar/USNYSEWEEKDAYS.calendar | 15 - .../src/main/resources/dh-tests.prop | 2 +- .../main/resources/test_calendar_imports.txt | 14 +- 17 files changed, 456 insertions(+), 4147 deletions(-) delete mode 100644 props/test-configs/src/main/resources/calendar/BEIJING.calendar create mode 100644 props/test-configs/src/main/resources/calendar/CAL1.calendar create mode 100644 props/test-configs/src/main/resources/calendar/CAL2.calendar delete mode 100644 props/test-configs/src/main/resources/calendar/DTB.calendar delete mode 100644 props/test-configs/src/main/resources/calendar/GBLO.calendar delete mode 100644 props/test-configs/src/main/resources/calendar/GLOBAL.calendar delete mode 100644 props/test-configs/src/main/resources/calendar/JPOSE.calendar delete mode 100644 props/test-configs/src/main/resources/calendar/LSE.calendar delete mode 100644 props/test-configs/src/main/resources/calendar/MOSCOW.calendar delete mode 100644 props/test-configs/src/main/resources/calendar/MUMBAI.calendar delete mode 100644 props/test-configs/src/main/resources/calendar/USNY.calendar delete mode 100644 props/test-configs/src/main/resources/calendar/USNYSE.calendar delete mode 100644 props/test-configs/src/main/resources/calendar/USNYSEWEEKDAYS.calendar diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java index 09852f65fd3..9567d4b1e5e 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java @@ -13,78 +13,31 @@ import java.io.*; import java.nio.file.NoSuchFileException; -import java.util.Collection; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import java.util.Set; import java.util.function.Consumer; /** * A collection of business calendars. */ -public class Calendars implements Map { +public class Calendars { private static final Logger logger = LoggerFactory.getLogger(Calendars.class); private static final String BUSINESS_CALENDAR_PROP_INTERNAL = "Calendar.importPath"; private static final String BUSINESS_CALENDAR_PROP_USER = "Calendar.userImportPath"; - private static final Calendars instance = new Calendars(); - private static final String defaultName = Configuration.getInstance().getProperty("Calendar.default"); + private static String defaultName = Configuration.getInstance().getProperty("Calendar.default"); - /** - * Gets the singleton map of business calendars. - * - * @return singleton map of calendars - */ - static Calendars getInstance() { - return instance; - } - - /** - * Returns a business calendar. - * - * @param name name of the calendar - * @return business calendar - * @throws IllegalArgumentException no calendar matching {@code name} - * @throws RequirementFailure if the input is null - */ - public static BusinessCalendar calendar(final String name) { - Require.neqNull(name, "name"); - - final String n = name.toUpperCase(); - - if (!instance.containsKey(n)) { - throw new IllegalArgumentException("No such calendar: " + name); - } - - return instance.get(n); - } - - /** - * Returns the default business calendar. - * - * @return default business calendar. The default is specified by the {@code Calendar.default} property. - */ - public static BusinessCalendar calendar() { - return calendar(defaultName); - } + private static final Map map = new HashMap<>(); + private static String[] names = new String[0]; - /** - * Returns the names of all available calendars - * - * @return names of all available calendars - */ - public static String[] calendarNames() { - return instance.keySet().toArray(String[]::new); - } + private Calendars() {} + // region Load - private final Map calendars = new HashMap<>(); - - - private Calendars() { + static { final Configuration configuration = Configuration.getInstance(); - loadProperty(configuration, BUSINESS_CALENDAR_PROP_INTERNAL); if (configuration.hasProperty(BUSINESS_CALENDAR_PROP_USER)) { @@ -92,7 +45,7 @@ private Calendars() { } } - private void loadProperty(final Configuration configuration, final String property) { + private static void loadProperty(final Configuration configuration, final String property) { final String location = configuration.getProperty(property); try { load(location); @@ -101,9 +54,8 @@ private void loadProperty(final Configuration configuration, final String proper } } - private void load(final String businessCalendarConfig) - throws NoSuchFileException { - final InputStream configToLoad = this.getClass().getResourceAsStream(businessCalendarConfig); + private static void load(final String businessCalendarConfig) throws NoSuchFileException { + final InputStream configToLoad = Calendars.class.getResourceAsStream(businessCalendarConfig); if (configToLoad == null) { logger.warn("Could not find " + businessCalendarConfig + " on classpath"); @@ -112,7 +64,7 @@ private void load(final String businessCalendarConfig) final Consumer consumer = (filePath) -> { try { - final InputStream inputStream = this.getClass().getResourceAsStream(filePath); + final InputStream inputStream = Calendars.class.getResourceAsStream(filePath); if (inputStream != null) { final File calendarFile = inputStreamToFile(inputStream); final BusinessCalendar businessCalendar = BusinessCalendarParser.loadBusinessCalendar(calendarFile); @@ -140,21 +92,24 @@ private void load(final String businessCalendarConfig) } } - private void addCalendar(final BusinessCalendar cal) { + private synchronized static void addCalendar(final BusinessCalendar cal) { final String name = cal.name().toUpperCase(); if (!NameValidator.isValidQueryParameterName(name)) { throw new IllegalArgumentException("Invalid name for calendar: name='" + name + "'"); } - if (containsKey(name)) { - final Calendar oldCalendar = get(name); + if (map.containsKey(name)) { + final Calendar oldCalendar = map.get(name); if (oldCalendar.equals(cal)) { return; } throw new IllegalArgumentException("Multiple calendars have the same name: name='" + name + "'"); } - put(name, cal); + map.put(name, cal); + + names = map.keySet().toArray(String[]::new); + Arrays.sort(names); } /** @@ -162,7 +117,7 @@ private void addCalendar(final BusinessCalendar cal) { * * @param file business calendar file */ - public void addCalendarFromFile(final String file) { + public static void addCalendarFromFile(final String file) { addCalendarFromFile(new File(file)); } @@ -171,7 +126,7 @@ public void addCalendarFromFile(final String file) { * * @param file business calendar file */ - public void addCalendarFromFile(final File file) { + public static void addCalendarFromFile(final File file) { if (file.getAbsolutePath().endsWith(".calendar")) { final BusinessCalendar cal = BusinessCalendarParser.loadBusinessCalendar(file); addCalendar(cal); @@ -180,86 +135,73 @@ public void addCalendarFromFile(final File file) { } } - @Override - public int size() { - return calendars.size(); - } + private static File inputStreamToFile(@NotNull InputStream inputStream) throws IOException { + File calendarFile = File.createTempFile("temp-file-name", ".calendar"); + FileOutputStream outputStream = + new FileOutputStream(calendarFile); - @Override - public boolean isEmpty() { - return calendars.isEmpty(); - } + int read; + byte[] bytes = new byte[1024]; - @Override - public boolean containsKey(Object key) { - return !(key == null || !key.getClass().isAssignableFrom(String.class)) - && calendars.containsKey(((String) key).toUpperCase()); + while ((read = inputStream.read(bytes)) != -1) { + outputStream.write(bytes, 0, read); + } + outputStream.close(); + return calendarFile; } - @Override - public boolean containsValue(Object value) { - return calendars.containsValue(value); - } + // end region - @Override - public BusinessCalendar get(Object key) { - return calendars.get(key); - } + // region Methods - @Override - public BusinessCalendar put(String key, BusinessCalendar value) { - Require.neqNull(key, "key"); - key = key.toUpperCase(); - return calendars.put(key, value); + /** + * Sets the default calendar name. + * + * @param name calendar name + */ + public synchronized static void setDefaultCalendar(final String name) { + Require.neqNull(name, "name"); + defaultName = name; } - @Override - public BusinessCalendar remove(Object key) { - return calendars.remove(key); - } + /** + * Returns a business calendar. + * + * @param name name of the calendar + * @return business calendar + * @throws IllegalArgumentException no calendar matching {@code name} + * @throws RequirementFailure if the input is null + */ + public synchronized static BusinessCalendar calendar(final String name) { + Require.neqNull(name, "name"); - @Override - public void putAll(@NotNull Map m) { - calendars.putAll(m); - } + final String n = name.toUpperCase(); - @Override - public void clear() { - calendars.clear(); - } + if (!map.containsKey(n)) { + throw new IllegalArgumentException("No such calendar: " + name); + } - @NotNull - @Override - public Set keySet() { - return calendars.keySet(); + return map.get(n); } - @NotNull - @Override - public Collection values() { - return calendars.values(); + /** + * Returns the default business calendar. + * + * @return default business calendar. The default is specified by the {@code Calendar.default} property. + */ + public synchronized static BusinessCalendar calendar() { + return calendar(defaultName); } - @NotNull - @Override - public Set> entrySet() { - return calendars.entrySet(); + /** + * Returns the names of all available calendars + * + * @return names of all available calendars + */ + public synchronized static String[] calendarNames() { + return names; } - private static File inputStreamToFile(@NotNull InputStream inputStream) throws IOException { - File calendarFile = File.createTempFile("temp-file-name", ".calendar"); - FileOutputStream outputStream = - new FileOutputStream(calendarFile); - - int read; - byte[] bytes = new byte[1024]; - - while ((read = inputStream.read(bytes)) != -1) { - outputStream.write(bytes, 0, read); - } - - outputStream.close(); - return calendarFile; - } + // endregion } diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendars.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendars.java index 3a8fbc79cc4..3910d2f7bb2 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendars.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendars.java @@ -1,107 +1,40 @@ /** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending + * Copyright (c) 2016-2023 Deephaven Data Labs and Patent Pending */ package io.deephaven.time.calendar; -import io.deephaven.time.DateTimeUtils; -import org.junit.Test; +import io.deephaven.base.testing.BaseArrayTestCase; +import io.deephaven.configuration.Configuration; -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; +public class TestCalendars extends BaseArrayTestCase { -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; + public void testDefault() { + final BusinessCalendar calendar =Calendars.calendar(); + assertEquals(Configuration.getInstance().getProperty("Calendar.default"), calendar.name()); -public class TestCalendars { + final String defaultCal = calendar.name(); - @Test - public void testIsBusinessDay() { - BusinessCalendar usnyse = Calendars.calendar("USNYSE"); - BusinessCalendar usny = Calendars.calendar("USNY"); + Calendars.setDefaultCalendar("CAL2"); + assertEquals("CAL2", Calendars.calendar().name()); - // USNYSE - Instant businessDay = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - Instant halfDay = DateTimeUtils.parseInstant("2014-07-03T01:00:00.000000000 NY"); - Instant holiday = DateTimeUtils.parseInstant("2002-01-01T01:00:00.000000000 NY"); - Instant holiday2 = DateTimeUtils.parseInstant("2002-01-21T01:00:00.000000000 NY"); - - assertTrue(usnyse.isBusinessDay(businessDay)); - assertTrue(usnyse.isBusinessDay(halfDay)); - assertFalse(usnyse.isBusinessDay(holiday)); - assertFalse(usnyse.isBusinessDay(holiday2)); - - // USNY - businessDay = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - holiday = DateTimeUtils.parseInstant("2005-11-24T01:00:00.000000000 NY"); - holiday2 = DateTimeUtils.parseInstant("2002-01-21T01:00:00.000000000 NY"); - - assertTrue(usny.isBusinessDay(businessDay)); - assertFalse(usny.isBusinessDay(holiday)); - assertTrue(usny.isBusinessDay(holiday2)); + Calendars.setDefaultCalendar(defaultCal); } - @Test - public void testGetDefault() { - // Default is configured via a configuration property and cannot be changed once Calendars is statically - // initialized - assertEquals(Calendars.getDefaultName(), "USNYSE"); - BusinessCalendar calendars = Calendars.calendar(); - // USNYSE - Instant businessDay = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - Instant halfDay = DateTimeUtils.parseInstant("2014-07-03T01:00:00.000000000 NY"); - Instant holiday = DateTimeUtils.parseInstant("2002-01-01T01:00:00.000000000 NY"); - Instant holiday2 = DateTimeUtils.parseInstant("2002-01-21T01:00:00.000000000 NY"); - - assertTrue(calendars.isBusinessDay(businessDay)); - assertTrue(calendars.isBusinessDay(halfDay)); - assertFalse(calendars.isBusinessDay(holiday)); - assertFalse(calendars.isBusinessDay(holiday2)); - } - - @Test - public void testGetInstance() { - BusinessCalendar usnyse = Calendars.calendar("USNYSE"); - Instant businessDay = DateTimeUtils.parseInstant("2016-08-31T01:00:00.000000000 NY"); - Instant halfDay = DateTimeUtils.parseInstant("2014-07-03T01:00:00.000000000 NY"); - Instant holiday = DateTimeUtils.parseInstant("2002-01-01T01:00:00.000000000 NY"); - Instant holiday2 = DateTimeUtils.parseInstant("2002-01-21T01:00:00.000000000 NY"); - - assertTrue(usnyse.isBusinessDay(businessDay)); - assertTrue(usnyse.isBusinessDay(halfDay)); - assertFalse(usnyse.isBusinessDay(holiday)); - assertFalse(usnyse.isBusinessDay(holiday2)); + public void testCalendarNames() { + assertEquals(new String[]{"CAL1", "CAL2"}, Calendars.calendarNames()); } - @Test - public void testMapMethods() { - Calendars calendars = Calendars.getInstance(); - - final Map values = new HashMap<>(calendars); - - assertTrue(calendars.size() > 0); - assertEquals(calendars.keySet().size(), calendars.size()); - assertTrue(calendars.containsKey("USNYSE")); - assertTrue(calendars.containsKey("usnyse")); - assertFalse(calendars.containsKey("usnys")); - calendars.remove("USNYSE"); - assertFalse(calendars.containsKey("USNYSE")); - calendars.clear(); - assertTrue(calendars.isEmpty()); - - // replacing values so that other unit tests don't fail - calendars.putAll(values); - } - - @Test - public void testEquals() { - final BusinessCalendar usnyse1 = Calendars.calendar("USNYSE"); - final BusinessCalendar usnyse2 = Calendars.calendar("USNYSE"); - final BusinessCalendar jpose = Calendars.calendar("JPOSE"); - - assertEquals(usnyse1, usnyse2); - assertFalse(usnyse1.equals(jpose)); - assertFalse(usnyse1.equals(null)); + public void testCalendar() { + for(final String cn : Calendars.calendarNames()) { + final BusinessCalendar calendar = Calendars.calendar(cn); + assertEquals(cn, calendar.name()); + } + + try{ + Calendars.calendar("JUNK"); + fail("Should have thrown an exception"); + } catch (Exception e){ + //pass + } } } diff --git a/props/test-configs/src/main/resources/calendar/BEIJING.calendar b/props/test-configs/src/main/resources/calendar/BEIJING.calendar deleted file mode 100644 index f02d336d3ca..00000000000 --- a/props/test-configs/src/main/resources/calendar/BEIJING.calendar +++ /dev/null @@ -1,15 +0,0 @@ - - - - BEIJING - Asia/Shanghai - en - US - - 09:30,16:00 - Saturday - Sunday - - diff --git a/props/test-configs/src/main/resources/calendar/CAL1.calendar b/props/test-configs/src/main/resources/calendar/CAL1.calendar new file mode 100644 index 00000000000..50d2b6f3499 --- /dev/null +++ b/props/test-configs/src/main/resources/calendar/CAL1.calendar @@ -0,0 +1,178 @@ + + + + CAL1 + First business calendar + Europe/Berlin + 1990-01-01 + 2050-12-31 + + 09:0020:00 + Saturday + Sunday + + + 2015-01-01 + + + 2015-04-06 + + + 2015-05-25 + + + 2015-12-24 + + + 2015-12-25 + + + 2015-12-31 + + + 2016-01-01 + + + 2016-03-25 + + + 2016-03-28 + + + 2016-05-16 + + + 2016-10-03 + + + 2016-12-26 + + + 2017-04-14 + + + 2017-04-17 + + + 2017-05-01 + + + 2017-12-25 + + + 2017-12-26 + + + 2018-01-01 + + + 2018-03-30 + + + 2018-04-02 + + + 2018-05-01 + + + 2018-12-24 + + + 2018-12-25 + + + 2018-12-26 + + + 2018-12-31 + + + 2019-01-01 + + + 2019-04-19 + + + 2019-04-22 + + + 2019-05-01 + + + 2019-12-24 + + + 2019-12-25 + + + 2019-12-26 + + + 2019-12-31 + + + 2020-01-01 + + + 2020-04-10 + + + 2020-04-13 + + + 2020-05-01 + + + 2020-05-08 + + + 2020-05-21 + + + 2020-06-01 + + + 2020-12-24 + + + 2020-12-25 + + + 2020-12-31 + + + 2021-01-01 + + + 2021-04-02 + + + 2021-04-05 + + + 2021-05-24 + + + 2021-12-24 + + + 2021-12-31 + + + 2022-04-15 + + + 2022-04-18 + + + 2022-06-06 + + + 2022-10-03 + + + 2022-12-26 + + diff --git a/props/test-configs/src/main/resources/calendar/CAL2.calendar b/props/test-configs/src/main/resources/calendar/CAL2.calendar new file mode 100644 index 00000000000..57347f2a474 --- /dev/null +++ b/props/test-configs/src/main/resources/calendar/CAL2.calendar @@ -0,0 +1,178 @@ + + + + CAL2 + Second business calendar + America/New_York + 1990-01-01 + 2050-12-31 + + 09:0020:00 + Saturday + Sunday + + + 2015-01-01 + + + 2015-04-06 + + + 2015-05-25 + + + 2015-12-24 + + + 2015-12-25 + + + 2015-12-31 + + + 2016-01-01 + + + 2016-03-25 + + + 2016-03-28 + + + 2016-05-16 + + + 2016-10-03 + + + 2016-12-26 + + + 2017-04-14 + + + 2017-04-17 + + + 2017-05-01 + + + 2017-12-25 + + + 2017-12-26 + + + 2018-01-01 + + + 2018-03-30 + + + 2018-04-02 + + + 2018-05-01 + + + 2018-12-24 + + + 2018-12-25 + + + 2018-12-26 + + + 2018-12-31 + + + 2019-01-01 + + + 2019-04-19 + + + 2019-04-22 + + + 2019-05-01 + + + 2019-12-24 + + + 2019-12-25 + + + 2019-12-26 + + + 2019-12-31 + + + 2020-01-01 + + + 2020-04-10 + + + 2020-04-13 + + + 2020-05-01 + + + 2020-05-08 + + + 2020-05-21 + + + 2020-06-01 + + + 2020-12-24 + + + 2020-12-25 + + + 2020-12-31 + + + 2021-01-01 + + + 2021-04-02 + + + 2021-04-05 + + + 2021-05-24 + + + 2021-12-24 + + + 2021-12-31 + + + 2022-04-15 + + + 2022-04-18 + + + 2022-06-06 + + + 2022-10-03 + + + 2022-12-26 + + diff --git a/props/test-configs/src/main/resources/calendar/DTB.calendar b/props/test-configs/src/main/resources/calendar/DTB.calendar deleted file mode 100644 index 7f6e71f9658..00000000000 --- a/props/test-configs/src/main/resources/calendar/DTB.calendar +++ /dev/null @@ -1,175 +0,0 @@ - - - - DTB - Europe/Berlin - - 09:00,20:00 - Saturday - Sunday - - - 20150101 - - - 20150406 - - - 20150525 - - - 20151224 - - - 20151225 - - - 20151231 - - - 20160101 - - - 20160325 - - - 20160328 - - - 20160516 - - - 20161003 - - - 20161226 - - - 20170414 - - - 20170417 - - - 20170501 - - - 20171225 - - - 20171226 - - - 20180101 - - - 20180330 - - - 20180402 - - - 20180501 - - - 20181224 - - - 20181225 - - - 20181226 - - - 20181231 - - - 20190101 - - - 20190419 - - - 20190422 - - - 20190501 - - - 20191224 - - - 20191225 - - - 20191226 - - - 20191231 - - - 20200101 - - - 20200410 - - - 20200413 - - - 20200501 - - - 20200508 - - - 20200521 - - - 20200601 - - - 20201224 - - - 20201225 - - - 20201231 - - - 20210101 - - - 20210402 - - - 20210405 - - - 20210524 - - - 20211224 - - - 20211231 - - - 20220415 - - - 20220418 - - - 20220606 - - - 20221003 - - - 20221226 - - diff --git a/props/test-configs/src/main/resources/calendar/GBLO.calendar b/props/test-configs/src/main/resources/calendar/GBLO.calendar deleted file mode 100644 index d11c89da937..00000000000 --- a/props/test-configs/src/main/resources/calendar/GBLO.calendar +++ /dev/null @@ -1,355 +0,0 @@ - - - - GBLO - Europe/London - - 09:30,14:30 - Saturday - Sunday - - - 20090101 - - - 20090410 - - - 20090413 - - - 20090504 - - - 20090525 - - - 20090831 - - - 20091225 - - - 20091228 - - - 20100101 - - - 20100402 - - - 20100405 - - - 20100503 - - - 20100531 - - - 20100830 - - - 20101227 - - - 20101228 - - - 20110103 - - - 20110422 - - - 20110425 - - - 20110429 - - - 20110502 - - - 20110530 - - - 20110829 - - - 20111226 - - - 20111227 - - - 20120102 - - - 20120406 - - - 20120409 - - - 20120507 - - - 20120604 - - - 20120605 - - - 20120827 - - - 20121225 - - - 20121226 - - - 20130101 - - - 20130329 - - - 20130401 - - - 20130506 - - - 20130527 - - - 20130826 - - - 20131225 - - - 20131226 - - - 20140101 - - - 20140418 - - - 20140421 - - - 20140505 - - - 20140526 - - - 20140825 - - - 20141225 - - - 20141226 - - - 20150101 - - - 20150403 - - - 20150406 - - - 20150504 - - - 20150525 - - - 20150831 - - - 20151225 - - - 20151228 - - - 20160101 - - - 20160325 - - - 20160328 - - - 20160502 - - - 20160530 - - - 20160829 - - - 20161226 - - - 20161227 - - - 20170102 - - - 20170414 - - - 20170417 - - - 20170501 - - - 20170529 - - - 20170828 - - - 20171225 - - - 20171226 - - - 20180101 - - - 20180330 - - - 20180402 - - - 20180507 - - - 20180528 - - - 20180827 - - - 20181225 - - - 20181226 - - - 20190101 - - - 20190419 - - - 20190422 - - - 20190506 - - - 20190527 - - - 20190826 - - - 20191225 - - - 20191226 - - - 20200101 - - - 20200410 - - - 20200413 - - - 20200508 - - - 20200525 - - - 20200831 - - - 20201225 - - - 20201228 - - - 20210101 - - - 20210402 - - - 20210405 - - - 20210503 - - - 20210531 - - - 20210830 - - - 20211227 - - - 20211228 - - - 20220103 - - - 20220415 - - - 20220418 - - - 20220502 - - - 20220530 - - - 20220829 - - - 20221226 - - - 20221227 - - diff --git a/props/test-configs/src/main/resources/calendar/GLOBAL.calendar b/props/test-configs/src/main/resources/calendar/GLOBAL.calendar deleted file mode 100644 index 5c73b3b5ccd..00000000000 --- a/props/test-configs/src/main/resources/calendar/GLOBAL.calendar +++ /dev/null @@ -1,31 +0,0 @@ - - - - GLOBAL - America/New_York - - 09:30,16:00 - Saturday - Sunday - - - 20160325 - - - 20160328 - - - 20160530 - - - 20161226 - - - 20171225 - - - 20181225 - - \ No newline at end of file diff --git a/props/test-configs/src/main/resources/calendar/JPOSE.calendar b/props/test-configs/src/main/resources/calendar/JPOSE.calendar deleted file mode 100644 index a9f6e91c488..00000000000 --- a/props/test-configs/src/main/resources/calendar/JPOSE.calendar +++ /dev/null @@ -1,492 +0,0 @@ - - - - JPOSE - Asia/Tokyo - - 09:00,11:30 - 12:30,15:00 - Saturday - Sunday - - - 20060102 - - - 20060103 - - - 20060104 - 09:00,11:30 - - - 20060109 - - - 20060211 - - - 20060321 - - - 20060429 - - - 20060503 - - - 20060504 - - - 20060505 - - - 20060717 - - - 20060918 - - - 20060923 - - - 20061009 - - - 20061103 - - - 20061123 - - - 20061223 - - - 20061229 - 09:00,11:30 - - - 20070102 - - - 20070103 - - - 20070104 - 09:00,11:30 - - - 20070108 - - - 20070211 - - - 20070321 - - - 20070429 - - - 20070503 - - - 20070504 - - - 20070505 - - - 20070716 - - - 20070917 - - - 20070923 - - - 20071008 - - - 20071103 - - - 20071123 - - - 20071223 - - - 20071228 - 09:00,11:30 - - - 20070923 - - - 20071008 - - - 20170101 - - - 20170102 - - - 20170103 - - - 20170109 - - - 20170211 - - - 20170320 - - - 20170429 - - - 20170503 - - - 20170504 - - - 20170505 - - - 20170717 - - - 20170811 - - - 20170918 - - - 20170923 - - - 20171009 - - - 20171103 - - - 20171123 - - - 20171223 - - - 20171231 - - - 20180101 - - - 20180102 - - - 20180103 - - - 20180108 - - - 20180211 - - - 20180212 - - - 20180321 - - - 20180429 - - - 20180430 - - - 20180503 - - - 20180504 - - - 20180505 - - - 20180716 - - - 20180811 - - - 20180917 - - - 20180923 - - - 20180924 - - - 20181008 - - - 20181103 - - - 20181123 - - - 20181223 - - - 20181224 - - - 20181231 - - - 20190101 - - - 20190102 - - - 20190103 - - - 20190114 - - - 20190211 - - - 20190321 - - - 20190429 - - - 20190430 - - - 20190501 - - - 20190502 - - - 20190503 - - - 20190504 - - - 20190506 - - - 20190715 - - - 20190812 - - - 20190916 - - - 20190923 - - - 20191014 - - - 20191022 - - - 20191104 - - - 20191123 - - - 20191231 - - - 20200101 - - - 20200102 - - - 20200103 - - - 20200113 - - - 20200211 - - - 20200224 - - - 20200320 - - - 20200429 - - - 20200504 - - - 20200505 - - - 20200506 - - - 20200723 - - - 20200724 - - - 20200810 - - - 20200921 - - - 20200922 - - - 20201103 - - - 20201123 - - - 20201231 - - - 20210101 - - - 20210102 - - - 20210103 - - - 20210111 - - - 20210211 - - - 20210223 - - - 20210322 - - - 20210429 - - - 20210503 - - - 20210504 - - - 20210505 - - - 20210719 - - - 20210811 - - - 20210920 - - - 20210923 - - - 20211011 - - - 20211103 - - - 20211123 - - - 20211231 - - - 20220101 - - - 20220102 - - - 20220103 - - - 20220110 - - - 20220211 - - - 20220223 - - - 20220321 - - - 20220429 - - - 20220503 - - - 20220504 - - - 20220505 - - - 20220718 - - - 20220811 - - - 20220919 - - - 20220923 - - - 20221010 - - - 20221103 - - - 20221123 - - diff --git a/props/test-configs/src/main/resources/calendar/LSE.calendar b/props/test-configs/src/main/resources/calendar/LSE.calendar deleted file mode 100644 index e204bba0534..00000000000 --- a/props/test-configs/src/main/resources/calendar/LSE.calendar +++ /dev/null @@ -1,217 +0,0 @@ - - - - LSE - UTC - - 08:00,16:30 - Saturday - Sunday - - - 20150101 - - - 20150403 - - - 20150406 - - - 20150504 - - - 20150525 - - - 20150831 - - - 20151225 - - - 20151228 - - - 20160101 - - - 20160325 - - - 20160328 - - - 20160502 - - - 20160530 - - - 20160829 - - - 20161226 - - - 20161227 - - - 20170102 - - - 20170414 - - - 20170417 - - - 20170501 - - - 20170529 - - - 20170828 - - - 20171225 - - - 20171226 - - - 20180101 - - - 20180330 - - - 20180402 - - - 20180507 - - - 20180528 - - - 20180827 - - - 20181225 - - - 20181226 - - - 20190101 - - - 20190419 - - - 20190422 - - - 20190506 - - - 20190527 - - - 20190826 - - - 20191224 - 08:00,12:30 - - - 20191225 - - - 20191226 - - - 20191231 - 08:00,12:30 - - - 20200101 - - - 20200410 - - - 20200413 - - - 20200508 - - - 20200525 - - - 20200831 - - - 20201224 - 08:00,12:30 - - - 20201225 - - - 20201228 - - - 20201231 - 08:00,12:30 - - - 20210101 - - - 20210402 - - - 20210405 - - - 20210503 - - - 20210531 - - - 20210802 - - - 20211224 - 08:00,12:30 - - - 20211231 - 08:00,12:30 - - - 20220415 - - - 20220418 - - - 20220502 - - - 20220530 - - - 20220801 - - - 20221226 - - diff --git a/props/test-configs/src/main/resources/calendar/MOSCOW.calendar b/props/test-configs/src/main/resources/calendar/MOSCOW.calendar deleted file mode 100644 index 1aabe7af46a..00000000000 --- a/props/test-configs/src/main/resources/calendar/MOSCOW.calendar +++ /dev/null @@ -1,839 +0,0 @@ - - - - MOSCOW - Europe/Moscow - - 09:30,19:00 - Saturday - Sunday - - - 19990101 - - - 19990118 - - - 19990215 - - - 19990402 - - - 19990531 - - - 19990705 - - - 19990906 - - - 19991125 - - - 19991224 - - - 19991231 - - - 20000117 - - - 20000221 - - - 20000421 - - - 20000529 - - - 20000704 - - - 20000904 - - - 20001123 - - - 20001225 - - - 20010101 - - - 20010115 - - - 20010219 - - - 20010413 - - - 20010528 - - - 20010704 - - - 20010903 - - - 20010911 - - - 20010912 - - - 20010913 - - - 20010914 - - - 20011122 - - - 20011225 - - - 20020101 - - - 20020117 - - - 20020218 - - - 20020329 - - - 20020527 - - - 20020704 - - - 20020705 - 09:30,13:00 - - - 20020902 - - - 20021128 - - - 20021129 - 09:30,13:00 - - - 20021224 - 09:30,13:00 - - - 20021225 - - - 20030101 - - - 20030120 - - - 20030217 - - - 20030418 - - - 20030526 - - - 20030703 - 09:30,13:00 - - - 20030704 - - - 20030901 - - - 20031127 - - - 20031128 - 09:30,13:00 - - - 20031224 - 09:30,13:00 - - - 20031225 - - - 20031226 - 09:30,13:00 - - - 20040101 - - - 20040119 - - - 20040216 - - - 20040409 - - - 20040531 - - - 20040611 - - - 20040705 - - - 20040906 - - - 20041125 - - - 20041126 - 09:30,13:00 - - - 20041224 - - - 20050117 - - - 20050221 - - - 20050325 - - - 20050530 - - - 20050704 - - - 20050905 - - - 20051124 - - - 20051125 - 09:30,13:00 - - - 20051226 - - - 20060102 - - - 20060116 - - - 20060220 - - - 20060414 - - - 20060529 - - - 20060703 - 09:30,13:00 - - - 20060704 - - - 20060904 - - - 20061123 - - - 20061124 - 09:30,13:00 - - - 20061225 - - - 20070101 - - - 20070102 - - - 20070115 - - - 20070219 - - - 20070406 - - - 20070528 - - - 20070703 - 09:30,13:00 - - - 20070704 - - - 20070903 - - - 20071122 - - - 20071123 - 09:30,13:00 - - - 20071224 - 09:30,13:00 - - - 20071225 - - - 20080101 - - - 20080121 - - - 20080218 - - - 20080321 - - - 20080526 - - - 20080703 - 09:30,13:00 - - - 20080704 - - - 20080901 - - - 20081127 - - - 20081128 - 09:30,13:00 - - - 20081224 - 09:30,13:00 - - - 20081225 - - - 20090101 - - - 20090119 - - - 20090216 - - - 20090410 - - - 20090525 - - - 20090703 - - - 20090907 - - - 20091126 - - - 20091127 - 09:30,13:00 - - - 20091224 - 09:30,13:00 - - - 20091225 - - - 20100101 - - - 20100118 - - - 20100215 - - - 20100402 - - - 20100531 - - - 20100705 - - - 20100906 - - - 20101125 - - - 20101126 - 09:30,13:00 - - - 20101224 - - - 20110117 - - - 20110221 - - - 20110422 - - - 20110530 - - - 20110704 - - - 20110905 - - - 20111124 - - - 20111125 - 09:30,13:00 - - - 20111226 - - - 20120102 - - - 20120116 - - - 20120220 - - - 20120406 - - - 20120528 - - - 20120703 - 09:30,13:00 - - - 20120704 - - - 20120903 - - - 20121029 - - - 20121030 - - - 20121122 - - - 20121123 - 09:30,13:00 - - - 20121124 - 09:30,13:00 - - - 20121225 - - - 20130101 - - - 20130121 - - - 20130218 - - - 20130329 - - - 20130527 - - - 20130703 - 09:30,13:00 - - - 20130704 - - - 20130902 - - - 20131128 - - - 20131129 - 09:30,13:00 - - - 20131224 - 09:30,13:00 - - - 20131225 - - - 20140101 - - - 20140120 - - - 20140217 - - - 20140418 - - - 20140526 - - - 20140703 - 09:30,13:00 - - - 20140704 - - - 20140901 - - - 20141127 - - - 20141128 - 09:30,13:00 - - - 20141224 - 09:30,13:00 - - - 20141225 - - - 20150101 - - - 20150119 - - - 20150216 - - - 20150403 - - - 20150525 - - - 20150703 - - - 20150907 - - - 20151126 - - - 20151127 - 09:30,13:00 - - - 20151224 - 09:30,13:00 - - - 20151225 - - - 20160101 - - - 20160118 - - - 20160215 - - - 20160325 - - - 20160530 - - - 20160704 - - - 20160905 - - - 20161124 - - - 20161125 - 09:30,13:00 - - - 20161226 - - - 20170102 - - - 20170116 - - - 20170220 - - - 20170414 - - - 20170529 - - - 20170703 - 09:30,13:00 - - - 20170704 - - - 20170904 - - - 20171123 - - - 20171124 - 09:30,13:00 - - - 20171225 - - - 20180101 - - - 20180115 - - - 20180219 - - - 20180330 - - - 20180528 - - - 20180703 - 09:30,13:00 - - - 20180704 - - - 20180903 - - - 20181122 - - - 20181123 - 09:30,13:00 - - - 20181225 - - - 20190101 - - - 20190102 - - - 20190107 - - - 20190308 - - - 20190501 - - - 20190509 - - - 20190612 - - - 20191104 - - - 20191230 - - - 20191231 - - - 20200101 - - - 20200102 - - - 20200107 - - - 20200224 - - - 20200309 - - - 20200501 - - - 20200511 - - - 20200612 - - - 20201104 - - - 20201231 - - - 20210101 - - - 20210104 - - - 20210107 - - - 20210223 - - - 20210308 - - - 20210503 - - - 20210510 - - - 20210614 - - - 20211104 - - - 20211231 - - - 20220103 - - - 20220104 - - - 20220107 - - - 20220223 - - - 20220308 - - - 20220501 - - - 20220509 - - - 20220613 - - - 20221104 - - - 20221231 - - diff --git a/props/test-configs/src/main/resources/calendar/MUMBAI.calendar b/props/test-configs/src/main/resources/calendar/MUMBAI.calendar deleted file mode 100644 index cfbc2744fd3..00000000000 --- a/props/test-configs/src/main/resources/calendar/MUMBAI.calendar +++ /dev/null @@ -1,370 +0,0 @@ - - - - MUMBAI - Asia/Kolkata - - 09:15,15:30 - Saturday - Sunday - - - 20150126 - - - 20150217 - - - 20150219 - - - 20150306 - - - 20150401 - - - 20150402 - - - 20150403 - - - 20150414 - - - 20150501 - - - 20150504 - - - 20150818 - - - 20150917 - - - 20150925 - - - 20151002 - - - 20151022 - - - 20151111 - - - 20151112 - - - 20151125 - - - 20151224 - - - 20151225 - - - 20160126 - - - 20160219 - - - 20160307 - - - 20160324 - - - 20160325 - - - 20160401 - - - 20160414 - - - 20160415 - - - 20160419 - - - 20160428 - - - 20160706 - - - 20160815 - - - 20160817 - - - 20160905 - - - 20160913 - - - 20161011 - - - 20161012 - - - 20161031 - - - 20161114 - - - 20161212 - - - 20170126 - - - 20170224 - - - 20170313 - - - 20170414 - - - 20170501 - - - 20170626 - - - 20170815 - - - 20170825 - - - 20171002 - - - 20171019 - - - 20171020 - - - 20171225 - - - 20180126 - - - 20180213 - - - 20180302 - - - 20180329 - - - 20180330 - - - 20180501 - - - 20180815 - - - 20180822 - - - 20180913 - - - 20180920 - - - 20181002 - - - 20181018 - - - 20181107 - - - 20181108 - - - 20181123 - - - 20181225 - - - 20190304 - - - 20190321 - - - 20190417 - - - 20190419 - - - 20190501 - - - 20190605 - - - 20190812 - - - 20190815 - - - 20190902 - - - 20190910 - - - 20191002 - - - 20191008 - - - 20191028 - - - 20191112 - - - 20191225 - - - 20200221 - - - 20200310 - - - 20200402 - - - 20200406 - - - 20200410 - - - 20200414 - - - 20200501 - - - 20200525 - - - 20201002 - - - 20201116 - - - 20201130 - - - 20201225 - - - 20210126 - - - 20210311 - - - 20210329 - - - 20210402 - - - 20210414 - - - 20210513 - - - 20210720 - - - 20210819 - - - 20210910 - - - 20211015 - - - 20211104 - - - 20211119 - - - 20220126 - - - 20220301 - - - 20220318 - - - 20220414 - - - 20220415 - - - 20220502 - - - 20220809 - - - 20220815 - - - 20220830 - - - 20221004 - - - 20221025 - - - 20221107 - - diff --git a/props/test-configs/src/main/resources/calendar/USNY.calendar b/props/test-configs/src/main/resources/calendar/USNY.calendar deleted file mode 100644 index e755f8cd248..00000000000 --- a/props/test-configs/src/main/resources/calendar/USNY.calendar +++ /dev/null @@ -1,547 +0,0 @@ - - - - USNY - America/New_York - - 09:30,16:00 - Saturday - Sunday - - - 20040101 - - - 20040119 - - - 20040216 - - - 20040531 - - - 20040705 - - - 20040906 - - - 20041011 - - - 20041111 - - - 20041125 - - - 20050101 - - - 20050117 - - - 20050221 - - - 20050325 - - - 20050530 - - - 20050704 - - - 20050905 - - - 20051124 - - - 20051226 - - - 20060102 - - - 20060116 - - - 20060220 - - - 20060529 - - - 20060704 - - - 20060904 - - - 20061009 - - - 20061123 - - - 20061225 - - - 20070101 - - - 20070115 - - - 20070219 - - - 20070406 - - - 20070528 - - - 20070704 - - - 20070903 - - - 20071008 - - - 20071112 - - - 20071122 - - - 20071225 - - - 20080101 - - - 20080121 - - - 20080218 - - - 20080321 - - - 20080526 - - - 20080704 - - - 20080901 - - - 20081013 - - - 20081111 - - - 20081127 - - - 20081225 - - - 20090101 - - - 20090119 - - - 20090216 - - - 20090410 - - - 20090525 - - - 20090703 - - - 20090907 - - - 20091012 - - - 20091111 - - - 20091126 - - - 20091225 - - - 20100101 - - - 20100118 - - - 20100215 - - - 20100402 - - - 20100531 - - - 20100705 - - - 20100906 - - - 20101011 - - - 20101111 - - - 20101125 - - - 20101224 - - - 20110117 - - - 20110221 - - - 20110422 - - - 20110530 - - - 20110704 - - - 20110905 - - - 20111010 - - - 20111111 - - - 20111124 - - - 20111226 - - - 20120102 - - - 20120116 - - - 20120220 - - - 20120406 - - - 20120528 - - - 20120704 - - - 20120903 - - - 20121112 - - - 20121122 - - - 20121225 - - - 20130101 - - - 20130121 - - - 20130218 - - - 20130329 - - - 20130527 - - - 20130704 - - - 20130902 - - - 20131014 - - - 20131111 - - - 20131128 - - - 20131225 - - - 20140101 - - - 20140120 - - - 20140217 - - - 20140418 - - - 20140526 - - - 20140704 - - - 20140901 - - - 20141013 - - - 20141111 - - - 20141127 - - - 20141225 - - - 20150101 - - - 20150119 - - - 20150216 - - - 20150403 - - - 20150525 - - - 20150703 - - - 20150907 - - - 20151012 - - - 20151111 - - - 20151126 - - - 20151225 - - - 20160101 - - - 20160118 - - - 20160215 - - - 20160325 - - - 20160530 - - - 20160704 - - - 20160905 - - - 20161010 - - - 20161111 - - - 20161124 - - - 20161226 - - - 20170102 - - - 20170116 - - - 20170220 - - - 20170414 - - - 20170529 - - - 20170704 - - - 20170904 - - - 20171009 - - - 20171110 - - - 20171123 - - - 20171225 - - - 20180101 - - - 20180115 - - - 20180219 - - - 20180330 - - - 20180528 - - - 20180704 - - - 20180903 - - - 20181008 - - - 20181112 - - - 20181122 - - - 20181225 - - - 20190101 - - - 20190121 - - - 20190218 - - - 20190419 - - - 20190527 - - - 20190704 - - - 20190902 - - - 20191014 - - - 20191111 - - - 20191128 - - - 20191225 - - - 20200101 - - - 20200120 - - - 20200217 - - - 20200525 - - - 20200704 - - - 20200907 - - - 20201012 - - - 20201111 - - - 20201126 - - - 20201225 - - diff --git a/props/test-configs/src/main/resources/calendar/USNYSE.calendar b/props/test-configs/src/main/resources/calendar/USNYSE.calendar deleted file mode 100644 index 3b4050adb8d..00000000000 --- a/props/test-configs/src/main/resources/calendar/USNYSE.calendar +++ /dev/null @@ -1,856 +0,0 @@ - - - - USNYSE - America/New_York - - 09:30,16:00 - Saturday - Sunday - - - 19990101 - - - 19990118 - - - 19990215 - - - 19990402 - - - 19990531 - - - 19990705 - - - 19990906 - - - 19991125 - - - 19991224 - - - 20000117 - - - 20000221 - - - 20000421 - - - 20000529 - - - 20000704 - - - 20000904 - - - 20001123 - - - 20001225 - - - 20010101 - - - 20010115 - - - 20010219 - - - 20010413 - - - 20010528 - - - 20010704 - - - 20010903 - - - 20010911 - - - 20010912 - - - 20010913 - - - 20010914 - - - 20011122 - - - 20011225 - - - 20020101 - - - 20020121 - - - 20020218 - - - 20020329 - - - 20020527 - - - 20020704 - - - 20020705 - 09:30,13:00 - - - 20020902 - - - 20021128 - - - 20021129 - 09:30,13:00 - - - 20021224 - 09:30,13:00 - - - 20021225 - - - 20030101 - - - 20030120 - - - 20030217 - - - 20030418 - - - 20030526 - - - 20030703 - 09:30,13:00 - - - 20030704 - - - 20030901 - - - 20031127 - - - 20031128 - 09:30,13:00 - - - 20031224 - 09:30,13:00 - - - 20031225 - - - 20031226 - 09:30,13:00 - - - 20040101 - - - 20040119 - - - 20040216 - - - 20040409 - - - 20040531 - - - 20040611 - - - 20040705 - - - 20040906 - - - 20041125 - - - 20041126 - 09:30,13:00 - - - 20041224 - - - 20050117 - - - 20050221 - - - 20050325 - - - 20050530 - - - 20050704 - - - 20050905 - - - 20051124 - - - 20051125 - 09:30,13:00 - - - 20051226 - - - 20060102 - - - 20060116 - - - 20060220 - - - 20060414 - - - 20060529 - - - 20060703 - 09:30,13:00 - - - 20060704 - - - 20060904 - - - 20061123 - - - 20061124 - 09:30,13:00 - - - 20061225 - - - 20070101 - - - 20070102 - - - 20070115 - - - 20070219 - - - 20070406 - - - 20070528 - - - 20070703 - 09:30,13:00 - - - 20070704 - - - 20070903 - - - 20071122 - - - 20071123 - 09:30,13:00 - - - 20071224 - 09:30,13:00 - - - 20071225 - - - 20080101 - - - 20080121 - - - 20080218 - - - 20080321 - - - 20080526 - - - 20080703 - 09:30,13:00 - - - 20080704 - - - 20080901 - - - 20081127 - - - 20081128 - 09:30,13:00 - - - 20081224 - 09:30,13:00 - - - 20081225 - - - 20090101 - - - 20090119 - - - 20090216 - - - 20090410 - - - 20090525 - - - 20090703 - - - 20090907 - - - 20091126 - - - 20091127 - 09:30,13:00 - - - 20091224 - 09:30,13:00 - - - 20091225 - - - 20100101 - - - 20100118 - - - 20100215 - - - 20100402 - - - 20100531 - - - 20100705 - - - 20100906 - - - 20101125 - - - 20101126 - 09:30,13:00 - - - 20101224 - - - 20110117 - - - 20110221 - - - 20110422 - - - 20110530 - - - 20110704 - - - 20110905 - - - 20111124 - - - 20111125 - 09:30,13:00 - - - 20111226 - - - 20120102 - - - 20120116 - - - 20120220 - - - 20120406 - - - 20120528 - - - 20120703 - 09:30,13:00 - - - 20120704 - - - 20120903 - - - 20121029 - - - 20121030 - - - 20121122 - - - 20121123 - 09:30,13:00 - - - 20121224 - 09:30,13:00 - - - 20121225 - - - 20130101 - - - 20130121 - - - 20130218 - - - 20130329 - - - 20130527 - - - 20130703 - 09:30,13:00 - - - 20130704 - - - 20130902 - - - 20131128 - - - 20131129 - 09:30,13:00 - - - 20131224 - 09:30,13:00 - - - 20131225 - - - 20140101 - - - 20140120 - - - 20140217 - - - 20140418 - - - 20140526 - - - 20140703 - 09:30,13:00 - - - 20140704 - - - 20140901 - - - 20141127 - - - 20141128 - 09:30,13:00 - - - 20141224 - 09:30,13:00 - - - 20141225 - - - 20150101 - - - 20150119 - - - 20150216 - - - 20150403 - - - 20150525 - - - 20150703 - - - 20150907 - - - 20151126 - - - 20151127 - 09:30,13:00 - - - 20151224 - 09:30,13:00 - - - 20151225 - - - 20160101 - - - 20160118 - - - 20160215 - - - 20160325 - - - 20160530 - - - 20160704 - - - 20160905 - - - 20161124 - - - 20161125 - 09:30,13:00 - - - 20161226 - - - 20170102 - - - 20170116 - - - 20170220 - - - 20170414 - - - 20170529 - - - 20170703 - 09:30,13:00 - - - 20170704 - - - 20170904 - - - 20171123 - - - 20171124 - 09:30,13:00 - - - 20171225 - - - 20180101 - - - 20180115 - - - 20180219 - - - 20180330 - - - 20180528 - - - 20180703 - 09:30,13:00 - - - 20180704 - - - 20180903 - - - 20181122 - - - 20181123 - 09:30,13:00 - - - 20181205 - - - 20181224 - 09:30,13:00 - - - 20181225 - - - 20190101 - - - 20190121 - - - 20190218 - - - 20190419 - - - 20190527 - - - 20190703 - 09:30,13:00 - - - 20190704 - - - 20190902 - - - 20191128 - - - 20191129 - 09:30,13:00 - - - 20191224 - 09:30,13:00 - - - 20191225 - - - 20200101 - - - 20200120 - - - 20200217 - - - 20200410 - - - 20200525 - - - 20200703 - - - 20200907 - - - 20201126 - - - 20201127 - 09:30,13:00 - - - 20201224 - 09:30,13:00 - - - 20201225 - - - 20210101 - - - 20210118 - - - 20210215 - - - 20210402 - - - 20210531 - - - 20210705 - - - 20210906 - - - 20211125 - - - 20211126 - 09:30,13:00 - - - 20211224 - - - 20220117 - - - 20220221 - - - 20220415 - - - 20220530 - - - 20220704 - - - 20220905 - - - 20221124 - - - 20221125 - 09:30,13:00 - - - 20221226 - - diff --git a/props/test-configs/src/main/resources/calendar/USNYSEWEEKDAYS.calendar b/props/test-configs/src/main/resources/calendar/USNYSEWEEKDAYS.calendar deleted file mode 100644 index 11b65deaee1..00000000000 --- a/props/test-configs/src/main/resources/calendar/USNYSEWEEKDAYS.calendar +++ /dev/null @@ -1,15 +0,0 @@ - - - - USNYSEWEEKDAYS - America/New_York - en - US - - 09:30,16:00 - Saturday - Sunday - - \ No newline at end of file diff --git a/props/test-configs/src/main/resources/dh-tests.prop b/props/test-configs/src/main/resources/dh-tests.prop index 686b4e79801..8fbf1919ee7 100644 --- a/props/test-configs/src/main/resources/dh-tests.prop +++ b/props/test-configs/src/main/resources/dh-tests.prop @@ -37,7 +37,7 @@ TableDataRefreshService.tableSizeRefreshMillis=1000 ###### Time Zone & Calendars ##### timezone.aliases=/test_time_zone_aliases.csv -Calendar.default=USNYSE +Calendar.default=CAL1 Calendar.importPath=/test_calendar_imports.txt columnsFile=DeephavenColumns.xml diff --git a/props/test-configs/src/main/resources/test_calendar_imports.txt b/props/test-configs/src/main/resources/test_calendar_imports.txt index 763f6969489..d3ab04ca85e 100644 --- a/props/test-configs/src/main/resources/test_calendar_imports.txt +++ b/props/test-configs/src/main/resources/test_calendar_imports.txt @@ -1,12 +1,2 @@ -/calendar/BEIJING.calendar -/calendar/DTB.calendar -/calendar/GBLO.calendar -/calendar/GLOBAL.calendar -/calendar/JPOSE.calendar -/calendar/LSE.calendar -/calendar/MOSCOW.calendar -/calendar/MUMBAI.calendar -/calendar/USNY.calendar -/calendar/USNYSE.calendar -/calendar/USNYSEWEEKDAYS.calendar -/calendar/UTC.calendar +/calendar/CAL1.calendar +/calendar/CAL2.calendar From a4d9605459a47f3fc6de357740cb95da3eb1ef4d Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Mon, 30 Oct 2023 14:14:08 -0600 Subject: [PATCH 047/150] Updated doc string. --- .../main/java/io/deephaven/time/calendar/BusinessPeriod.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java index 74cea6ac4b1..8373860e4a8 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessPeriod.java @@ -45,7 +45,7 @@ public class BusinessPeriod & Temporal> { } /** - * start of the period. + * Start of the period. * * @return start of the period */ From f9c190c598f8682928beb72ca0a1d478c6f753a4 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 31 Oct 2023 10:03:26 -0600 Subject: [PATCH 048/150] Updated doc string. Added a weekendDays getter. --- .../time/calendar/BusinessCalendar.java | 21 +++++++++++++++++++ .../time/calendar/BusinessSchedule.java | 4 ++++ .../time/calendar/TestBusinessCalendar.java | 1 + 3 files changed, 26 insertions(+) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index 2a916027a65..e65e9c3c2f2 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -128,6 +128,18 @@ private YearData getYearData(final int year) { // region Constructors + /** + * Creates a new business calendar. + * + * @param name calendar name. + * @param description calendar description. + * @param timeZone calendar time zone. + * @param firstValidDate first valid date for the business calendar. + * @param lastValidDate last valid date for the business calendar. + * @param standardBusinessSchedule business schedule for a standard business day + * @param weekendDays weekend days + * @param holidays holidays + */ public BusinessCalendar(final String name, final String description, final ZoneId timeZone, final LocalDate firstValidDate, final LocalDate lastValidDate, final BusinessSchedule standardBusinessSchedule, final Set weekendDays, final Map> holidays) { super(name, description, timeZone); this.firstValidDate = firstValidDate; @@ -166,6 +178,15 @@ public LocalDate lastValidDate() { // region Business Schedule + /** + * Returns the days that make up a weekend. + * + * @return days that make up a weekend. + */ + public Set weekendDays() { + return this.weekendDays; + } + /** * Business schedule for a standard business day. * diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java index 7a31c28946d..cd3cc5699ca 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessSchedule.java @@ -20,6 +20,10 @@ /** * Schedule for a single business day. * + * A business day / schedule may contain multiple business periods. For example, some financial exchanges + * have a morning and an afternoon trading session. This would be represented by a business schedule with two + * business periods. + * * @param time type */ public class BusinessSchedule & Temporal> { diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java index c2d72448715..42a83007b54 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java @@ -49,6 +49,7 @@ public void testBusinessGetters() { assertEquals(holidays, bCalendar.holidays()); assertEquals(firstValidDate, bCalendar.firstValidDate()); assertEquals(lastValidDate, bCalendar.lastValidDate()); + assertEquals(weekendDays, bCalendar.weekendDays()); } public void testBusinessSchedule() { From c61aa38e099834ed391cd5fe0342ffacf6e53bd3 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 31 Oct 2023 13:02:57 -0600 Subject: [PATCH 049/150] Updated doc string. Added a weekendDays getter. --- .../time/calendar/BusinessCalendar.java | 110 ++++-- .../io/deephaven/time/calendar/Calendar.java | 49 ++- .../time/calendar/TestBusinessCalendar.java | 350 +++++++++++------- .../deephaven/time/calendar/TestCalendar.java | 96 +++-- 4 files changed, 405 insertions(+), 200 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java index e65e9c3c2f2..6299edd50c3 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendar.java @@ -1456,8 +1456,6 @@ public double diffBusinessYears(final ZonedDateTime start, final ZonedDateTime e // region Arithmetic - //TODO: should the add/subtract methods on Instants or ZDT return times of LocalDates? - /** * Adds a specified number of business days to an input date. Adding negative days is equivalent to subtracting days. * @@ -1502,7 +1500,12 @@ public LocalDate plusBusinessDays(final String date, final int days) { } /** - * Adds a specified number of business days to an input date. Adding negative days is equivalent to subtracting days. + * Adds a specified number of business days to an input time. Adding negative days is equivalent to subtracting days. + * + * Day additions are not always 24 hours. The resultant time will have the same local time as the input time, + * as determined by the calendar's time zone. This accounts for Daylight Savings Time. + * For example, 2023-11-05 has a daylight savings time adjustment, + * so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference. * * @param time time * @param days number of days to add. @@ -1510,13 +1513,22 @@ public LocalDate plusBusinessDays(final String date, final int days) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate plusBusinessDays(final Instant time, final int days) { + public Instant plusBusinessDays(final Instant time, final int days) { Require.neqNull(time, "time"); - return plusBusinessDays(DateTimeUtils.toLocalDate(time, timeZone()), days); + final ZonedDateTime zdt = plusBusinessDays(DateTimeUtils.toZonedDateTime(time, timeZone()), days); + return zdt == null ? null : zdt.toInstant(); } /** - * Adds a specified number of business days to an input date. Adding negative days is equivalent to subtracting days. + * Adds a specified number of business days to an input time. Adding negative days is equivalent to subtracting days. + * + * Day additions are not always 24 hours. The resultant time will have the same local time as the input time, + * as determined by the calendar's time zone. This accounts for Daylight Savings Time. + * For example, 2023-11-05 has a daylight savings time adjustment, + * so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference. + * + * The resultant time will have the same time zone as the calendar. This could be different than the + * time zone of the input {@link ZonedDateTime}. * * @param time time * @param days number of days to add. @@ -1524,9 +1536,14 @@ public LocalDate plusBusinessDays(final Instant time, final int days) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate plusBusinessDays(final ZonedDateTime time, final int days) { + public ZonedDateTime plusBusinessDays(final ZonedDateTime time, final int days) { Require.neqNull(time, "time"); - return plusBusinessDays(time.toInstant(), days); + final ZonedDateTime zdt = time.withZoneSameInstant(timeZone()); + final LocalDate pbd = plusBusinessDays(zdt.toLocalDate(), days); + return pbd == null ? null : + pbd + .atTime(zdt.toLocalTime()) + .atZone(timeZone()); } /** @@ -1557,7 +1574,12 @@ public LocalDate minusBusinessDays(final String date, final int days) { } /** - * Subtracts a specified number of business days from an input date. Subtracting negative days is equivalent to adding days. + * Subtracts a specified number of business days from an input time. Subtracting negative days is equivalent to adding days. + * + * Day subtractions are not always 24 hours. The resultant time will have the same local time as the input time, + * as determined by the calendar's time zone. This accounts for Daylight Savings Time. + * For example, 2023-11-05 has a daylight savings time adjustment, + * so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference. * * @param time time * @param days number of days to add. @@ -1565,12 +1587,20 @@ public LocalDate minusBusinessDays(final String date, final int days) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate minusBusinessDays(final Instant time, final int days) { + public Instant minusBusinessDays(final Instant time, final int days) { return plusBusinessDays(time, -days); } /** - * Subtracts a specified number of business days from an input date. Subtracting negative days is equivalent to adding days. + * Subtracts a specified number of business days from an input time. Subtracting negative days is equivalent to adding days. + * + * Day subtraction are not always 24 hours. The resultant time will have the same local time as the input time, + * as determined by the calendar's time zone. This accounts for Daylight Savings Time. + * For example, 2023-11-05 has a daylight savings time adjustment, + * so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference. + * + * The resultant time will have the same time zone as the calendar. This could be different than the + * time zone of the input {@link ZonedDateTime}. * * @param time time * @param days number of days to add. @@ -1578,7 +1608,7 @@ public LocalDate minusBusinessDays(final Instant time, final int days) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate minusBusinessDays(final ZonedDateTime time, final int days) { + public ZonedDateTime minusBusinessDays(final ZonedDateTime time, final int days) { return plusBusinessDays(time, -days); } @@ -1626,7 +1656,15 @@ public LocalDate plusNonBusinessDays(final String date, final int days) { } /** - * Adds a specified number of non-business days to an input date. Adding negative days is equivalent to subtracting days. + * Adds a specified number of non-business days to an input time. Adding negative days is equivalent to subtracting days. + * + * Day additions are not always 24 hours. The resultant time will have the same local time as the input time, + * as determined by the calendar's time zone. This accounts for Daylight Savings Time. + * For example, 2023-11-05 has a daylight savings time adjustment, + * so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference. + * + * The resultant time will have the same time zone as the calendar. This could be different than the + * time zone of the input {@link ZonedDateTime}. * * @param time time * @param days number of days to add. @@ -1634,13 +1672,23 @@ public LocalDate plusNonBusinessDays(final String date, final int days) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate plusNonBusinessDays(final Instant time, final int days) { + public Instant plusNonBusinessDays(final Instant time, final int days) { Require.neqNull(time, "time"); - return this.plusNonBusinessDays(DateTimeUtils.toLocalDate(time, timeZone()), days); + final ZonedDateTime zdt = plusNonBusinessDays(DateTimeUtils.toZonedDateTime(time, timeZone()), days); + return zdt == null ? null : zdt.toInstant(); + } /** - * Adds a specified number of non-business days to an input date. Adding negative days is equivalent to subtracting days. + * Adds a specified number of non-business days to an input time. Adding negative days is equivalent to subtracting days. + * + * Day additions are not always 24 hours. The resultant time will have the same local time as the input time, + * as determined by the calendar's time zone. This accounts for Daylight Savings Time. + * For example, 2023-11-05 has a daylight savings time adjustment, + * so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference. + * + * The resultant time will have the same time zone as the calendar. This could be different than the + * time zone of the input {@link ZonedDateTime}. * * @param time time * @param days number of days to add. @@ -1648,9 +1696,14 @@ public LocalDate plusNonBusinessDays(final Instant time, final int days) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate plusNonBusinessDays(final ZonedDateTime time, final int days) { + public ZonedDateTime plusNonBusinessDays(final ZonedDateTime time, final int days) { Require.neqNull(time, "time"); - return plusNonBusinessDays(time.toInstant(), days); + final ZonedDateTime zdt = time.withZoneSameInstant(timeZone()); + final LocalDate pbd = plusNonBusinessDays(zdt.toLocalDate(), days); + return pbd == null ? null : + pbd + .atTime(zdt.toLocalTime()) + .atZone(timeZone()); } /** @@ -1681,7 +1734,12 @@ public LocalDate minusNonBusinessDays(final String date, final int days) { } /** - * Subtracts a specified number of non-business days to an input date. Subtracting negative days is equivalent to adding days. + * Subtracts a specified number of non-business days to an input time. Subtracting negative days is equivalent to adding days. + * + * Day subtractions are not always 24 hours. The resultant time will have the same local time as the input time, + * as determined by the calendar's time zone. This accounts for Daylight Savings Time. + * For example, 2023-11-05 has a daylight savings time adjustment, + * so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference. * * @param time time * @param days number of days to add. @@ -1689,12 +1747,20 @@ public LocalDate minusNonBusinessDays(final String date, final int days) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate minusNonBusinessDays(final Instant time, final int days) { + public Instant minusNonBusinessDays(final Instant time, final int days) { return plusNonBusinessDays(time, -days); } /** - * Subtracts a specified number of non-business days to an input date. Subtracting negative days is equivalent to adding days. + * Subtracts a specified number of non-business days to an input time. Subtracting negative days is equivalent to adding days. + * + * Day subtractions are not always 24 hours. The resultant time will have the same local time as the input time, + * as determined by the calendar's time zone. This accounts for Daylight Savings Time. + * For example, 2023-11-05 has a daylight savings time adjustment, + * so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference. + * + * The resultant time will have the same time zone as the calendar. This could be different than the + * time zone of the input {@link ZonedDateTime}. * * @param time time * @param days number of days to add. @@ -1702,7 +1768,7 @@ public LocalDate minusNonBusinessDays(final Instant time, final int days) { * @throws RequirementFailure if the input is null * @throws InvalidDateException if the date is not in the valid range */ - public LocalDate minusNonBusinessDays(final ZonedDateTime time, final int days) { + public ZonedDateTime minusNonBusinessDays(final ZonedDateTime time, final int days) { return plusNonBusinessDays(time, -days); } diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java index 8803a15cf7b..9c8ad2639ff 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendar.java @@ -88,8 +88,6 @@ public String toString() { // region Arithmetic - //TODO: should the add/subtract methods on Instants or ZDT return times of LocalDates? - /** * Adds a specified number of days to an input date. Adding negative days is equivalent to subtracting days. * @@ -120,27 +118,43 @@ public LocalDate plusDays(final String date, final int days) { /** * Adds a specified number of days to an input time. Adding negative days is equivalent to subtracting days. * + * Day additions are not always 24 hours. The resultant time will have the same local time as the input time, + * as determined by the calendar's time zone. This accounts for Daylight Savings Time. + * For example, 2023-11-05 has a daylight savings time adjustment, + * so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference. + * * @param time time * @param days number of days to add - * @return {@code days} days after {@code time} + * @return {@code days} days after {@code time}. * @throws RequirementFailure if the input is null */ - public LocalDate plusDays(final Instant time, final int days) { + public Instant plusDays(final Instant time, final int days) { Require.neqNull(time, "time"); - return plusDays(DateTimeUtils.toLocalDate(time, timeZone), days); + return plusDays(DateTimeUtils.toZonedDateTime(time, timeZone), days).toInstant(); } /** * Adds a specified number of days to an input time. Adding negative days is equivalent to subtracting days. * + * Day additions are not always 24 hours. The resultant time will have the same local time as the input time, + * as determined by the calendar's time zone. This accounts for Daylight Savings Time. + * For example, 2023-11-05 has a daylight savings time adjustment, + * so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference. + * + * The resultant time will have the same time zone as the calendar. This could be different than the + * time zone of the input {@link ZonedDateTime}. + * * @param time time * @param days number of days to add * @return {@code days} days after {@code time} * @throws RequirementFailure if the input is null */ - public LocalDate plusDays(final ZonedDateTime time, final int days) { + public ZonedDateTime plusDays(final ZonedDateTime time, final int days) { Require.neqNull(time, "time"); - return plusDays(time.toInstant(), days); + final ZonedDateTime zdt = time.withZoneSameInstant(timeZone); + return plusDays(zdt.toLocalDate(), days) + .atTime(zdt.toLocalTime()) + .atZone(timeZone); } /** @@ -173,27 +187,40 @@ public LocalDate minusDays(final String date, final int days) { /** * Subtracts a specified number of days to an input time. Subtracting negative days is equivalent to adding days. * + * Day subtractions are not always 24 hours. The resultant time will have the same local time as the input time, + * as determined by the calendar's time zone. This accounts for Daylight Savings Time. + * For example, 2023-11-05 has a daylight savings time adjustment, + * so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference. + * * @param time time * @param days number of days to subtract * @return {@code days} days after {@code time} * @throws RequirementFailure if the input is null */ - public LocalDate minusDays(final Instant time, final int days) { + public Instant minusDays(final Instant time, final int days) { Require.neqNull(time, "time"); - return minusDays(DateTimeUtils.toLocalDate(time, timeZone), days); + return plusDays(time, -days); } /** * Subtracts a specified number of days to an input time. Subtracting negative days is equivalent to adding days. * + * Day subtractions are not always 24 hours. The resultant time will have the same local time as the input time, + * as determined by the calendar's time zone. This accounts for Daylight Savings Time. + * For example, 2023-11-05 has a daylight savings time adjustment, + * so '2023-11-04T14:00 ET' plus 1 day will result in '2023-11-05T15:00 ET', which is a 25-hour difference. + * + * The resultant time will have the same time zone as the calendar. This could be different than the + * time zone of the input {@link ZonedDateTime}. + * * @param time time * @param days number of days to subtract * @return {@code days} days after {@code time} * @throws RequirementFailure if the input is null */ - public LocalDate minusDays(final ZonedDateTime time, final int days) { + public ZonedDateTime minusDays(final ZonedDateTime time, final int days) { Require.neqNull(time, "time"); - return minusDays(time.toInstant(), days); + return plusDays(time, -days); } /** diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java index 42a83007b54..5d5bd9ce44e 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java @@ -1015,64 +1015,83 @@ public void testPlusBusinessDays() { // 2023-07-14 normal day // 2023-07-15 normal day + final ZoneId timeZone2 = ZoneId.of("America/New_York"); LocalDate d = LocalDate.of(2023,7,3); String s = d.toString(); - ZonedDateTime z = d.atTime(1,24).atZone(timeZone); + ZonedDateTime z = d.atTime(6,24).atZone(timeZone2); Instant i = z.toInstant(); assertEquals(d,bCalendar.plusBusinessDays(d, 0)); assertEquals(d,bCalendar.plusBusinessDays(s, 0)); - assertEquals(d,bCalendar.plusBusinessDays(z, 0)); - assertEquals(d,bCalendar.plusBusinessDays(i, 0)); - - assertEquals(LocalDate.of(2023,7,6),bCalendar.plusBusinessDays(d, 1)); - assertEquals(LocalDate.of(2023,7,6),bCalendar.plusBusinessDays(s, 1)); - assertEquals(LocalDate.of(2023,7,6),bCalendar.plusBusinessDays(z, 1)); - assertEquals(LocalDate.of(2023,7,6),bCalendar.plusBusinessDays(i, 1)); - - assertEquals(LocalDate.of(2023,7,7),bCalendar.plusBusinessDays(d, 2)); - assertEquals(LocalDate.of(2023,7,7),bCalendar.plusBusinessDays(s, 2)); - assertEquals(LocalDate.of(2023,7,7),bCalendar.plusBusinessDays(z, 2)); - assertEquals(LocalDate.of(2023,7,7),bCalendar.plusBusinessDays(i, 2)); - - assertEquals(LocalDate.of(2023,7,14),bCalendar.plusBusinessDays(d, 7)); - assertEquals(LocalDate.of(2023,7,14),bCalendar.plusBusinessDays(s, 7)); - assertEquals(LocalDate.of(2023,7,14),bCalendar.plusBusinessDays(z, 7)); - assertEquals(LocalDate.of(2023,7,14),bCalendar.plusBusinessDays(i, 7)); + assertEquals(z.withZoneSameInstant(timeZone),bCalendar.plusBusinessDays(z, 0)); + assertEquals(i,bCalendar.plusBusinessDays(i, 0)); + + final LocalDate d2 = LocalDate.of(2023,7,6); + final Instant i2 = d2.atTime(6, 24).atZone(timeZone2).toInstant(); + final ZonedDateTime z2 = d2.atTime(6, 24).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d2,bCalendar.plusBusinessDays(d, 1)); + assertEquals(d2,bCalendar.plusBusinessDays(s, 1)); + assertEquals(z2,bCalendar.plusBusinessDays(z, 1)); + assertEquals(i2,bCalendar.plusBusinessDays(i, 1)); + + final LocalDate d3 = LocalDate.of(2023,7,7); + final Instant i3 = d3.atTime(6, 24).atZone(timeZone2).toInstant(); + final ZonedDateTime z3 = d3.atTime(6, 24).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d3,bCalendar.plusBusinessDays(d, 2)); + assertEquals(d3,bCalendar.plusBusinessDays(s, 2)); + assertEquals(z3,bCalendar.plusBusinessDays(z, 2)); + assertEquals(i3,bCalendar.plusBusinessDays(i, 2)); + + final LocalDate d4 = LocalDate.of(2023,7,14); + final Instant i4 = d4.atTime(6, 24).atZone(timeZone2).toInstant(); + final ZonedDateTime z4 = d4.atTime(6, 24).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d4,bCalendar.plusBusinessDays(d, 7)); + assertEquals(d4,bCalendar.plusBusinessDays(s, 7)); + assertEquals(z4,bCalendar.plusBusinessDays(z, 7)); + assertEquals(i4,bCalendar.plusBusinessDays(i, 7)); d = LocalDate.of(2023,7,14); s = d.toString(); - z = d.atTime(1,24).atZone(timeZone); + z = d.atTime(6,25).atZone(timeZone2); i = z.toInstant(); assertEquals(d,bCalendar.plusBusinessDays(d, 0)); assertEquals(d,bCalendar.plusBusinessDays(s, 0)); - assertEquals(d,bCalendar.plusBusinessDays(z, 0)); - assertEquals(d,bCalendar.plusBusinessDays(i, 0)); - - assertEquals(LocalDate.of(2023,7,11),bCalendar.plusBusinessDays(d, -1)); - assertEquals(LocalDate.of(2023,7,11),bCalendar.plusBusinessDays(s, -1)); - assertEquals(LocalDate.of(2023,7,11),bCalendar.plusBusinessDays(z, -1)); - assertEquals(LocalDate.of(2023,7,11),bCalendar.plusBusinessDays(i, -1)); - - assertEquals(LocalDate.of(2023,7,10),bCalendar.plusBusinessDays(d, -2)); - assertEquals(LocalDate.of(2023,7,10),bCalendar.plusBusinessDays(s, -2)); - assertEquals(LocalDate.of(2023,7,10),bCalendar.plusBusinessDays(z, -2)); - assertEquals(LocalDate.of(2023,7,10),bCalendar.plusBusinessDays(i, -2)); - - assertEquals(LocalDate.of(2023,7,3),bCalendar.plusBusinessDays(d, -7)); - assertEquals(LocalDate.of(2023,7,3),bCalendar.plusBusinessDays(s, -7)); - assertEquals(LocalDate.of(2023,7,3),bCalendar.plusBusinessDays(z, -7)); - assertEquals(LocalDate.of(2023,7,3),bCalendar.plusBusinessDays(i, -7)); + assertEquals(z.withZoneSameInstant(timeZone),bCalendar.plusBusinessDays(z, 0)); + assertEquals(i,bCalendar.plusBusinessDays(i, 0)); + + final LocalDate d5 = LocalDate.of(2023,7,11); + final Instant i5 = d5.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z5 = d5.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d5,bCalendar.plusBusinessDays(d, -1)); + assertEquals(d5,bCalendar.plusBusinessDays(s, -1)); + assertEquals(z5,bCalendar.plusBusinessDays(z, -1)); + assertEquals(i5,bCalendar.plusBusinessDays(i, -1)); + + final LocalDate d6 = LocalDate.of(2023,7,10); + final Instant i6 = d6.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z6 = d6.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d6,bCalendar.plusBusinessDays(d, -2)); + assertEquals(d6,bCalendar.plusBusinessDays(s, -2)); + assertEquals(z6,bCalendar.plusBusinessDays(z, -2)); + assertEquals(i6,bCalendar.plusBusinessDays(i, -2)); + + final LocalDate d7 = LocalDate.of(2023,7,3); + final Instant i7 = d7.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z7 = d7.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d7,bCalendar.plusBusinessDays(d, -7)); + assertEquals(d7,bCalendar.plusBusinessDays(s, -7)); + assertEquals(z7,bCalendar.plusBusinessDays(z, -7)); + assertEquals(i7,bCalendar.plusBusinessDays(i, -7)); d = LocalDate.of(2023,7,4); s = d.toString(); - z = d.atTime(1,24).atZone(timeZone); + z = d.atTime(6,24).atZone(timeZone2); i = z.toInstant(); assertNull(bCalendar.plusBusinessDays(d, 0)); assertNull(bCalendar.plusBusinessDays(s, 0)); - assertNull(bCalendar.plusBusinessDays(z, 0)); + assertNull(bCalendar.plusBusinessDays(z.withZoneSameInstant(timeZone), 0)); assertNull(bCalendar.plusBusinessDays(i, 0)); } @@ -1091,59 +1110,78 @@ public void testMinusBusinessDays() { // 2023-07-14 normal day // 2023-07-15 normal day + final ZoneId timeZone2 = ZoneId.of("America/New_York"); LocalDate d = LocalDate.of(2023,7,3); String s = d.toString(); - ZonedDateTime z = d.atTime(1,24).atZone(timeZone); + ZonedDateTime z = d.atTime(6,25).atZone(timeZone2); Instant i = z.toInstant(); assertEquals(d,bCalendar.minusBusinessDays(d, 0)); assertEquals(d,bCalendar.minusBusinessDays(s, 0)); - assertEquals(d,bCalendar.minusBusinessDays(z, 0)); - assertEquals(d,bCalendar.minusBusinessDays(i, 0)); - - assertEquals(LocalDate.of(2023,7,6),bCalendar.minusBusinessDays(d, -1)); - assertEquals(LocalDate.of(2023,7,6),bCalendar.minusBusinessDays(s, -1)); - assertEquals(LocalDate.of(2023,7,6),bCalendar.minusBusinessDays(z, -1)); - assertEquals(LocalDate.of(2023,7,6),bCalendar.minusBusinessDays(i, -1)); - - assertEquals(LocalDate.of(2023,7,7),bCalendar.minusBusinessDays(d, -2)); - assertEquals(LocalDate.of(2023,7,7),bCalendar.minusBusinessDays(s, -2)); - assertEquals(LocalDate.of(2023,7,7),bCalendar.minusBusinessDays(z, -2)); - assertEquals(LocalDate.of(2023,7,7),bCalendar.minusBusinessDays(i, -2)); - - assertEquals(LocalDate.of(2023,7,14),bCalendar.minusBusinessDays(d, -7)); - assertEquals(LocalDate.of(2023,7,14),bCalendar.minusBusinessDays(s, -7)); - assertEquals(LocalDate.of(2023,7,14),bCalendar.minusBusinessDays(z, -7)); - assertEquals(LocalDate.of(2023,7,14),bCalendar.minusBusinessDays(i, -7)); + assertEquals(z.withZoneSameInstant(timeZone),bCalendar.minusBusinessDays(z, 0)); + assertEquals(i,bCalendar.minusBusinessDays(i, 0)); + + final LocalDate d1 = LocalDate.of(2023,7,6); + final Instant i1 = d1.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z1 = d1.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d1,bCalendar.minusBusinessDays(d, -1)); + assertEquals(d1,bCalendar.minusBusinessDays(s, -1)); + assertEquals(z1,bCalendar.minusBusinessDays(z, -1)); + assertEquals(i1,bCalendar.minusBusinessDays(i, -1)); + + final LocalDate d2 = LocalDate.of(2023,7,7); + final Instant i2 = d2.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z2 = d2.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d2,bCalendar.minusBusinessDays(d, -2)); + assertEquals(d2,bCalendar.minusBusinessDays(s, -2)); + assertEquals(z2,bCalendar.minusBusinessDays(z, -2)); + assertEquals(i2,bCalendar.minusBusinessDays(i, -2)); + + final LocalDate d3 = LocalDate.of(2023,7,14); + final Instant i3 = d3.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z3 = d3.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d3,bCalendar.minusBusinessDays(d, -7)); + assertEquals(d3,bCalendar.minusBusinessDays(s, -7)); + assertEquals(z3,bCalendar.minusBusinessDays(z, -7)); + assertEquals(i3,bCalendar.minusBusinessDays(i, -7)); d = LocalDate.of(2023,7,14); s = d.toString(); - z = d.atTime(1,24).atZone(timeZone); + z = d.atTime(6,25).atZone(timeZone2); i = z.toInstant(); assertEquals(d,bCalendar.minusBusinessDays(d, 0)); assertEquals(d,bCalendar.minusBusinessDays(s, 0)); - assertEquals(d,bCalendar.minusBusinessDays(z, 0)); - assertEquals(d,bCalendar.minusBusinessDays(i, 0)); - - assertEquals(LocalDate.of(2023,7,11),bCalendar.minusBusinessDays(d, 1)); - assertEquals(LocalDate.of(2023,7,11),bCalendar.minusBusinessDays(s, 1)); - assertEquals(LocalDate.of(2023,7,11),bCalendar.minusBusinessDays(z, 1)); - assertEquals(LocalDate.of(2023,7,11),bCalendar.minusBusinessDays(i, 1)); - - assertEquals(LocalDate.of(2023,7,10),bCalendar.minusBusinessDays(d, 2)); - assertEquals(LocalDate.of(2023,7,10),bCalendar.minusBusinessDays(s, 2)); - assertEquals(LocalDate.of(2023,7,10),bCalendar.minusBusinessDays(z, 2)); - assertEquals(LocalDate.of(2023,7,10),bCalendar.minusBusinessDays(i, 2)); - - assertEquals(LocalDate.of(2023,7,3),bCalendar.minusBusinessDays(d, 7)); - assertEquals(LocalDate.of(2023,7,3),bCalendar.minusBusinessDays(s, 7)); - assertEquals(LocalDate.of(2023,7,3),bCalendar.minusBusinessDays(z, 7)); - assertEquals(LocalDate.of(2023,7,3),bCalendar.minusBusinessDays(i, 7)); + assertEquals(z.withZoneSameInstant(timeZone),bCalendar.minusBusinessDays(z, 0)); + assertEquals(i,bCalendar.minusBusinessDays(i, 0)); + + final LocalDate d4 = LocalDate.of(2023,7,11); + final Instant i4 = d4.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z4 = d4.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d4,bCalendar.minusBusinessDays(d, 1)); + assertEquals(d4,bCalendar.minusBusinessDays(s, 1)); + assertEquals(z4,bCalendar.minusBusinessDays(z, 1)); + assertEquals(i4,bCalendar.minusBusinessDays(i, 1)); + + final LocalDate d5 = LocalDate.of(2023,7,10); + final Instant i5 = d5.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z5 = d5.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d5,bCalendar.minusBusinessDays(d, 2)); + assertEquals(d5,bCalendar.minusBusinessDays(s, 2)); + assertEquals(z5,bCalendar.minusBusinessDays(z, 2)); + assertEquals(i5,bCalendar.minusBusinessDays(i, 2)); + + final LocalDate d6 = LocalDate.of(2023,7,3); + final Instant i6 = d6.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z6 = d6.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d6,bCalendar.minusBusinessDays(d, 7)); + assertEquals(d6,bCalendar.minusBusinessDays(s, 7)); + assertEquals(z6,bCalendar.minusBusinessDays(z, 7)); + assertEquals(i6,bCalendar.minusBusinessDays(i, 7)); d = LocalDate.of(2023,7,4); s = d.toString(); - z = d.atTime(1,24).atZone(timeZone); + z = d.atTime(6,24).atZone(timeZone2); i = z.toInstant(); assertNull(bCalendar.minusBusinessDays(d, 0)); @@ -1167,9 +1205,10 @@ public void testPlusNonBusinessDays() { // 2023-07-14 normal day // 2023-07-15 normal day + final ZoneId timeZone2 = ZoneId.of("America/New_York"); LocalDate d = LocalDate.of(2023,7,3); String s = d.toString(); - ZonedDateTime z = d.atTime(1,24).atZone(timeZone); + ZonedDateTime z = d.atTime(6,25).atZone(timeZone2); Instant i = z.toInstant(); assertNull(bCalendar.plusNonBusinessDays(d, 0)); @@ -1177,24 +1216,33 @@ public void testPlusNonBusinessDays() { assertNull(bCalendar.plusNonBusinessDays(z, 0)); assertNull(bCalendar.plusNonBusinessDays(i, 0)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(d, 1)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(s, 1)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(z, 1)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(i, 1)); - - assertEquals(LocalDate.of(2023,7,5),bCalendar.plusNonBusinessDays(d, 2)); - assertEquals(LocalDate.of(2023,7,5),bCalendar.plusNonBusinessDays(s, 2)); - assertEquals(LocalDate.of(2023,7,5),bCalendar.plusNonBusinessDays(z, 2)); - assertEquals(LocalDate.of(2023,7,5),bCalendar.plusNonBusinessDays(i, 2)); - - assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(d, 4)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(s, 4)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(z, 4)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(i, 4)); + final LocalDate d1 = LocalDate.of(2023,7,4); + final Instant i1 = d1.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z1 = d1.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d1,bCalendar.plusNonBusinessDays(d, 1)); + assertEquals(d1,bCalendar.plusNonBusinessDays(s, 1)); + assertEquals(z1,bCalendar.plusNonBusinessDays(z, 1)); + assertEquals(i1,bCalendar.plusNonBusinessDays(i, 1)); + + final LocalDate d2 = LocalDate.of(2023,7,5); + final Instant i2 = d2.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z2 = d2.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d2,bCalendar.plusNonBusinessDays(d, 2)); + assertEquals(d2,bCalendar.plusNonBusinessDays(s, 2)); + assertEquals(z2,bCalendar.plusNonBusinessDays(z, 2)); + assertEquals(i2,bCalendar.plusNonBusinessDays(i, 2)); + + final LocalDate d3 = LocalDate.of(2023,7,13); + final Instant i3 = d3.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z3 = d3.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d3,bCalendar.plusNonBusinessDays(d, 4)); + assertEquals(d3,bCalendar.plusNonBusinessDays(s, 4)); + assertEquals(z3,bCalendar.plusNonBusinessDays(z, 4)); + assertEquals(i3,bCalendar.plusNonBusinessDays(i, 4)); d = LocalDate.of(2023,7,14); s = d.toString(); - z = d.atTime(1,24).atZone(timeZone); + z = d.atTime(6,25).atZone(timeZone2); i = z.toInstant(); assertNull(bCalendar.plusNonBusinessDays(d, 0)); @@ -1202,24 +1250,33 @@ public void testPlusNonBusinessDays() { assertNull(bCalendar.plusNonBusinessDays(z, 0)); assertNull(bCalendar.plusNonBusinessDays(i, 0)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(d, -1)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(s, -1)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(z, -1)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.plusNonBusinessDays(i, -1)); - - assertEquals(LocalDate.of(2023,7,12),bCalendar.plusNonBusinessDays(d, -2)); - assertEquals(LocalDate.of(2023,7,12),bCalendar.plusNonBusinessDays(s, -2)); - assertEquals(LocalDate.of(2023,7,12),bCalendar.plusNonBusinessDays(z, -2)); - assertEquals(LocalDate.of(2023,7,12),bCalendar.plusNonBusinessDays(i, -2)); - - assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(d, -4)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(s, -4)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(z, -4)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.plusNonBusinessDays(i, -4)); + final LocalDate d4 = LocalDate.of(2023,7,13); + final Instant i4 = d4.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z4 = d4.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d4,bCalendar.plusNonBusinessDays(d, -1)); + assertEquals(d4,bCalendar.plusNonBusinessDays(s, -1)); + assertEquals(z4,bCalendar.plusNonBusinessDays(z, -1)); + assertEquals(i4,bCalendar.plusNonBusinessDays(i, -1)); + + final LocalDate d5 = LocalDate.of(2023,7,12); + final Instant i5 = d5.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z5 = d5.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d5,bCalendar.plusNonBusinessDays(d, -2)); + assertEquals(d5,bCalendar.plusNonBusinessDays(s, -2)); + assertEquals(z5,bCalendar.plusNonBusinessDays(z, -2)); + assertEquals(i5,bCalendar.plusNonBusinessDays(i, -2)); + + final LocalDate d6 = LocalDate.of(2023,7,4); + final Instant i6 = d6.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z6 = d6.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d6,bCalendar.plusNonBusinessDays(d, -4)); + assertEquals(d6,bCalendar.plusNonBusinessDays(s, -4)); + assertEquals(z6,bCalendar.plusNonBusinessDays(z, -4)); + assertEquals(i6,bCalendar.plusNonBusinessDays(i, -4)); d = LocalDate.of(2023,7,4); s = d.toString(); - z = d.atTime(1,24).atZone(timeZone); + z = d.atTime(6,25).atZone(timeZone2); i = z.toInstant(); assertNull(bCalendar.plusNonBusinessDays(d, 0)); @@ -1243,9 +1300,10 @@ public void testMinusNonBusinessDays() { // 2023-07-14 normal day // 2023-07-15 normal day + final ZoneId timeZone2 = ZoneId.of("America/New_York"); LocalDate d = LocalDate.of(2023,7,3); String s = d.toString(); - ZonedDateTime z = d.atTime(1,24).atZone(timeZone); + ZonedDateTime z = d.atTime(6,25).atZone(timeZone2); Instant i = z.toInstant(); assertNull(bCalendar.minusNonBusinessDays(d, 0)); @@ -1253,24 +1311,33 @@ public void testMinusNonBusinessDays() { assertNull(bCalendar.minusNonBusinessDays(z, 0)); assertNull(bCalendar.minusNonBusinessDays(i, 0)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(d, -1)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(s, -1)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(z, -1)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(i, -1)); - - assertEquals(LocalDate.of(2023,7,5),bCalendar.minusNonBusinessDays(d, -2)); - assertEquals(LocalDate.of(2023,7,5),bCalendar.minusNonBusinessDays(s, -2)); - assertEquals(LocalDate.of(2023,7,5),bCalendar.minusNonBusinessDays(z, -2)); - assertEquals(LocalDate.of(2023,7,5),bCalendar.minusNonBusinessDays(i, -2)); - - assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(d, -4)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(s, -4)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(z, -4)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(i, -4)); + final LocalDate d1 = LocalDate.of(2023,7,4); + final Instant i1 = d1.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z1 = d1.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d1,bCalendar.minusNonBusinessDays(d, -1)); + assertEquals(d1,bCalendar.minusNonBusinessDays(s, -1)); + assertEquals(z1,bCalendar.minusNonBusinessDays(z, -1)); + assertEquals(i1,bCalendar.minusNonBusinessDays(i, -1)); + + final LocalDate d2 = LocalDate.of(2023,7,5); + final Instant i2 = d2.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z2 = d2.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d2,bCalendar.minusNonBusinessDays(d, -2)); + assertEquals(d2,bCalendar.minusNonBusinessDays(s, -2)); + assertEquals(z2,bCalendar.minusNonBusinessDays(z, -2)); + assertEquals(i2,bCalendar.minusNonBusinessDays(i, -2)); + + final LocalDate d3 = LocalDate.of(2023,7,13); + final Instant i3 = d3.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z3 = d3.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d3,bCalendar.minusNonBusinessDays(d, -4)); + assertEquals(d3,bCalendar.minusNonBusinessDays(s, -4)); + assertEquals(z3,bCalendar.minusNonBusinessDays(z, -4)); + assertEquals(i3,bCalendar.minusNonBusinessDays(i, -4)); d = LocalDate.of(2023,7,14); s = d.toString(); - z = d.atTime(1,24).atZone(timeZone); + z = d.atTime(6,25).atZone(timeZone2); i = z.toInstant(); assertNull(bCalendar.minusNonBusinessDays(d, 0)); @@ -1278,24 +1345,33 @@ public void testMinusNonBusinessDays() { assertNull(bCalendar.minusNonBusinessDays(z, 0)); assertNull(bCalendar.minusNonBusinessDays(i, 0)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(d, 1)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(s, 1)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(z, 1)); - assertEquals(LocalDate.of(2023,7,13),bCalendar.minusNonBusinessDays(i, 1)); - - assertEquals(LocalDate.of(2023,7,12),bCalendar.minusNonBusinessDays(d, 2)); - assertEquals(LocalDate.of(2023,7,12),bCalendar.minusNonBusinessDays(s, 2)); - assertEquals(LocalDate.of(2023,7,12),bCalendar.minusNonBusinessDays(z, 2)); - assertEquals(LocalDate.of(2023,7,12),bCalendar.minusNonBusinessDays(i, 2)); - - assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(d, 4)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(s, 4)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(z, 4)); - assertEquals(LocalDate.of(2023,7,4),bCalendar.minusNonBusinessDays(i, 4)); + final LocalDate d4 = LocalDate.of(2023,7,13); + final Instant i4 = d4.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z4 = d4.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d4,bCalendar.minusNonBusinessDays(d, 1)); + assertEquals(d4,bCalendar.minusNonBusinessDays(s, 1)); + assertEquals(z4,bCalendar.minusNonBusinessDays(z, 1)); + assertEquals(i4,bCalendar.minusNonBusinessDays(i, 1)); + + final LocalDate d5 = LocalDate.of(2023,7,12); + final Instant i5 = d5.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z5 = d5.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d5,bCalendar.minusNonBusinessDays(d, 2)); + assertEquals(d5,bCalendar.minusNonBusinessDays(s, 2)); + assertEquals(z5,bCalendar.minusNonBusinessDays(z, 2)); + assertEquals(i5,bCalendar.minusNonBusinessDays(i, 2)); + + final LocalDate d6 = LocalDate.of(2023,7,4); + final Instant i6 = d6.atTime(6, 25).atZone(timeZone2).toInstant(); + final ZonedDateTime z6 = d6.atTime(6, 25).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d6,bCalendar.minusNonBusinessDays(d, 4)); + assertEquals(d6,bCalendar.minusNonBusinessDays(s, 4)); + assertEquals(z6,bCalendar.minusNonBusinessDays(z, 4)); + assertEquals(i6,bCalendar.minusNonBusinessDays(i, 4)); d = LocalDate.of(2023,7,4); s = d.toString(); - z = d.atTime(1,24).atZone(timeZone); + z = d.atTime(6,24).atZone(timeZone2); i = z.toInstant(); assertNull(bCalendar.minusNonBusinessDays(d, 0)); diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java index 7a6255b7b4e..59843706e94 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java @@ -32,51 +32,87 @@ public void testToString() { } public void testPlusDays() { - final LocalDate d = LocalDate.of(2023,2,3); + final ZoneId timeZone2 = ZoneId.of("America/New_York"); + final LocalDate d = LocalDate.of(2023, 2, 3); final String s = "2023-02-03"; - final ZonedDateTime z = d.atTime(1,24).atZone(timeZone); - final Instant i = z.toInstant(); - - assertEquals(d, calendar.plusDays(d,0)); - assertEquals(d, calendar.plusDays(s,0)); - assertEquals(d, calendar.plusDays(z,0)); - assertEquals(d, calendar.plusDays(i,0)); - - final LocalDate d2 = LocalDate.of(2023,2,5); - assertEquals(d2, calendar.plusDays(d,2)); - assertEquals(d2, calendar.plusDays(s,2)); - assertEquals(d2, calendar.plusDays(z,2)); - assertEquals(d2, calendar.plusDays(i,2)); - - final LocalDate d3 = LocalDate.of(2023,2,1); - assertEquals(d3, calendar.plusDays(d,-2)); - assertEquals(d3, calendar.plusDays(s,-2)); - assertEquals(d3, calendar.plusDays(z,-2)); - assertEquals(d3, calendar.plusDays(i,-2)); + final ZonedDateTime z = d.atTime(1, 24).atZone(timeZone2); + final Instant i = d.atTime(1, 24).atZone(timeZone2).toInstant(); + + assertEquals(d, calendar.plusDays(d, 0)); + assertEquals(d, calendar.plusDays(s, 0)); + assertEquals(z.withZoneSameInstant(timeZone), calendar.plusDays(z, 0)); + assertEquals(i, calendar.plusDays(i, 0)); + + final LocalDate d2 = LocalDate.of(2023, 2, 5); + final Instant i2 = d2.atTime(1, 24).atZone(timeZone2).toInstant(); + final ZonedDateTime z2 = d2.atTime(1, 24).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d2, calendar.plusDays(d, 2)); + assertEquals(d2, calendar.plusDays(s, 2)); + assertEquals(z2, calendar.plusDays(z, 2)); + assertEquals(i2, calendar.plusDays(i, 2)); + assertEquals(2 * DateTimeUtils.DAY, DateTimeUtils.minus(i2, i)); + assertEquals(2 * DateTimeUtils.DAY, DateTimeUtils.minus(z2, z)); + + final LocalDate d3 = LocalDate.of(2023, 2, 1); + final Instant i3 = d3.atTime(1, 24).atZone(timeZone2).toInstant(); + final ZonedDateTime z3 = d3.atTime(z.toLocalTime()).atZone(timeZone2).withZoneSameInstant(timeZone); + assertEquals(d3, calendar.plusDays(d, -2)); + assertEquals(d3, calendar.plusDays(s, -2)); + assertEquals(z3, calendar.plusDays(z, -2)); + assertEquals(i3, calendar.plusDays(i, -2)); + assertEquals(-2 * DateTimeUtils.DAY, DateTimeUtils.minus(i3, i)); + assertEquals(-2 * DateTimeUtils.DAY, DateTimeUtils.minus(z3, z)); + + // Test Daylight Savings Time + final ZonedDateTime zDST1 = ZonedDateTime.of(2023, 11, 4, 14, 1, 2, 3, timeZone).withZoneSameInstant(timeZone2); + final ZonedDateTime zDST2 = ZonedDateTime.of(2023, 11, 5, 14, 1, 2, 3, timeZone); + final Instant iDST1 = ZonedDateTime.of(2023, 11, 4, 14, 1, 2, 3, timeZone).toInstant(); + final Instant iDST2 = ZonedDateTime.of(2023, 11, 5, 14, 1, 2, 3, timeZone).toInstant(); + + assertEquals(zDST2, calendar.plusDays(zDST1, 1)); + assertEquals(iDST2, calendar.plusDays(iDST1, 1)); + assertEquals(DateTimeUtils.DAY + DateTimeUtils.HOUR, DateTimeUtils.minus(zDST2, zDST1)); + assertEquals(DateTimeUtils.DAY + DateTimeUtils.HOUR, DateTimeUtils.minus(iDST2, iDST1)); } public void testMinusDays() { - final LocalDate d = LocalDate.of(2023,2,3); + final ZoneId timeZone2 = ZoneId.of("America/New_York"); + final LocalDate d = LocalDate.of(2023, 2, 3); final String s = "2023-02-03"; - final ZonedDateTime z = d.atTime(1,24).atZone(timeZone); - final Instant i = z.toInstant(); + final ZonedDateTime z = d.atTime(1, 24).atZone(timeZone2); + final Instant i = d.atTime(1, 24).atZone(timeZone2).toInstant(); assertEquals(d, calendar.minusDays(d,0)); assertEquals(d, calendar.minusDays(s,0)); - assertEquals(d, calendar.minusDays(z,0)); - assertEquals(d, calendar.minusDays(i,0)); + assertEquals(z.withZoneSameInstant(timeZone), calendar.minusDays(z,0)); + assertEquals(i, calendar.minusDays(i,0)); final LocalDate d2 = LocalDate.of(2023,2,1); + final Instant i2 = d2.atTime(1, 24).atZone(timeZone2).toInstant(); + final ZonedDateTime z2 = d2.atTime(1, 24).atZone(timeZone2).withZoneSameInstant(timeZone); assertEquals(d2, calendar.minusDays(d,2)); assertEquals(d2, calendar.minusDays(s,2)); - assertEquals(d2, calendar.minusDays(z,2)); - assertEquals(d2, calendar.minusDays(i,2)); + assertEquals(z2, calendar.minusDays(z,2)); + assertEquals(i2, calendar.minusDays(i,2)); - final LocalDate d3 = LocalDate.of(2023,2,5); + final LocalDate d3 = LocalDate.of(2023, 2, 5); + final Instant i3 = d3.atTime(1, 24).atZone(timeZone2).toInstant(); + final ZonedDateTime z3 = d3.atTime(z.toLocalTime()).atZone(timeZone2).withZoneSameInstant(timeZone); assertEquals(d3, calendar.minusDays(d,-2)); assertEquals(d3, calendar.minusDays(s,-2)); - assertEquals(d3, calendar.minusDays(z,-2)); - assertEquals(d3, calendar.minusDays(i,-2)); + assertEquals(z3, calendar.minusDays(z,-2)); + assertEquals(i3, calendar.minusDays(i,-2)); + + // Test Daylight Savings Time + final ZonedDateTime zDST1 = ZonedDateTime.of(2023, 11, 4, 14, 1, 2, 3, timeZone); + final ZonedDateTime zDST2 = ZonedDateTime.of(2023, 11, 5, 14, 1, 2, 3, timeZone).withZoneSameInstant(timeZone2); + final Instant iDST1 = ZonedDateTime.of(2023, 11, 4, 14, 1, 2, 3, timeZone).toInstant(); + final Instant iDST2 = ZonedDateTime.of(2023, 11, 5, 14, 1, 2, 3, timeZone).toInstant(); + + assertEquals(zDST1, calendar.minusDays(zDST2, 1)); + assertEquals(iDST1, calendar.minusDays(iDST2, 1)); + assertEquals(DateTimeUtils.DAY + DateTimeUtils.HOUR, DateTimeUtils.minus(zDST2, zDST1)); + assertEquals(DateTimeUtils.DAY + DateTimeUtils.HOUR, DateTimeUtils.minus(iDST2, iDST1)); } public void testCurrentDate() { From ae26972001584c869406906989cbb0f80e36577a Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 31 Oct 2023 14:48:45 -0600 Subject: [PATCH 050/150] Renamed todayDate to todayLocalDate. (partial commit) --- .../java/io/deephaven/time/DateTimeUtils.java | 10 +++++----- .../io/deephaven/time/TestDateTimeUtils.java | 4 ++-- .../time/calendar/TestBusinessCalendar.java | 16 ++++++++-------- .../io/deephaven/time/calendar/TestCalendar.java | 8 ++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java b/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java index 595afc516ed..776d83e5184 100644 --- a/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java +++ b/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java @@ -482,7 +482,7 @@ public static String today() { } /** - * Provides the current date string according to the {@link #currentClock() current clock}. Under most + * Provides the current date according to the {@link #currentClock() current clock}. Under most * circumstances, this method will return the date according to current system time, but during replay simulations, * this method can return the date according to replay time. * @@ -493,12 +493,12 @@ public static String today() { */ @ScriptApi @NotNull - public static LocalDate todayDate(@NotNull final ZoneId timeZone) { + public static LocalDate todayLocalDate(@NotNull final ZoneId timeZone) { return cachedCurrentDates.putIfAbsent(timeZone, CachedCurrentDate::new).getLocalDate(); } /** - * Provides the current date string according to the {@link #currentClock() current clock} and the + * Provides the current date according to the {@link #currentClock() current clock} and the * {@link ZoneId#systemDefault() default time zone}. Under most circumstances, this method will return the date * according to current system time, but during replay simulations, this method can return the date according to * replay time. @@ -510,8 +510,8 @@ public static LocalDate todayDate(@NotNull final ZoneId timeZone) { */ @ScriptApi @NotNull - public static LocalDate todayDate() { - return todayDate(DateTimeUtils.timeZone()); + public static LocalDate todayLocalDate() { + return todayLocalDate(DateTimeUtils.timeZone()); } // endregion diff --git a/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java b/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java index 09f60baf3e2..ece2b451ae7 100644 --- a/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java +++ b/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java @@ -1727,8 +1727,8 @@ public Instant instantMillis() { TestCase.assertEquals(DateTimeUtils.today(DateTimeUtils.timeZone()), DateTimeUtils.today()); TestCase.assertEquals(DateTimeUtils.toLocalDate(Instant.ofEpochSecond(0, nanos), TZ_AL), - DateTimeUtils.todayDate(TZ_AL)); - TestCase.assertEquals(DateTimeUtils.todayDate(DateTimeUtils.timeZone()), DateTimeUtils.todayDate()); + DateTimeUtils.todayLocalDate(TZ_AL)); + TestCase.assertEquals(DateTimeUtils.todayLocalDate(DateTimeUtils.timeZone()), DateTimeUtils.todayLocalDate()); } catch (Exception ex) { DateTimeUtils.setClock(initial); throw ex; diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java index 5d5bd9ce44e..cc4f90169d2 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendar.java @@ -1381,23 +1381,23 @@ public void testMinusNonBusinessDays() { } public void testFutureBusinessDate() { - assertEquals(bCalendar.plusBusinessDays(DateTimeUtils.todayDate(),3), bCalendar.futureBusinessDate(3)); - assertEquals(bCalendar.plusBusinessDays(DateTimeUtils.todayDate(),-3), bCalendar.futureBusinessDate(-3)); + assertEquals(bCalendar.plusBusinessDays(DateTimeUtils.todayLocalDate(),3), bCalendar.futureBusinessDate(3)); + assertEquals(bCalendar.plusBusinessDays(DateTimeUtils.todayLocalDate(),-3), bCalendar.futureBusinessDate(-3)); } public void testPastBusinessDate() { - assertEquals(bCalendar.minusBusinessDays(DateTimeUtils.todayDate(),3), bCalendar.pastBusinessDate(3)); - assertEquals(bCalendar.minusBusinessDays(DateTimeUtils.todayDate(),-3), bCalendar.pastBusinessDate(-3)); + assertEquals(bCalendar.minusBusinessDays(DateTimeUtils.todayLocalDate(),3), bCalendar.pastBusinessDate(3)); + assertEquals(bCalendar.minusBusinessDays(DateTimeUtils.todayLocalDate(),-3), bCalendar.pastBusinessDate(-3)); } public void testFutureNonBusinessDate() { - assertEquals(bCalendar.plusNonBusinessDays(DateTimeUtils.todayDate(),3), bCalendar.futureNonBusinessDate(3)); - assertEquals(bCalendar.plusNonBusinessDays(DateTimeUtils.todayDate(),-3), bCalendar.futureNonBusinessDate(-3)); + assertEquals(bCalendar.plusNonBusinessDays(DateTimeUtils.todayLocalDate(),3), bCalendar.futureNonBusinessDate(3)); + assertEquals(bCalendar.plusNonBusinessDays(DateTimeUtils.todayLocalDate(),-3), bCalendar.futureNonBusinessDate(-3)); } public void testPastNonBusinessDate() { - assertEquals(bCalendar.minusNonBusinessDays(DateTimeUtils.todayDate(),3), bCalendar.pastNonBusinessDate(3)); - assertEquals(bCalendar.minusNonBusinessDays(DateTimeUtils.todayDate(),-3), bCalendar.pastNonBusinessDate(-3)); + assertEquals(bCalendar.minusNonBusinessDays(DateTimeUtils.todayLocalDate(),3), bCalendar.pastNonBusinessDate(3)); + assertEquals(bCalendar.minusNonBusinessDays(DateTimeUtils.todayLocalDate(),-3), bCalendar.pastNonBusinessDate(-3)); } } diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java index 59843706e94..927cbe21557 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestCalendar.java @@ -120,13 +120,13 @@ public void testCurrentDate() { } public void testFutureDate() { - assertEquals(calendar.plusDays(DateTimeUtils.todayDate(),3), calendar.futureDate(3)); - assertEquals(calendar.plusDays(DateTimeUtils.todayDate(),-3), calendar.futureDate(-3)); + assertEquals(calendar.plusDays(DateTimeUtils.todayLocalDate(),3), calendar.futureDate(3)); + assertEquals(calendar.plusDays(DateTimeUtils.todayLocalDate(),-3), calendar.futureDate(-3)); } public void testPastDate() { - assertEquals(calendar.minusDays(DateTimeUtils.todayDate(),3), calendar.pastDate(3)); - assertEquals(calendar.minusDays(DateTimeUtils.todayDate(),-3), calendar.pastDate(-3)); + assertEquals(calendar.minusDays(DateTimeUtils.todayLocalDate(),3), calendar.pastDate(3)); + assertEquals(calendar.minusDays(DateTimeUtils.todayLocalDate(),-3), calendar.pastDate(-3)); } public void testCalendarDates() { From 54c44de432ec41b2a9c567e9c87d4855e2115413 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 31 Oct 2023 15:00:29 -0600 Subject: [PATCH 051/150] Add LocalDate arithmetic. --- .../java/io/deephaven/time/DateTimeUtils.java | 92 +++++++++++++++++++ .../io/deephaven/time/TestDateTimeUtils.java | 16 ++++ 2 files changed, 108 insertions(+) diff --git a/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java b/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java index 776d83e5184..084fad6935e 100644 --- a/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java +++ b/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java @@ -1361,6 +1361,52 @@ public static ZonedDateTime excelToZonedDateTime(final double excel, @Nullable f // region Arithmetic + /** + * Adds days to a {@link LocalDate}. + * + * @param date starting date + * @param days number of days to add + * @return {@code null} if either input is {@code null} or {@link QueryConstants#NULL_LONG}; otherwise the starting + * date plus the specified number of days + * @throws DateTimeOverflowException if the resultant date time exceeds the supported range + */ + @ScriptApi + @Nullable + public static LocalDate plus(@Nullable final LocalDate date, final long days) { + if (date == null || days == NULL_LONG) { + return null; + } + + try { + return date.plusDays(days); + } catch (Exception ex) { + throw new DateTimeOverflowException(ex); + } + } + + /** + * Adds a time period to a {@link LocalDate}. + * + * @param date starting date + * @param period time period + * @return {@code null} if either input is {@code null}; otherwise the starting + * date plus the specified time period + * @throws DateTimeOverflowException if the resultant date time exceeds the supported range + */ + @ScriptApi + @Nullable + public static LocalDate plus(@Nullable final LocalDate date, final Period period) { + if (date == null || period == null) { + return null; + } + + try { + return date.plus(period); + } catch (Exception ex) { + throw new DateTimeOverflowException(ex); + } + } + /** * Adds nanoseconds to an {@link Instant}. * @@ -1499,6 +1545,52 @@ public static ZonedDateTime plus(@Nullable final ZonedDateTime dateTime, @Nullab } } + /** + * Subtracts days from a {@link LocalDate}. + * + * @param date starting date + * @param days number of days to subtract + * @return {@code null} if either input is {@code null} or {@link QueryConstants#NULL_LONG}; otherwise the starting + * date plus the specified number of days + * @throws DateTimeOverflowException if the resultant date time exceeds the supported range + */ + @ScriptApi + @Nullable + public static LocalDate minus(@Nullable final LocalDate date, final long days) { + if (date == null || days == NULL_LONG) { + return null; + } + + try { + return date.minusDays(days); + } catch (Exception ex) { + throw new DateTimeOverflowException(ex); + } + } + + /** + * Subtracts a time period from a {@link LocalDate}. + * + * @param date starting date + * @param period time period + * @return {@code null} if either input is {@code null}; otherwise the starting + * date minus the specified time period + * @throws DateTimeOverflowException if the resultant date time exceeds the supported range + */ + @ScriptApi + @Nullable + public static LocalDate minus(@Nullable final LocalDate date, final Period period) { + if (date == null || period == null) { + return null; + } + + try { + return date.minus(period); + } catch (Exception ex) { + throw new DateTimeOverflowException(ex); + } + } + /** * Subtracts nanoseconds from an {@link Instant}. * diff --git a/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java b/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java index ece2b451ae7..3c7a724ee92 100644 --- a/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java +++ b/engine/time/src/test/java/io/deephaven/time/TestDateTimeUtils.java @@ -1899,6 +1899,14 @@ public void testUpperBinWithOffset() { DateTimeUtils.upperBin(DateTimeUtils.upperBin(zdt, second, second), second, second)); } + public void testPlusLocalDate() { + final LocalDate d = LocalDate.of(2010, 1, 2); + TestCase.assertEquals(LocalDate.of(2010, 1, 5), DateTimeUtils.plus(d, 3)); + TestCase.assertEquals(LocalDate.of(2009, 12, 30), DateTimeUtils.plus(d, -3)); + TestCase.assertEquals(LocalDate.of(2010, 1, 5), DateTimeUtils.plus(d, Period.ofDays(3))); + TestCase.assertEquals(LocalDate.of(2009, 12, 30), DateTimeUtils.plus(d, Period.ofDays(-3))); + } + public void testPlus() { final Instant instant = DateTimeUtils.parseInstant("2010-01-01T12:13:14.999123456 JP"); final ZonedDateTime zdt = DateTimeUtils.toZonedDateTime(instant, TZ_AL); @@ -2047,6 +2055,14 @@ public void testPlus() { } + public void testMinusLocalDate() { + final LocalDate d = LocalDate.of(2010, 1, 2); + TestCase.assertEquals(LocalDate.of(2009, 12, 30), DateTimeUtils.minus(d, 3)); + TestCase.assertEquals(LocalDate.of(2010, 1, 5), DateTimeUtils.minus(d, -3)); + TestCase.assertEquals(LocalDate.of(2009, 12, 30), DateTimeUtils.minus(d, Period.ofDays(3))); + TestCase.assertEquals(LocalDate.of(2010, 1, 5), DateTimeUtils.minus(d, Period.ofDays(-3))); + } + public void testMinus() { final Instant instant1 = DateTimeUtils.parseInstant("2010-01-01T12:13:14.999123456 JP"); final Instant instant2 = DateTimeUtils.parseInstant("2010-01-01T13:13:14.999123456 JP"); From 6cd75fb0c7ff9ec518d2cdb43da717ed2e572211 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 31 Oct 2023 15:30:38 -0600 Subject: [PATCH 052/150] Updating calendar configs. --- .../resources/calendar/USBANK.calendar | 676 +++++++++ .../resources/calendar/USNYSE.calendar | 1328 +++++++++++++++++ .../resources/calendar/UTC.calendar | 11 + .../resources/default_calendar_imports.txt | 2 + .../main/resources/calendar/USBANK.calendar | 1 + .../main/resources/calendar/USNYSE.calendar | 1 + .../main/resources/test_calendar_imports.txt | 2 + 7 files changed, 2021 insertions(+) create mode 100644 props/configs/out/production/resources/calendar/USBANK.calendar create mode 100644 props/configs/out/production/resources/calendar/USNYSE.calendar create mode 100644 props/configs/out/production/resources/calendar/UTC.calendar create mode 120000 props/test-configs/src/main/resources/calendar/USBANK.calendar create mode 120000 props/test-configs/src/main/resources/calendar/USNYSE.calendar diff --git a/props/configs/out/production/resources/calendar/USBANK.calendar b/props/configs/out/production/resources/calendar/USBANK.calendar new file mode 100644 index 00000000000..4ac1e49cbe9 --- /dev/null +++ b/props/configs/out/production/resources/calendar/USBANK.calendar @@ -0,0 +1,676 @@ + + + + USBANK + America/New_York + en + US + 2013-01-01 + 2034-12-25 + + United States Banking Business Calendar. + Sources: https://www.frbservices.org/about/holiday-schedules, https://www.public-holidays.us/mobile_US_EN_2029_Federal%20holidays, https://www.federalreserve.gov/aboutthefed/k8.htm, https://www.federalholidays.net/usa/federal-holidays-2022.html + Last updated 7/23/2023 + + + 09:00,17:00 + Saturday + Sunday + + + 20130101 + + + 20130121 + + + 20130218 + + + 20130527 + + + 20130704 + + + 20130902 + + + 20131014 + + + 20131111 + + + 20131128 + + + 20131225 + + + 20140101 + + + 20140120 + + + 20140217 + + + 20140526 + + + 20140704 + + + 20140901 + + + 20141013 + + + 20141111 + + + 20141127 + + + 20141225 + + + 20150101 + + + 20150119 + + + 20150216 + + + 20150525 + + + 20150907 + + + 20151012 + + + 20151111 + + + 20151126 + + + 20151225 + + + 20160101 + + + 20160118 + + + 20160215 + + + 20160530 + + + 20160704 + + + 20160905 + + + 20161010 + + + 20161111 + + + 20161124 + + + 20161226 + + + 20170102 + + + 20170116 + + + 20170220 + + + 20170529 + + + 20170704 + + + 20170904 + + + 20171009 + + + 20171123 + + + 20171225 + + + 20180101 + + + 20180115 + + + 20180219 + + + 20180528 + + + 20180704 + + + 20180903 + + + 20181008 + + + 20181112 + + + 20181122 + + + 20181225 + + + 20190101 + + + 20190121 + + + 20190218 + + + 20190527 + + + 20190704 + + + 20190902 + + + 20191014 + + + 20191111 + + + 20191126 + + + 20191225 + + + 20200101 + + + 20200120 + + + 20200217 + + + 20200525 + + + 20200907 + + + 20201012 + + + 20201111 + + + 20201126 + + + 20201225 + + + 20210101 + + + 20210118 + + + 20210215 + + + 20210531 + + + 20210705 + + + 20210906 + + + 20211011 + + + 20211111 + + + 20211125 + + + 20220117 + + + 20220221 + + + 20220530 + + + 20220620 + + + 20220704 + + + 20220905 + + + 20221010 + + + 20221111 + + + 20221124 + + + 20221226 + + + 20230102 + + + 20230116 + + + 20230220 + + + 20230529 + + + 20230619 + + + 20230704 + + + 20230904 + + + 20231009 + + + 20231123 + + + 20231225 + + + 20240101 + + + 20240115 + + + 20240219 + + + 20240527 + + + 20240619 + + + 20240704 + + + 20240902 + + + 20241014 + + + 20241111 + + + 20241128 + + + 20241225 + + + 20250101 + + + 20250120 + + + 20250217 + + + 20250526 + + + 20250619 + + + 20250704 + + + 20250901 + + + 20251012 + + + 20251111 + + + 20251127 + + + 20251225 + + + 20260101 + + + 20260119 + + + 20260216 + + + 20260525 + + + 20260619 + + + 20260907 + + + 20261012 + + + 20261111 + + + 20261126 + + + 20261225 + + + 20270101 + + + 20270118 + + + 20270215 + + + 20270531 + + + 20270705 + + + 20270906 + + + 20271011 + + + 20271111 + + + 20271125 + + + 20280117 + + + 20280221 + + + 20280529 + + + 20280619 + + + 20280704 + + + 20280904 + + + 20281009 + + + 20281123 + + + 20281225 + + + 20290101 + + + 20290115 + + + 20290219 + + + 20290528 + + + 20290619 + + + 20290704 + + + 20290903 + + + 20291008 + + + 20291112 + + + 20291122 + + + 20291225 + + + 20300101 + + + 20300121 + + + 20300218 + + + 20300527 + + + 20300619 + + + 20300704 + + + 20300902 + + + 20301014 + + + 20301111 + + + 20301128 + + + 20301225 + + + 20310101 + + + 20310120 + + + 20310217 + + + 20310526 + + + 20310619 + + + 20310704 + + + 20310901 + + + 20311013 + + + 20311111 + + + 20311127 + + + 20311225 + + + 20320101 + + + 20320119 + + + 20320216 + + + 20320531 + + + 20320705 + + + 20320906 + + + 20321011 + + + 20321111 + + + 20321125 + + + 20330117 + + + 20330221 + + + 20330530 + + + 20330620 + + + 20330704 + + + 20330905 + + + 20331010 + + + 20331111 + + + 20331124 + + + 20331226 + + + 20340102 + + + 20340116 + + + 20340220 + + + 20340529 + + + 20340619 + + + 20340704 + + + 20340904 + + + 20341009 + + + 20341123 + + + 20341225 + + diff --git a/props/configs/out/production/resources/calendar/USNYSE.calendar b/props/configs/out/production/resources/calendar/USNYSE.calendar new file mode 100644 index 00000000000..5c882c5aa9e --- /dev/null +++ b/props/configs/out/production/resources/calendar/USNYSE.calendar @@ -0,0 +1,1328 @@ + + + + USNYSE + America/New_York + en + US + 1999-01-01 + 2034-12-25 + + New York Stock Exchange Business Calendar. + Sources: https://www.tradinghours.com/markets/nyse, https://www.nyse.com/markets/hours-calendars, https://www.public-holidays.us/mobile_US_PD_2027_New%20York%20Stock%20Exchange + Historical reference: https://www.thestreet.com/markets/stock-market-open-or-closed-fourth-of-july + Last updated 7/23/2023 + + + 09:30,16:00 + Saturday + Sunday + + + 19990101 + + + 19990118 + + + 19990215 + + + 19990402 + + + 19990531 + + + 19990705 + + + 19990906 + + + 19991125 + + + 19991224 + + + 20000117 + + + 20000221 + + + 20000421 + + + 20000529 + + + 20000704 + + + 20000904 + + + 20001123 + + + 20001225 + + + 20010101 + + + 20010115 + + + 20010219 + + + 20010413 + + + 20010528 + + + 20010704 + + + 20010903 + + + 20010911 + + + 20010912 + + + 20010913 + + + 20010914 + + + 20011122 + + + 20011225 + + + 20020101 + + + 20020121 + + + 20020218 + + + 20020329 + + + 20020527 + + + 20020704 + + + 20020705 + 09:30,13:00 + + + 20020902 + + + 20021128 + + + 20021129 + 09:30,13:00 + + + 20021224 + 09:30,13:00 + + + 20021225 + + + 20030101 + + + 20030120 + + + 20030217 + + + 20030418 + + + 20030526 + + + 20030703 + 09:30,13:00 + + + 20030704 + + + 20030901 + + + 20031127 + + + 20031128 + 09:30,13:00 + + + 20031224 + 09:30,13:00 + + + 20031225 + + + 20031226 + 09:30,13:00 + + + 20040101 + + + 20040119 + + + 20040216 + + + 20040409 + + + 20040531 + + + 20040611 + + + 20040705 + + + 20040906 + + + 20041125 + + + 20041126 + 09:30,13:00 + + + 20041224 + + + 20050117 + + + 20050221 + + + 20050325 + + + 20050530 + + + 20050704 + + + 20050905 + + + 20051124 + + + 20051125 + 09:30,13:00 + + + 20051226 + + + 20060102 + + + 20060116 + + + 20060220 + + + 20060414 + + + 20060529 + + + 20060703 + 09:30,13:00 + + + 20060704 + + + 20060904 + + + 20061123 + + + 20061124 + 09:30,13:00 + + + 20061225 + + + 20070101 + + + 20070102 + + + 20070115 + + + 20070219 + + + 20070406 + + + 20070528 + + + 20070703 + 09:30,13:00 + + + 20070704 + + + 20070903 + + + 20071122 + + + 20071123 + 09:30,13:00 + + + 20071224 + 09:30,13:00 + + + 20071225 + + + 20080101 + + + 20080121 + + + 20080218 + + + 20080321 + + + 20080526 + + + 20080703 + 09:30,13:00 + + + 20080704 + + + 20080901 + + + 20081127 + + + 20081128 + 09:30,13:00 + + + 20081224 + 09:30,13:00 + + + 20081225 + + + 20090101 + + + 20090119 + + + 20090216 + + + 20090410 + + + 20090525 + + + 20090703 + + + 20090907 + + + 20091126 + + + 20091127 + 09:30,13:00 + + + 20091224 + 09:30,13:00 + + + 20091225 + + + 20100101 + + + 20100118 + + + 20100215 + + + 20100402 + + + 20100531 + + + 20100705 + + + 20100906 + + + 20101125 + + + 20101126 + 09:30,13:00 + + + 20101224 + + + 20110117 + + + 20110221 + + + 20110422 + + + 20110530 + + + 20110704 + + + 20110905 + + + 20111124 + + + 20111125 + 09:30,13:00 + + + 20111226 + + + 20120102 + + + 20120116 + + + 20120220 + + + 20120406 + + + 20120528 + + + 20120703 + 09:30,13:00 + + + 20120704 + + + 20120903 + + + 20121029 + + + 20121030 + + + 20121122 + + + 20121123 + 09:30,13:00 + + + 20121224 + 09:30,13:00 + + + 20121225 + + + 20130101 + + + 20130121 + + + 20130218 + + + 20130329 + + + 20130527 + + + 20130703 + 09:30,13:00 + + + 20130704 + + + 20130902 + + + 20131128 + + + 20131129 + 09:30,13:00 + + + 20131224 + 09:30,13:00 + + + 20131225 + + + 20140101 + + + 20140120 + + + 20140217 + + + 20140418 + + + 20140526 + + + 20140703 + 09:30,13:00 + + + 20140704 + + + 20140901 + + + 20141127 + + + 20141128 + 09:30,13:00 + + + 20141224 + 09:30,13:00 + + + 20141225 + + + 20150101 + + + 20150119 + + + 20150216 + + + 20150403 + + + 20150525 + + + 20150703 + + + 20150907 + + + 20151126 + + + 20151127 + 09:30,13:00 + + + 20151224 + 09:30,13:00 + + + 20151225 + + + 20160101 + + + 20160118 + + + 20160215 + + + 20160325 + + + 20160530 + + + 20160704 + + + 20160905 + + + 20161124 + + + 20161125 + 09:30,13:00 + + + 20161226 + + + 20170102 + + + 20170116 + + + 20170220 + + + 20170414 + + + 20170529 + + + 20170703 + 09:30,13:00 + + + 20170704 + + + 20170904 + + + 20171123 + + + 20171124 + 09:30,13:00 + + + 20171225 + + + 20180101 + + + 20180115 + + + 20180219 + + + 20180330 + + + 20180528 + + + 20180703 + 09:30,13:00 + + + 20180704 + + + 20180903 + + + 20181122 + + + 20181123 + 09:30,13:00 + + + 20181205 + + + 20181224 + 09:30,13:00 + + + 20181225 + + + 20190101 + + + 20190121 + + + 20190218 + + + 20190419 + + + 20190527 + + + 20190703 + 09:30,13:00 + + + 20190704 + + + 20190902 + + + 20191128 + + + 20191129 + 09:30,13:00 + + + 20191224 + 09:30,13:00 + + + 20191225 + + + 20200101 + + + 20200120 + + + 20200217 + + + 20200410 + + + 20200525 + + + 20200703 + + + 20200907 + + + 20201126 + + + 20201127 + 09:30,13:00 + + + 20201224 + 09:30,13:00 + + + 20201225 + + + 20210101 + + + 20210118 + + + 20210215 + + + 20210402 + + + 20210531 + + + 20210705 + + + 20210906 + + + 20211125 + + + 20211126 + 09:30,13:00 + + + 20211224 + + + 20220117 + + + 20220221 + + + 20220415 + + + 20220530 + + + 20220704 + + + 20220905 + + + 20221124 + + + 20221125 + 09:30,13:00 + + + 20221226 + + + 20230102 + + + 20230116 + + + 20230220 + + + 20230407 + + + 20230529 + + + 20230619 + + + 20230703 + 09:30,13:00 + + + 20230704 + + + 20230904 + + + 20231123 + + + 20231124 + 09:30,13:00 + + + 20231225 + + + 20240101 + + + 20240115 + + + 20240219 + + + 20240329 + + + 20240527 + + + 20240619 + + + 20240703 + 09:30,13:00 + + + 20240704 + + + 20240902 + + + 20241128 + + + 20241129 + 09:30,13:00 + + + 20241224 + 10:30,14:00 + + + 20241225 + + + 20250101 + + + 20250120 + + + 20250217 + + + 20250418 + + + 20250526 + + + 20250619 + + + 20250703 + 09:30,13:00 + + + 20250704 + + + 20250901 + + + 20251127 + + + 20251128 + 09:30,13:00 + + + 20251224 + 10:30,14:00 + + + 20251225 + + + 20260101 + + + 20260119 + + + 20260216 + + + 20260403 + + + 20260525 + + + 20260619 + + + 20260703 + 09:30,13:00 + + + 20260907 + + + 20261126 + + + 20261127 + 09:30,13:00 + + + 20261224 + 10:30,14:00 + + + 20261225 + + + 20270101 + + + 20270118 + + + 20270215 + + + 20270326 + + + 20270531 + + + 20270618 + + + 20270705 + + + 20270906 + + + 20271125 + + + 20271126 + 09:30,13:00 + + + 20271224 + + + 20271231 + + + 20280117 + + + 20280221 + + + 20280414 + + + 20280529 + + + 20280619 + + + 20280703 + 09:30,13:00 + + + 20280704 + + + 20280904 + + + 20281123 + + + 20281124 + 09:30,13:00 + + + 20281225 + + + 20290101 + + + 20290115 + + + 20290219 + + + 20290330 + + + 20290528 + + + 20290619 + + + 20290703 + 09:30,13:00 + + + 20290704 + + + 20290903 + + + 20291122 + + + 20291123 + 09:30,13:00 + + + 20291224 + 10:30,14:00 + + + 20291225 + + + 20300101 + + + 20300121 + + + 20300218 + + + 20300419 + + + 20300527 + + + 20300619 + + + 20300703 + 09:30,13:00 + + + 20300704 + + + 20300902 + + + 20301128 + + + 20301129 + 09:30,13:00 + + + 20301224 + 10:30,14:00 + + + 20301225 + + + 20310101 + + + 20310120 + + + 20310217 + + + 20310411 + + + 20310526 + + + 20310619 + + + 20310703 + 09:30,13:00 + + + 20310704 + + + 20310901 + + + 20311127 + + + 20311128 + 09:30,13:00 + + + 20311224 + 10:30,14:00 + + + 20311225 + + + 20320101 + + + 20320119 + + + 20320216 + + + 20320326 + + + 20320531 + + + 20320618 + + + 20320705 + + + 20320906 + + + 20321125 + + + 20321126 + 09:30,13:00 + + + 20321224 + + + 20321231 + + + 20330117 + + + 20330221 + + + 20330415 + + + 20330530 + + + 20330620 + + + 20330704 + + + 20330905 + + + 20331125 + 09:30,13:00 + + + 20331226 + + + 20340102 + + + 20340116 + + + 20340220 + + + 20340407 + + + 20340529 + + + 20340619 + + + 20340703 + 09:30,13:00 + + + 20340704 + + + 20340904 + + + 20341123 + + + 20341124 + 09:30,13:00 + + + 20341225 + + diff --git a/props/configs/out/production/resources/calendar/UTC.calendar b/props/configs/out/production/resources/calendar/UTC.calendar new file mode 100644 index 00000000000..1a53d818563 --- /dev/null +++ b/props/configs/out/production/resources/calendar/UTC.calendar @@ -0,0 +1,11 @@ + + + + UTC + UTC + + 00:00,24:00 + + \ No newline at end of file diff --git a/props/configs/src/main/resources/default_calendar_imports.txt b/props/configs/src/main/resources/default_calendar_imports.txt index 649e1eef0d7..6c6d1dd77cc 100644 --- a/props/configs/src/main/resources/default_calendar_imports.txt +++ b/props/configs/src/main/resources/default_calendar_imports.txt @@ -1 +1,3 @@ /calendar/UTC.calendar +/calendar/USBANK.calendar +/calendar/USNYSE.calendar diff --git a/props/test-configs/src/main/resources/calendar/USBANK.calendar b/props/test-configs/src/main/resources/calendar/USBANK.calendar new file mode 120000 index 00000000000..ce7d51f44a5 --- /dev/null +++ b/props/test-configs/src/main/resources/calendar/USBANK.calendar @@ -0,0 +1 @@ +/Users/chip/TEMP/FIX_TIME/deephaven-core/props/configs/out/production/resources/calendar/USBANK.calendar \ No newline at end of file diff --git a/props/test-configs/src/main/resources/calendar/USNYSE.calendar b/props/test-configs/src/main/resources/calendar/USNYSE.calendar new file mode 120000 index 00000000000..6abb4fcbd82 --- /dev/null +++ b/props/test-configs/src/main/resources/calendar/USNYSE.calendar @@ -0,0 +1 @@ +/Users/chip/TEMP/FIX_TIME/deephaven-core/props/configs/out/production/resources/calendar/USNYSE.calendar \ No newline at end of file diff --git a/props/test-configs/src/main/resources/test_calendar_imports.txt b/props/test-configs/src/main/resources/test_calendar_imports.txt index d3ab04ca85e..a226ed9d3f4 100644 --- a/props/test-configs/src/main/resources/test_calendar_imports.txt +++ b/props/test-configs/src/main/resources/test_calendar_imports.txt @@ -1,2 +1,4 @@ /calendar/CAL1.calendar /calendar/CAL2.calendar +/calendar/USBANK.calendar +/calendar/USNYSE.calendar From 6fd7e2f7c451ab2b0c360878cc9f6fdb8179d685 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Tue, 31 Oct 2023 15:33:56 -0600 Subject: [PATCH 053/150] Updating calendar configs. --- .../main/resources/calendar/USBANK.calendar | 676 +++++++++ .../main/resources/calendar/USNYSE.calendar | 1328 +++++++++++++++++ 2 files changed, 2004 insertions(+) create mode 100644 props/configs/src/main/resources/calendar/USBANK.calendar create mode 100644 props/configs/src/main/resources/calendar/USNYSE.calendar diff --git a/props/configs/src/main/resources/calendar/USBANK.calendar b/props/configs/src/main/resources/calendar/USBANK.calendar new file mode 100644 index 00000000000..4ac1e49cbe9 --- /dev/null +++ b/props/configs/src/main/resources/calendar/USBANK.calendar @@ -0,0 +1,676 @@ + + + + USBANK + America/New_York + en + US + 2013-01-01 + 2034-12-25 + + United States Banking Business Calendar. + Sources: https://www.frbservices.org/about/holiday-schedules, https://www.public-holidays.us/mobile_US_EN_2029_Federal%20holidays, https://www.federalreserve.gov/aboutthefed/k8.htm, https://www.federalholidays.net/usa/federal-holidays-2022.html + Last updated 7/23/2023 + + + 09:00,17:00 + Saturday + Sunday + + + 20130101 + + + 20130121 + + + 20130218 + + + 20130527 + + + 20130704 + + + 20130902 + + + 20131014 + + + 20131111 + + + 20131128 + + + 20131225 + + + 20140101 + + + 20140120 + + + 20140217 + + + 20140526 + + + 20140704 + + + 20140901 + + + 20141013 + + + 20141111 + + + 20141127 + + + 20141225 + + + 20150101 + + + 20150119 + + + 20150216 + + + 20150525 + + + 20150907 + + + 20151012 + + + 20151111 + + + 20151126 + + + 20151225 + + + 20160101 + + + 20160118 + + + 20160215 + + + 20160530 + + + 20160704 + + + 20160905 + + + 20161010 + + + 20161111 + + + 20161124 + + + 20161226 + + + 20170102 + + + 20170116 + + + 20170220 + + + 20170529 + + + 20170704 + + + 20170904 + + + 20171009 + + + 20171123 + + + 20171225 + + + 20180101 + + + 20180115 + + + 20180219 + + + 20180528 + + + 20180704 + + + 20180903 + + + 20181008 + + + 20181112 + + + 20181122 + + + 20181225 + + + 20190101 + + + 20190121 + + + 20190218 + + + 20190527 + + + 20190704 + + + 20190902 + + + 20191014 + + + 20191111 + + + 20191126 + + + 20191225 + + + 20200101 + + + 20200120 + + + 20200217 + + + 20200525 + + + 20200907 + + + 20201012 + + + 20201111 + + + 20201126 + + + 20201225 + + + 20210101 + + + 20210118 + + + 20210215 + + + 20210531 + + + 20210705 + + + 20210906 + + + 20211011 + + + 20211111 + + + 20211125 + + + 20220117 + + + 20220221 + + + 20220530 + + + 20220620 + + + 20220704 + + + 20220905 + + + 20221010 + + + 20221111 + + + 20221124 + + + 20221226 + + + 20230102 + + + 20230116 + + + 20230220 + + + 20230529 + + + 20230619 + + + 20230704 + + + 20230904 + + + 20231009 + + + 20231123 + + + 20231225 + + + 20240101 + + + 20240115 + + + 20240219 + + + 20240527 + + + 20240619 + + + 20240704 + + + 20240902 + + + 20241014 + + + 20241111 + + + 20241128 + + + 20241225 + + + 20250101 + + + 20250120 + + + 20250217 + + + 20250526 + + + 20250619 + + + 20250704 + + + 20250901 + + + 20251012 + + + 20251111 + + + 20251127 + + + 20251225 + + + 20260101 + + + 20260119 + + + 20260216 + + + 20260525 + + + 20260619 + + + 20260907 + + + 20261012 + + + 20261111 + + + 20261126 + + + 20261225 + + + 20270101 + + + 20270118 + + + 20270215 + + + 20270531 + + + 20270705 + + + 20270906 + + + 20271011 + + + 20271111 + + + 20271125 + + + 20280117 + + + 20280221 + + + 20280529 + + + 20280619 + + + 20280704 + + + 20280904 + + + 20281009 + + + 20281123 + + + 20281225 + + + 20290101 + + + 20290115 + + + 20290219 + + + 20290528 + + + 20290619 + + + 20290704 + + + 20290903 + + + 20291008 + + + 20291112 + + + 20291122 + + + 20291225 + + + 20300101 + + + 20300121 + + + 20300218 + + + 20300527 + + + 20300619 + + + 20300704 + + + 20300902 + + + 20301014 + + + 20301111 + + + 20301128 + + + 20301225 + + + 20310101 + + + 20310120 + + + 20310217 + + + 20310526 + + + 20310619 + + + 20310704 + + + 20310901 + + + 20311013 + + + 20311111 + + + 20311127 + + + 20311225 + + + 20320101 + + + 20320119 + + + 20320216 + + + 20320531 + + + 20320705 + + + 20320906 + + + 20321011 + + + 20321111 + + + 20321125 + + + 20330117 + + + 20330221 + + + 20330530 + + + 20330620 + + + 20330704 + + + 20330905 + + + 20331010 + + + 20331111 + + + 20331124 + + + 20331226 + + + 20340102 + + + 20340116 + + + 20340220 + + + 20340529 + + + 20340619 + + + 20340704 + + + 20340904 + + + 20341009 + + + 20341123 + + + 20341225 + + diff --git a/props/configs/src/main/resources/calendar/USNYSE.calendar b/props/configs/src/main/resources/calendar/USNYSE.calendar new file mode 100644 index 00000000000..5c882c5aa9e --- /dev/null +++ b/props/configs/src/main/resources/calendar/USNYSE.calendar @@ -0,0 +1,1328 @@ + + + + USNYSE + America/New_York + en + US + 1999-01-01 + 2034-12-25 + + New York Stock Exchange Business Calendar. + Sources: https://www.tradinghours.com/markets/nyse, https://www.nyse.com/markets/hours-calendars, https://www.public-holidays.us/mobile_US_PD_2027_New%20York%20Stock%20Exchange + Historical reference: https://www.thestreet.com/markets/stock-market-open-or-closed-fourth-of-july + Last updated 7/23/2023 + + + 09:30,16:00 + Saturday + Sunday + + + 19990101 + + + 19990118 + + + 19990215 + + + 19990402 + + + 19990531 + + + 19990705 + + + 19990906 + + + 19991125 + + + 19991224 + + + 20000117 + + + 20000221 + + + 20000421 + + + 20000529 + + + 20000704 + + + 20000904 + + + 20001123 + + + 20001225 + + + 20010101 + + + 20010115 + + + 20010219 + + + 20010413 + + + 20010528 + + + 20010704 + + + 20010903 + + + 20010911 + + + 20010912 + + + 20010913 + + + 20010914 + + + 20011122 + + + 20011225 + + + 20020101 + + + 20020121 + + + 20020218 + + + 20020329 + + + 20020527 + + + 20020704 + + + 20020705 + 09:30,13:00 + + + 20020902 + + + 20021128 + + + 20021129 + 09:30,13:00 + + + 20021224 + 09:30,13:00 + + + 20021225 + + + 20030101 + + + 20030120 + + + 20030217 + + + 20030418 + + + 20030526 + + + 20030703 + 09:30,13:00 + + + 20030704 + + + 20030901 + + + 20031127 + + + 20031128 + 09:30,13:00 + + + 20031224 + 09:30,13:00 + + + 20031225 + + + 20031226 + 09:30,13:00 + + + 20040101 + + + 20040119 + + + 20040216 + + + 20040409 + + + 20040531 + + + 20040611 + + + 20040705 + + + 20040906 + + + 20041125 + + + 20041126 + 09:30,13:00 + + + 20041224 + + + 20050117 + + + 20050221 + + + 20050325 + + + 20050530 + + + 20050704 + + + 20050905 + + + 20051124 + + + 20051125 + 09:30,13:00 + + + 20051226 + + + 20060102 + + + 20060116 + + + 20060220 + + + 20060414 + + + 20060529 + + + 20060703 + 09:30,13:00 + + + 20060704 + + + 20060904 + + + 20061123 + + + 20061124 + 09:30,13:00 + + + 20061225 + + + 20070101 + + + 20070102 + + + 20070115 + + + 20070219 + + + 20070406 + + + 20070528 + + + 20070703 + 09:30,13:00 + + + 20070704 + + + 20070903 + + + 20071122 + + + 20071123 + 09:30,13:00 + + + 20071224 + 09:30,13:00 + + + 20071225 + + + 20080101 + + + 20080121 + + + 20080218 + + + 20080321 + + + 20080526 + + + 20080703 + 09:30,13:00 + + + 20080704 + + + 20080901 + + + 20081127 + + + 20081128 + 09:30,13:00 + + + 20081224 + 09:30,13:00 + + + 20081225 + + + 20090101 + + + 20090119 + + + 20090216 + + + 20090410 + + + 20090525 + + + 20090703 + + + 20090907 + + + 20091126 + + + 20091127 + 09:30,13:00 + + + 20091224 + 09:30,13:00 + + + 20091225 + + + 20100101 + + + 20100118 + + + 20100215 + + + 20100402 + + + 20100531 + + + 20100705 + + + 20100906 + + + 20101125 + + + 20101126 + 09:30,13:00 + + + 20101224 + + + 20110117 + + + 20110221 + + + 20110422 + + + 20110530 + + + 20110704 + + + 20110905 + + + 20111124 + + + 20111125 + 09:30,13:00 + + + 20111226 + + + 20120102 + + + 20120116 + + + 20120220 + + + 20120406 + + + 20120528 + + + 20120703 + 09:30,13:00 + + + 20120704 + + + 20120903 + + + 20121029 + + + 20121030 + + + 20121122 + + + 20121123 + 09:30,13:00 + + + 20121224 + 09:30,13:00 + + + 20121225 + + + 20130101 + + + 20130121 + + + 20130218 + + + 20130329 + + + 20130527 + + + 20130703 + 09:30,13:00 + + + 20130704 + + + 20130902 + + + 20131128 + + + 20131129 + 09:30,13:00 + + + 20131224 + 09:30,13:00 + + + 20131225 + + + 20140101 + + + 20140120 + + + 20140217 + + + 20140418 + + + 20140526 + + + 20140703 + 09:30,13:00 + + + 20140704 + + + 20140901 + + + 20141127 + + + 20141128 + 09:30,13:00 + + + 20141224 + 09:30,13:00 + + + 20141225 + + + 20150101 + + + 20150119 + + + 20150216 + + + 20150403 + + + 20150525 + + + 20150703 + + + 20150907 + + + 20151126 + + + 20151127 + 09:30,13:00 + + + 20151224 + 09:30,13:00 + + + 20151225 + + + 20160101 + + + 20160118 + + + 20160215 + + + 20160325 + + + 20160530 + + + 20160704 + + + 20160905 + + + 20161124 + + + 20161125 + 09:30,13:00 + + + 20161226 + + + 20170102 + + + 20170116 + + + 20170220 + + + 20170414 + + + 20170529 + + + 20170703 + 09:30,13:00 + + + 20170704 + + + 20170904 + + + 20171123 + + + 20171124 + 09:30,13:00 + + + 20171225 + + + 20180101 + + + 20180115 + + + 20180219 + + + 20180330 + + + 20180528 + + + 20180703 + 09:30,13:00 + + + 20180704 + + + 20180903 + + + 20181122 + + + 20181123 + 09:30,13:00 + + + 20181205 + + + 20181224 + 09:30,13:00 + + + 20181225 + + + 20190101 + + + 20190121 + + + 20190218 + + + 20190419 + + + 20190527 + + + 20190703 + 09:30,13:00 + + + 20190704 + + + 20190902 + + + 20191128 + + + 20191129 + 09:30,13:00 + + + 20191224 + 09:30,13:00 + + + 20191225 + + + 20200101 + + + 20200120 + + + 20200217 + + + 20200410 + + + 20200525 + + + 20200703 + + + 20200907 + + + 20201126 + + + 20201127 + 09:30,13:00 + + + 20201224 + 09:30,13:00 + + + 20201225 + + + 20210101 + + + 20210118 + + + 20210215 + + + 20210402 + + + 20210531 + + + 20210705 + + + 20210906 + + + 20211125 + + + 20211126 + 09:30,13:00 + + + 20211224 + + + 20220117 + + + 20220221 + + + 20220415 + + + 20220530 + + + 20220704 + + + 20220905 + + + 20221124 + + + 20221125 + 09:30,13:00 + + + 20221226 + + + 20230102 + + + 20230116 + + + 20230220 + + + 20230407 + + + 20230529 + + + 20230619 + + + 20230703 + 09:30,13:00 + + + 20230704 + + + 20230904 + + + 20231123 + + + 20231124 + 09:30,13:00 + + + 20231225 + + + 20240101 + + + 20240115 + + + 20240219 + + + 20240329 + + + 20240527 + + + 20240619 + + + 20240703 + 09:30,13:00 + + + 20240704 + + + 20240902 + + + 20241128 + + + 20241129 + 09:30,13:00 + + + 20241224 + 10:30,14:00 + + + 20241225 + + + 20250101 + + + 20250120 + + + 20250217 + + + 20250418 + + + 20250526 + + + 20250619 + + + 20250703 + 09:30,13:00 + + + 20250704 + + + 20250901 + + + 20251127 + + + 20251128 + 09:30,13:00 + + + 20251224 + 10:30,14:00 + + + 20251225 + + + 20260101 + + + 20260119 + + + 20260216 + + + 20260403 + + + 20260525 + + + 20260619 + + + 20260703 + 09:30,13:00 + + + 20260907 + + + 20261126 + + + 20261127 + 09:30,13:00 + + + 20261224 + 10:30,14:00 + + + 20261225 + + + 20270101 + + + 20270118 + + + 20270215 + + + 20270326 + + + 20270531 + + + 20270618 + + + 20270705 + + + 20270906 + + + 20271125 + + + 20271126 + 09:30,13:00 + + + 20271224 + + + 20271231 + + + 20280117 + + + 20280221 + + + 20280414 + + + 20280529 + + + 20280619 + + + 20280703 + 09:30,13:00 + + + 20280704 + + + 20280904 + + + 20281123 + + + 20281124 + 09:30,13:00 + + + 20281225 + + + 20290101 + + + 20290115 + + + 20290219 + + + 20290330 + + + 20290528 + + + 20290619 + + + 20290703 + 09:30,13:00 + + + 20290704 + + + 20290903 + + + 20291122 + + + 20291123 + 09:30,13:00 + + + 20291224 + 10:30,14:00 + + + 20291225 + + + 20300101 + + + 20300121 + + + 20300218 + + + 20300419 + + + 20300527 + + + 20300619 + + + 20300703 + 09:30,13:00 + + + 20300704 + + + 20300902 + + + 20301128 + + + 20301129 + 09:30,13:00 + + + 20301224 + 10:30,14:00 + + + 20301225 + + + 20310101 + + + 20310120 + + + 20310217 + + + 20310411 + + + 20310526 + + + 20310619 + + + 20310703 + 09:30,13:00 + + + 20310704 + + + 20310901 + + + 20311127 + + + 20311128 + 09:30,13:00 + + + 20311224 + 10:30,14:00 + + + 20311225 + + + 20320101 + + + 20320119 + + + 20320216 + + + 20320326 + + + 20320531 + + + 20320618 + + + 20320705 + + + 20320906 + + + 20321125 + + + 20321126 + 09:30,13:00 + + + 20321224 + + + 20321231 + + + 20330117 + + + 20330221 + + + 20330415 + + + 20330530 + + + 20330620 + + + 20330704 + + + 20330905 + + + 20331125 + 09:30,13:00 + + + 20331226 + + + 20340102 + + + 20340116 + + + 20340220 + + + 20340407 + + + 20340529 + + + 20340619 + + + 20340703 + 09:30,13:00 + + + 20340704 + + + 20340904 + + + 20341123 + + + 20341124 + 09:30,13:00 + + + 20341225 + + From 849fe1c659c034aca6eb0c65e366830e4a773145 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Wed, 1 Nov 2023 12:06:44 -0600 Subject: [PATCH 054/150] Refactoring code gen --- .../main/java/io/deephaven/gen/GenUtils.java | 48 ++++ .../java/io/deephaven/gen/JavaFunction.java | 163 +++++++++++++ .../libs/GroovyStaticImportGenerator.java | 221 ++---------------- .../plot/util/GenerateFigureImmutable.java | 49 +--- .../plot/util/GenerateMultiSeries.java | 90 +++---- .../util/GeneratePlottingConvenience.java | 2 +- .../plot/util/GeneratePyV2FigureAPI.java | 2 +- 7 files changed, 286 insertions(+), 289 deletions(-) create mode 100644 Generators/src/main/java/io/deephaven/gen/GenUtils.java create mode 100644 Generators/src/main/java/io/deephaven/gen/JavaFunction.java diff --git a/Generators/src/main/java/io/deephaven/gen/GenUtils.java b/Generators/src/main/java/io/deephaven/gen/GenUtils.java new file mode 100644 index 00000000000..34c3e400dbf --- /dev/null +++ b/Generators/src/main/java/io/deephaven/gen/GenUtils.java @@ -0,0 +1,48 @@ +package io.deephaven.gen; + +import java.lang.reflect.GenericArrayType; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.util.LinkedHashSet; +import java.util.Set; + +public class GenUtils { + private GenUtils() { + } + + public static Set typesToImport(Type t) { + Set result = new LinkedHashSet<>(); + + if (t instanceof Class) { + final Class c = (Class) t; + final boolean isArray = c.isArray(); + final boolean isPrimitive = c.isPrimitive(); + + if (isPrimitive) { + return result; + } else if (isArray) { + return typesToImport(c.getComponentType()); + } else { + result.add(t.getTypeName()); + } + } else if (t instanceof ParameterizedType) { + final ParameterizedType pt = (ParameterizedType) t; + result.add(pt.getRawType().getTypeName()); + + for (Type a : pt.getActualTypeArguments()) { + result.addAll(typesToImport(a)); + } + } else if (t instanceof TypeVariable) { + // type variables are generic so they don't need importing + return result; + } else if (t instanceof GenericArrayType) { + GenericArrayType at = (GenericArrayType) t; + return typesToImport(at.getGenericComponentType()); + } else { + throw new UnsupportedOperationException("Unsupported Type type: " + t.getClass()); + } + + return result; + } +} diff --git a/Generators/src/main/java/io/deephaven/gen/JavaFunction.java b/Generators/src/main/java/io/deephaven/gen/JavaFunction.java new file mode 100644 index 00000000000..8143d57e1e2 --- /dev/null +++ b/Generators/src/main/java/io/deephaven/gen/JavaFunction.java @@ -0,0 +1,163 @@ +package io.deephaven.gen; + +import io.deephaven.util.type.TypeUtils; +import org.jetbrains.annotations.NotNull; + +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.util.Arrays; +import java.util.Objects; +import java.util.logging.Logger; + +/** + * A Java function description for use in code generation. + */ +public class JavaFunction implements Comparable { + private static final Logger log = Logger.getLogger(JavaFunction.class.toString()); + + private final String className; + private final String classNameShort; + private final String methodName; + private final TypeVariable[] typeParameters; + private final Type returnType; + private final Type[] parameterTypes; + private final String[] parameterNames; + private final boolean isVarArgs; + + public JavaFunction(final String className, final String classNameShort, final String methodName, + final TypeVariable[] typeParameters, final Type returnType, final Type[] parameterTypes, + final String[] parameterNames, final boolean isVarArgs) { + this.className = className; + this.classNameShort = classNameShort; + this.methodName = methodName; + this.typeParameters = typeParameters; + this.returnType = returnType; + this.parameterTypes = parameterTypes; + this.parameterNames = parameterNames; + this.isVarArgs = isVarArgs; + } + + public JavaFunction(final Method m) { + this( + m.getDeclaringClass().getCanonicalName(), + m.getDeclaringClass().getSimpleName(), + m.getName(), + m.getTypeParameters(), + m.getGenericReturnType(), + m.getGenericParameterTypes(), + Arrays.stream(m.getParameters()).map(Parameter::getName).toArray(String[]::new), + m.isVarArgs()); + + for (Parameter parameter : m.getParameters()) { + if (!parameter.isNamePresent()) { + throw new IllegalArgumentException( + "Parameter names are not present in the code! Was the code compiled with \"-parameters\": " + + this); + } + } + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + JavaFunction that = (JavaFunction) o; + + if (!Objects.equals(methodName, that.methodName)) + return false; + // Probably incorrect - comparing Object[] arrays with Arrays.equals + return Arrays.equals(parameterTypes, that.parameterTypes); + + } + + @Override + public int hashCode() { + int result = methodName != null ? methodName.hashCode() : 0; + result = 31 * result + Arrays.hashCode(parameterTypes); + return result; + } + + @Override + public String toString() { + return "JavaFunction{" + + "className='" + className + '\'' + + ", methodName='" + methodName + '\'' + + ", typeParameters=" + Arrays.toString(typeParameters) + + ", returnType=" + returnType + + ", parameterTypes=" + Arrays.toString(parameterTypes) + + ", parameterNames=" + Arrays.toString(parameterNames) + + '}'; + } + + @Override + public int compareTo(@NotNull JavaFunction o) { + int cm = methodName.compareTo(o.methodName); + if (cm != 0) { + return cm; + } + if (parameterTypes.length != o.parameterTypes.length) { + return parameterTypes.length - o.parameterTypes.length; + } + + for (int i = 0; i < parameterTypes.length; i++) { + Type t1 = parameterTypes[i]; + Type t2 = o.parameterTypes[i]; + int ct = t1.toString().compareTo(t2.toString()); + if (ct != 0) { + return ct; + } + } + + return 0; + } + + public String getClassName() { + return className; + } + + public String getClassNameShort() { + return classNameShort; + } + + public String getMethodName() { + return methodName; + } + + public TypeVariable[] getTypeParameters() { + return typeParameters; + } + + public Type getReturnType() { + return returnType; + } + + public Class getReturnClass() { + if (returnType == null) { + return null; + } + + try { + return TypeUtils.getErasedType(returnType); + } catch (UnsupportedOperationException e) { + log.warning("Unable to determine Class from returnType=" + returnType.getTypeName()); + return null; + } + } + + public Type[] getParameterTypes() { + return parameterTypes; + } + + public String[] getParameterNames() { + return parameterNames; + } + + public boolean isVarArgs() { + return isVarArgs; + } +} diff --git a/Generators/src/main/java/io/deephaven/libs/GroovyStaticImportGenerator.java b/Generators/src/main/java/io/deephaven/libs/GroovyStaticImportGenerator.java index 668447631b0..ccef0eb4b1c 100644 --- a/Generators/src/main/java/io/deephaven/libs/GroovyStaticImportGenerator.java +++ b/Generators/src/main/java/io/deephaven/libs/GroovyStaticImportGenerator.java @@ -3,7 +3,7 @@ */ package io.deephaven.libs; -import io.deephaven.util.type.TypeUtils; +import io.deephaven.gen.JavaFunction; import org.jetbrains.annotations.NotNull; import java.io.IOException; @@ -17,160 +17,17 @@ import java.util.logging.Logger; import java.util.stream.Collectors; +import static io.deephaven.gen.GenUtils.typesToImport; + /** * Groovy has a bug where performing a static import on multiple libraries containing functions with the same name * causes some of the functions to not be present in the namespace. This class combines static imports from multiple * sources into a single class that can be imported. */ +@SuppressWarnings("StringConcatenationInLoop") public class GroovyStaticImportGenerator { - private static Logger log = Logger.getLogger(GroovyStaticImportGenerator.class.toString()); - - public static class JavaFunction implements Comparable { - private final String className; - private final String classNameShort; - private final String methodName; - private final TypeVariable[] typeParameters; - private final Type returnType; - private final Type[] parameterTypes; - private final String[] parameterNames; - private final boolean isVarArgs; - - public JavaFunction(final String className, final String classNameShort, final String methodName, - final TypeVariable[] typeParameters, final Type returnType, final Type[] parameterTypes, - final String[] parameterNames, final boolean isVarArgs) { - this.className = className; - this.classNameShort = classNameShort; - this.methodName = methodName; - this.typeParameters = typeParameters; - this.returnType = returnType; - this.parameterTypes = parameterTypes; - this.parameterNames = parameterNames; - this.isVarArgs = isVarArgs; - } - - public JavaFunction(final Method m) { - this( - m.getDeclaringClass().getCanonicalName(), - m.getDeclaringClass().getSimpleName(), - m.getName(), - m.getTypeParameters(), - m.getGenericReturnType(), - m.getGenericParameterTypes(), - Arrays.stream(m.getParameters()).map(Parameter::getName).toArray(String[]::new), - m.isVarArgs()); - - for (Parameter parameter : m.getParameters()) { - if (!parameter.isNamePresent()) { - throw new IllegalArgumentException( - "Parameter names are not present in the code! Was the code compiled with \"-parameters\": " - + toString()); - } - } - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - JavaFunction that = (JavaFunction) o; - - if (methodName != null ? !methodName.equals(that.methodName) : that.methodName != null) - return false; - // Probably incorrect - comparing Object[] arrays with Arrays.equals - return Arrays.equals(parameterTypes, that.parameterTypes); - - } - - @Override - public int hashCode() { - int result = methodName != null ? methodName.hashCode() : 0; - result = 31 * result + Arrays.hashCode(parameterTypes); - return result; - } - - @Override - public String toString() { - return "JavaFunction{" + - "className='" + className + '\'' + - ", methodName='" + methodName + '\'' + - ", typeParameters=" + Arrays.toString(typeParameters) + - ", returnType=" + returnType + - ", parameterTypes=" + Arrays.toString(parameterTypes) + - ", parameterNames=" + Arrays.toString(parameterNames) + - '}'; - } - - @Override - public int compareTo(@NotNull JavaFunction o) { - int cm = methodName.compareTo(o.methodName); - if (cm != 0) { - return cm; - } - if (parameterTypes.length != o.parameterTypes.length) { - return parameterTypes.length - o.parameterTypes.length; - } - - for (int i = 0; i < parameterTypes.length; i++) { - Type t1 = parameterTypes[i]; - Type t2 = o.parameterTypes[i]; - int ct = t1.toString().compareTo(t2.toString()); - if (ct != 0) { - return ct; - } - } - - return 0; - } - - public String getClassName() { - return className; - } - - public String getClassNameShort() { - return classNameShort; - } - - public String getMethodName() { - return methodName; - } - - public TypeVariable[] getTypeParameters() { - return typeParameters; - } - - public Type getReturnType() { - return returnType; - } - - public Class getReturnClass() { - if (returnType == null) { - return null; - } - - try { - return TypeUtils.getErasedType(returnType); - } catch (UnsupportedOperationException e) { - log.warning("Unable to determine Class from returnType=" + returnType.getTypeName()); - return null; - } - } - - public Type[] getParameterTypes() { - return parameterTypes; - } - - public String[] getParameterNames() { - return parameterNames; - } - - public boolean isVarArgs() { - return isVarArgs; - } - } + private static final Logger log = Logger.getLogger(GroovyStaticImportGenerator.class.toString()); private final Map staticFunctions = new TreeMap<>(); @@ -217,11 +74,11 @@ private Set generateImports() { Set imports = new TreeSet<>(); for (JavaFunction f : staticFunctions.keySet()) { - imports.add(f.className); + imports.add(f.getClassName()); - imports.addAll(typesToImport(f.returnType)); + imports.addAll(typesToImport(f.getReturnType())); - for (Type t : f.parameterTypes) { + for (Type t : f.getParameterTypes()) { imports.addAll(typesToImport(t)); } } @@ -229,41 +86,6 @@ private Set generateImports() { return imports; } - private static Set typesToImport(Type t) { - Set result = new LinkedHashSet<>(); - - if (t instanceof Class) { - final Class c = (Class) t; - final boolean isArray = c.isArray(); - final boolean isPrimitive = c.isPrimitive(); - - if (isPrimitive) { - return result; - } else if (isArray) { - return typesToImport(c.getComponentType()); - } else { - result.add(t.getTypeName()); - } - } else if (t instanceof ParameterizedType) { - final ParameterizedType pt = (ParameterizedType) t; - result.add(pt.getRawType().getTypeName()); - - for (Type a : pt.getActualTypeArguments()) { - result.addAll(typesToImport(a)); - } - } else if (t instanceof TypeVariable) { - // type variables are generic so they don't need importing - return result; - } else if (t instanceof GenericArrayType) { - GenericArrayType at = (GenericArrayType) t; - return typesToImport(at.getGenericComponentType()); - } else { - throw new UnsupportedOperationException("Unsupported Type type: " + t.getClass()); - } - - return result; - } - private String generateCode() { String code = "/**\n" + @@ -302,24 +124,24 @@ private String generateCode() { continue; } - String returnType = f.returnType.getTypeName(); + String returnType = f.getReturnType().getTypeName(); String s = " /** @see " + f.getClassName() + "#" + f.getMethodName() + "(" + - Arrays.stream(f.parameterTypes).map(t -> getParamTypeString(t)) + Arrays.stream(f.getParameterTypes()).map(this::getParamTypeString) .collect(Collectors.joining(",")) + ") */\n" + " public static "; - if (f.typeParameters.length > 0) { + if (f.getTypeParameters().length > 0) { s += "<"; - for (int i = 0; i < f.typeParameters.length; i++) { + for (int i = 0; i < f.getTypeParameters().length; i++) { if (i != 0) { s += ","; } - TypeVariable t = f.typeParameters[i]; + TypeVariable t = f.getTypeParameters()[i]; log.info("BOUNDS: " + Arrays.toString(t.getBounds())); s += t; @@ -340,23 +162,23 @@ private String generateCode() { s += ">"; } - s += " " + returnType + " " + f.methodName + "("; + s += " " + returnType + " " + f.getMethodName() + "("; String callArgs = ""; - for (int i = 0; i < f.parameterTypes.length; i++) { + for (int i = 0; i < f.getParameterTypes().length; i++) { if (i != 0) { s += ","; callArgs += ","; } - Type t = f.parameterTypes[i]; + Type t = f.getParameterTypes()[i]; - s += " " + t.getTypeName() + " " + f.parameterNames[i]; - callArgs += " " + f.parameterNames[i]; + s += " " + t.getTypeName() + " " + f.getParameterNames()[i]; + callArgs += " " + f.getParameterNames()[i]; } s += " ) {"; - s += "return " + f.classNameShort + "." + f.methodName + "(" + callArgs + " );"; + s += "return " + f.getClassNameShort() + "." + f.getMethodName() + "(" + callArgs + " );"; s += "}"; code += s; @@ -415,11 +237,10 @@ public static void main(String[] args) throws ClassNotFoundException, IOExceptio "io.deephaven.function.Sort", }; - @SuppressWarnings("unchecked") GroovyStaticImportGenerator gen = new GroovyStaticImportGenerator(imports, // skipping common erasure "sum" - Collections.singletonList((f) -> f.methodName.equals("sum") && f.parameterTypes.length == 1 - && f.parameterTypes[0].getTypeName() + Collections.singletonList((f) -> f.getMethodName().equals("sum") && f.getParameterTypes().length == 1 + && f.getParameterTypes()[0].getTypeName() .contains("ObjectVector<"))); final String code = gen.generateCode(); diff --git a/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java b/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java index f144fed8f1c..6bedbf359f9 100644 --- a/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java +++ b/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java @@ -7,8 +7,7 @@ import io.deephaven.plot.datasets.DataSeries; import io.deephaven.plot.datasets.multiseries.MultiSeries; import io.deephaven.plot.errors.PlotExceptionCause; -import io.deephaven.libs.GroovyStaticImportGenerator; -import io.deephaven.libs.GroovyStaticImportGenerator.JavaFunction; +import io.deephaven.gen.JavaFunction; import java.io.IOException; import java.io.PrintWriter; @@ -23,6 +22,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static io.deephaven.gen.GenUtils.typesToImport; import static io.deephaven.plot.util.PlotGeneratorUtils.indent; /** @@ -157,41 +157,6 @@ private Set generateImports() { return imports; } - private static Set typesToImport(Type t) { - Set result = new LinkedHashSet<>(); - - if (t instanceof Class) { - final Class c = (Class) t; - final boolean isArray = c.isArray(); - final boolean isPrimitive = c.isPrimitive(); - - if (isPrimitive) { - return result; - } else if (isArray) { - return typesToImport(c.getComponentType()); - } else { - result.add(t.getTypeName()); - } - } else if (t instanceof ParameterizedType) { - final ParameterizedType pt = (ParameterizedType) t; - result.add(pt.getRawType().getTypeName()); - - for (Type a : pt.getActualTypeArguments()) { - result.addAll(typesToImport(a)); - } - } else if (t instanceof TypeVariable) { - // type variables are generic so they don't need importing - return result; - } else if (t instanceof GenericArrayType) { - GenericArrayType at = (GenericArrayType) t; - return typesToImport(at.getGenericComponentType()); - } else { - throw new UnsupportedOperationException("Unsupported Type type: " + t.getClass()); - } - - return result; - } - private String generateImplements() { final StringBuilder sb = new StringBuilder(); @@ -882,11 +847,11 @@ private String createSignatureGroupFunction(final TreeSet fs) { return s; } - private Map> commonSignatureGroups( + private Map> commonSignatureGroups( final String[] interfaces) throws ClassNotFoundException { - final Map> methods = new TreeMap<>(); + final Map> methods = new TreeMap<>(); - final Set functionSet = new HashSet<>(); + final Set functionSet = new HashSet<>(); for (String iface : interfaces) { final Class c = Class.forName(iface, false, Thread.currentThread().getContextClassLoader()); log.info("Processing class: " + c); @@ -898,11 +863,11 @@ private Map> commonSig boolean isObject = m.getDeclaringClass().equals(Object.class); if (!isStatic && isPublic && !isObject) { - final GroovyStaticImportGenerator.JavaFunction f = new GroovyStaticImportGenerator.JavaFunction(m); + final JavaFunction f = new JavaFunction(m); if (functionSet.add(f)) { // avoids repeating methods that have the same parameter types but // different parameter names final String key = createFunctionSignature(f); - final TreeSet mm = + final TreeSet mm = methods.computeIfAbsent(key, k -> new TreeSet<>()); mm.add(f); } diff --git a/Generators/src/main/java/io/deephaven/plot/util/GenerateMultiSeries.java b/Generators/src/main/java/io/deephaven/plot/util/GenerateMultiSeries.java index 25f3210aa99..ac43698bcb6 100644 --- a/Generators/src/main/java/io/deephaven/plot/util/GenerateMultiSeries.java +++ b/Generators/src/main/java/io/deephaven/plot/util/GenerateMultiSeries.java @@ -5,9 +5,9 @@ import io.deephaven.base.ClassUtil; import io.deephaven.base.Pair; +import io.deephaven.gen.JavaFunction; import io.deephaven.plot.util.functions.ClosureFunction; import io.deephaven.engine.table.Table; -import io.deephaven.libs.GroovyStaticImportGenerator; import io.deephaven.util.type.TypeUtils; import groovy.lang.Closure; @@ -240,25 +240,25 @@ private String generateClasses(final Set skip) throws ClassNotFoundExcep .append(" series) {\n").append(indent(2)).append("$$initializeSeries$$(series);\n") .append(indent(1)).append("}\n\n"); } - final List sortedMethods = new ArrayList<>(); - final List methodsWithFunctionParameter = new ArrayList<>(); + final List sortedMethods = new ArrayList<>(); + final List methodsWithFunctionParameter = new ArrayList<>(); for (final String clazz : interfaces) { final Class dataseries = Class.forName(clazz, false, Thread.currentThread().getContextClassLoader()); final Method[] methods = Arrays.stream(dataseries.getMethods()) .filter(m -> !skip.contains(m)) .toArray(Method[]::new); - final GroovyStaticImportGenerator.JavaFunction[] functionalMethods = + final JavaFunction[] functionalMethods = filterBadMethods(Arrays.stream(methods) .filter(m -> hasFunction(m.getParameterTypes())) - .map(GroovyStaticImportGenerator.JavaFunction::new) - .toArray(GroovyStaticImportGenerator.JavaFunction[]::new)); + .map(JavaFunction::new) + .toArray(JavaFunction[]::new)); - final GroovyStaticImportGenerator.JavaFunction[] nonFunctionalMethods = + final JavaFunction[] nonFunctionalMethods = Arrays.stream(methods) .filter(m -> !hasFunction(m.getParameterTypes())) - .map(GroovyStaticImportGenerator.JavaFunction::new) - .toArray(GroovyStaticImportGenerator.JavaFunction[]::new); + .map(JavaFunction::new) + .toArray(JavaFunction[]::new); Arrays.sort(functionalMethods); Arrays.sort(nonFunctionalMethods); Collections.addAll(methodsWithFunctionParameter, functionalMethods); @@ -266,7 +266,7 @@ private String generateClasses(final Set skip) throws ClassNotFoundExcep } final Set methodsDone = new HashSet<>(); // used to avoid duplicates - for (final GroovyStaticImportGenerator.JavaFunction function : methodsWithFunctionParameter) { + for (final JavaFunction function : methodsWithFunctionParameter) { final String mapName = createMapName(function); if (!methodsDone.add(mapName)) { continue; @@ -276,8 +276,8 @@ private String generateClasses(final Set skip) throws ClassNotFoundExcep code.append("\n\n"); } - final Map mapToFunction = new HashMap<>(); - for (final GroovyStaticImportGenerator.JavaFunction function : sortedMethods) { + final Map mapToFunction = new HashMap<>(); + for (final JavaFunction function : sortedMethods) { final String mapName = createMapName(function); if (mapToFunction.get(mapName) != null) { continue; @@ -331,9 +331,9 @@ private String createCopyConstructor(final Set strings) { } private String createInitializeFunction( - final Map mapToFunction) { + final Map mapToFunction) { final StringBuilder code = new StringBuilder(); - final Map> functionToGenerics = + final Map> functionToGenerics = createFunctionToGenerics(mapToFunction.values()); code.append(indent(1)).append("@SuppressWarnings(\"unchecked\") \n").append(indent(1)).append("private ") @@ -350,9 +350,9 @@ private String createInitializeFunction( boolean objectArrayInitialized = false; int numConsumers = 0; - for (final Map.Entry entry : mapToFunction.entrySet()) { + for (final Map.Entry entry : mapToFunction.entrySet()) { final String map = entry.getKey(); - final GroovyStaticImportGenerator.JavaFunction function = entry.getValue(); + final JavaFunction function = entry.getValue(); final boolean oneArg = function.getParameterNames().length == 1; if (oneArg) { @@ -429,12 +429,12 @@ private String createInitializeFunctionTransform() { return indent(2) + "this.series.initializeSeries((SERIES2) series);\n" + indent(1) + "}\n"; } - private Map> createFunctionToGenerics( - Collection functionSet) { - final Map> map = new HashMap<>(); + private Map> createFunctionToGenerics( + Collection functionSet) { + final Map> map = new HashMap<>(); final Map generics = new HashMap<>(); final Map counter = new HashMap<>(); - for (final GroovyStaticImportGenerator.JavaFunction function : functionSet) { + for (final JavaFunction function : functionSet) { for (TypeVariable typeVariable : function.getTypeParameters()) { final String typeName = typeVariable.getTypeName(); final Type[] bounds = typeVariable.getBounds(); @@ -466,11 +466,11 @@ private Map> } private String createGenericInitializeSeries( - final Map mapToFunction, - final Map> functionToGenerics) { + final Map mapToFunction, + final Map> functionToGenerics) { final List args = new ArrayList<>(); final Set variableNames = new HashSet<>(); - for (final GroovyStaticImportGenerator.JavaFunction function : mapToFunction.values()) { + for (final JavaFunction function : mapToFunction.values()) { for (final TypeVariable typeVariable : function.getTypeParameters()) { String genericTypes = getGenericTypes(typeVariable); if (!genericTypes.isEmpty()) { @@ -487,7 +487,7 @@ private String createGenericInitializeSeries( return args.isEmpty() ? "" : "<" + String.join(", ", args) + "> "; } - private String createMapName(final GroovyStaticImportGenerator.JavaFunction function) { + private String createMapName(final JavaFunction function) { return "%METHOD%SeriesNameTo%TYPES%Map".replaceAll("%TYPES%", createArgsString(function)) .replaceAll("%METHOD%", function.getMethodName()); } @@ -497,7 +497,7 @@ private String createMap(String mapType, final String mapName) { ".HashMapWithDefault<>();\n"; } - private String createMethod(final String returnClass, final GroovyStaticImportGenerator.JavaFunction function, + private String createMethod(final String returnClass, final JavaFunction function, final String mapName) { final StringBuilder code = new StringBuilder(); code.append(createMethodHeader(returnClass, function)); @@ -519,7 +519,7 @@ private String createGetter(String mapType, String mapName) { } private String createMethodWithFunctionParameter(String returnClass, - GroovyStaticImportGenerator.JavaFunction function) throws ClassNotFoundException { + JavaFunction function) throws ClassNotFoundException { final StringBuilder code = new StringBuilder(); code.append(createMethodHeader(returnClass, function)); if (isTransform) { @@ -533,7 +533,7 @@ private String createMethodWithFunctionParameter(String returnClass, return code.toString(); } - private String createFunctionalBody(final String returnClass, GroovyStaticImportGenerator.JavaFunction function) + private String createFunctionalBody(final String returnClass, JavaFunction function) throws ClassNotFoundException { if (function.getParameterTypes()[0].getTypeName().startsWith("groovy.lang.Closure")) { return indent(2) + "return " + function.getMethodName() @@ -556,7 +556,7 @@ private String createFunctionalBody(final String returnClass, GroovyStaticImport } private String getFigureFunctionInput(final String returnClass, - final GroovyStaticImportGenerator.JavaFunction function, final String tableMethodName) + final JavaFunction function, final String tableMethodName) throws ClassNotFoundException { final StringBuilder code = new StringBuilder(); code.append(isSwappable ? "new SelectableDataSetSwappableTable(getSwappableTable()), " @@ -626,17 +626,17 @@ private String getFigureFunctionInput(final String returnClass, return code.toString(); } - private static GroovyStaticImportGenerator.JavaFunction[] filterBadMethods( - final GroovyStaticImportGenerator.JavaFunction[] functions) { - final List retList = new ArrayList<>(); + private static JavaFunction[] filterBadMethods( + final JavaFunction[] functions) { + final List retList = new ArrayList<>(); - final Map, GroovyStaticImportGenerator.JavaFunction> functionMap = new HashMap<>(); + final Map, JavaFunction> functionMap = new HashMap<>(); - for (final GroovyStaticImportGenerator.JavaFunction function : functions) { + for (final JavaFunction function : functions) { if (function.getParameterTypes()[0].getTypeName().contains("Function")) { final Pair methodPair = new Pair<>(function.getMethodName(), function.getParameterNames().length); - final GroovyStaticImportGenerator.JavaFunction oldFunction = functionMap.get(methodPair); + final JavaFunction oldFunction = functionMap.get(methodPair); if (oldFunction != null) { if (oldFunction.getTypeParameters().length < 1 && function.getTypeParameters().length > 0) { @@ -652,10 +652,10 @@ private static GroovyStaticImportGenerator.JavaFunction[] filterBadMethods( } retList.addAll(functionMap.values()); - return retList.toArray(new GroovyStaticImportGenerator.JavaFunction[0]); + return retList.toArray(new JavaFunction[0]); } - private String getFunctionInput(GroovyStaticImportGenerator.JavaFunction function) { + private String getFunctionInput(JavaFunction function) { if (function.getMethodName().endsWith("ByX")) { return "getX()"; } else if (function.getMethodName().endsWith("ByY")) { @@ -668,7 +668,7 @@ private String getFunctionInput(GroovyStaticImportGenerator.JavaFunction functio + function.getMethodName() + " param class " + function.getParameterTypes()[0].getClass()); } - private String getReturnTypeName(final GroovyStaticImportGenerator.JavaFunction function) { + private String getReturnTypeName(final JavaFunction function) { if (function.getTypeParameters().length < 1) { // non generics final String[] params = function.getParameterTypes()[0].getTypeName().split(","); final String returnType = params[params.length - 1]; @@ -709,7 +709,7 @@ private String getColumnNameConstant(String methodName) { throw new IllegalStateException("No column name constant corresponds to method name " + methodName); } - private String createTransformBody(final GroovyStaticImportGenerator.JavaFunction function) { + private String createTransformBody(final JavaFunction function) { final List args = new ArrayList<>(); Collections.addAll(args, function.getParameterNames()); args.add("multiSeriesKey"); @@ -717,7 +717,7 @@ private String createTransformBody(final GroovyStaticImportGenerator.JavaFunctio + function.getMethodName() + "(" + String.join(", ", args) + ");\n" + indent(1) + "}\n\n"; } - private String createExceptionMethodBody(final GroovyStaticImportGenerator.JavaFunction function) { + private String createExceptionMethodBody(final JavaFunction function) { return indent(2) + "throw new PlotUnsupportedOperationException(\"DataSeries \" + this.getClass() + \" does not support method " + function.getMethodName() + " for arguments " + Arrays.toString(function.getParameterTypes()) @@ -726,7 +726,7 @@ private String createExceptionMethodBody(final GroovyStaticImportGenerator.JavaF } private String createMethodHeader(final String returnClass, - final GroovyStaticImportGenerator.JavaFunction function) { + final JavaFunction function) { String methodHeader = indent(1) + (!isInterface ? "@Override public " : "") + getGenericTypes(function) + returnClass + (isGeneric ? "" : "") + " " + function.getMethodName() + "("; @@ -746,7 +746,7 @@ private String createMethodHeader(final String returnClass, + (!isInterface ? " {\n" : ";\n"); } - private String getGenericTypes(final GroovyStaticImportGenerator.JavaFunction function) { + private String getGenericTypes(final JavaFunction function) { final TypeVariable[] typeParameters = function.getTypeParameters(); if (typeParameters.length == 0) { return ""; @@ -770,7 +770,7 @@ private String getGenericTypes(TypeVariable typeVariable) { return typeVariable.getName() + (bounds.isEmpty() ? "" : " extends " + String.join(" & ", bounds)); } - private String createMapCode(final GroovyStaticImportGenerator.JavaFunction function, final String mapName) { + private String createMapCode(final JavaFunction function, final String mapName) { final Type[] vars = function.getParameterTypes(); final String[] names = function.getParameterNames(); final StringBuilder code = new StringBuilder(); @@ -832,7 +832,7 @@ private String createMapCode(final GroovyStaticImportGenerator.JavaFunction func .toString(); } - private String createSmartKeyArgs(final GroovyStaticImportGenerator.JavaFunction function, + private String createSmartKeyArgs(final JavaFunction function, final Map tableToTableHandleVarMap) { List args = new ArrayList<>(); final Type[] vars = function.getParameterTypes(); @@ -852,7 +852,7 @@ private String createSmartKeyArgs(final GroovyStaticImportGenerator.JavaFunction return String.join(", ", args); } - private String createArgsString(final GroovyStaticImportGenerator.JavaFunction function) { + private String createArgsString(final JavaFunction function) { StringBuilder args = new StringBuilder(); for (final Type type : function.getParameterTypes()) { String typeName = type.getTypeName(); @@ -865,7 +865,7 @@ private String createArgsString(final GroovyStaticImportGenerator.JavaFunction f } } - private static String getMapType(GroovyStaticImportGenerator.JavaFunction function) { + private static String getMapType(JavaFunction function) { final String className; final Type[] types = function.getParameterTypes(); if (types.length == 1) { diff --git a/Generators/src/main/java/io/deephaven/plot/util/GeneratePlottingConvenience.java b/Generators/src/main/java/io/deephaven/plot/util/GeneratePlottingConvenience.java index 99c7feabac0..91479a48973 100644 --- a/Generators/src/main/java/io/deephaven/plot/util/GeneratePlottingConvenience.java +++ b/Generators/src/main/java/io/deephaven/plot/util/GeneratePlottingConvenience.java @@ -5,7 +5,7 @@ import io.deephaven.plot.BaseFigureImpl; import io.deephaven.plot.FigureImpl; -import io.deephaven.libs.GroovyStaticImportGenerator.JavaFunction; +import io.deephaven.gen.JavaFunction; import java.lang.reflect.WildcardType; import java.io.IOException; diff --git a/Generators/src/main/java/io/deephaven/plot/util/GeneratePyV2FigureAPI.java b/Generators/src/main/java/io/deephaven/plot/util/GeneratePyV2FigureAPI.java index f13655cd750..d06e32397e3 100644 --- a/Generators/src/main/java/io/deephaven/plot/util/GeneratePyV2FigureAPI.java +++ b/Generators/src/main/java/io/deephaven/plot/util/GeneratePyV2FigureAPI.java @@ -4,7 +4,7 @@ package io.deephaven.plot.util; import io.deephaven.base.Pair; -import io.deephaven.libs.GroovyStaticImportGenerator.JavaFunction; +import io.deephaven.gen.JavaFunction; import org.jetbrains.annotations.NotNull; import java.io.File; From 582d4bd1d0b8816bd621dbbcb1e1e33e131faacf Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Wed, 1 Nov 2023 12:33:44 -0600 Subject: [PATCH 055/150] Refactoring code gen --- .../main/java/io/deephaven/gen/GenUtils.java | 30 +++++++++-- .../java/io/deephaven/gen/JavaFunction.java | 20 ++++++++ .../libs/GroovyStaticImportGenerator.java | 21 +------- .../plot/util/GenerateFigureImmutable.java | 12 +---- .../util/GeneratePlottingConvenience.java | 51 ++----------------- 5 files changed, 53 insertions(+), 81 deletions(-) diff --git a/Generators/src/main/java/io/deephaven/gen/GenUtils.java b/Generators/src/main/java/io/deephaven/gen/GenUtils.java index 34c3e400dbf..25f2caa0cd5 100644 --- a/Generators/src/main/java/io/deephaven/gen/GenUtils.java +++ b/Generators/src/main/java/io/deephaven/gen/GenUtils.java @@ -1,9 +1,8 @@ package io.deephaven.gen; -import java.lang.reflect.GenericArrayType; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; +import org.jetbrains.annotations.NotNull; + +import java.lang.reflect.*; import java.util.LinkedHashSet; import java.util.Set; @@ -36,6 +35,9 @@ public static Set typesToImport(Type t) { } else if (t instanceof TypeVariable) { // type variables are generic so they don't need importing return result; + } else if (t instanceof WildcardType) { + // type variables are generic so they don't need importing + return result; } else if (t instanceof GenericArrayType) { GenericArrayType at = (GenericArrayType) t; return typesToImport(at.getGenericComponentType()); @@ -45,4 +47,24 @@ public static Set typesToImport(Type t) { return result; } + + /** + * Helper to transform method parameter types to a form that can be used in a javadoc link, including removing + * generics and finding the upper bound of typevars. + */ + @NotNull + public static String getParamTypeString(Type t) { + if (t instanceof ParameterizedType) { + return ((ParameterizedType) t).getRawType().getTypeName(); + } else if (t instanceof TypeVariable) { + return getParamTypeString(((TypeVariable) t).getBounds()[0]); + } else if (t instanceof WildcardType) { + return getParamTypeString(((WildcardType) t).getUpperBounds()[0]); + } else if (t instanceof GenericArrayType) { + return getParamTypeString(((GenericArrayType) t).getGenericComponentType()) + "[]"; + } + return t.getTypeName(); + } + + } diff --git a/Generators/src/main/java/io/deephaven/gen/JavaFunction.java b/Generators/src/main/java/io/deephaven/gen/JavaFunction.java index 8143d57e1e2..7b1e039e85f 100644 --- a/Generators/src/main/java/io/deephaven/gen/JavaFunction.java +++ b/Generators/src/main/java/io/deephaven/gen/JavaFunction.java @@ -160,4 +160,24 @@ public String[] getParameterNames() { public boolean isVarArgs() { return isVarArgs; } + + /** + * Creates a new JavaFunction with the same signature, but with new class and method names. + * + * @param className class name or null if the current name should be used. + * @param classNameShort short class name or null if the current short name should be used. + * @param methodName method name or null if the current name should be used. + * @return a new JavaFunction with the same signature, but with new class and method names. + */ + public JavaFunction relocate(final String className, final String classNameShort, final String methodName) { + return new JavaFunction( + className == null ? this.className : className, + classNameShort == null ? this.classNameShort : classNameShort, + methodName == null ? this.methodName : methodName, + getTypeParameters(), + getReturnType(), + getParameterTypes(), + getParameterNames(), + isVarArgs()); + } } diff --git a/Generators/src/main/java/io/deephaven/libs/GroovyStaticImportGenerator.java b/Generators/src/main/java/io/deephaven/libs/GroovyStaticImportGenerator.java index ccef0eb4b1c..b488128be13 100644 --- a/Generators/src/main/java/io/deephaven/libs/GroovyStaticImportGenerator.java +++ b/Generators/src/main/java/io/deephaven/libs/GroovyStaticImportGenerator.java @@ -3,6 +3,7 @@ */ package io.deephaven.libs; +import io.deephaven.gen.GenUtils; import io.deephaven.gen.JavaFunction; import org.jetbrains.annotations.NotNull; @@ -127,7 +128,7 @@ private String generateCode() { String returnType = f.getReturnType().getTypeName(); String s = " /** @see " + f.getClassName() + "#" + f.getMethodName() + "(" + - Arrays.stream(f.getParameterTypes()).map(this::getParamTypeString) + Arrays.stream(f.getParameterTypes()).map(GenUtils::getParamTypeString) .collect(Collectors.joining(",")) + ") */\n" + @@ -190,24 +191,6 @@ private String generateCode() { return code; } - /** - * Helper to transform method parameter types to a form that can be used in a javadoc link, including removing - * generics and finding the upper bound of typevars. - */ - @NotNull - private String getParamTypeString(Type t) { - if (t instanceof ParameterizedType) { - return ((ParameterizedType) t).getRawType().getTypeName(); - } else if (t instanceof TypeVariable) { - return getParamTypeString(((TypeVariable) t).getBounds()[0]); - } else if (t instanceof WildcardType) { - return getParamTypeString(((WildcardType) t).getUpperBounds()[0]); - } else if (t instanceof GenericArrayType) { - return getParamTypeString(((GenericArrayType) t).getGenericComponentType()) + "[]"; - } - return t.getTypeName(); - } - public static void main(String[] args) throws ClassNotFoundException, IOException { String devroot = null; diff --git a/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java b/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java index 6bedbf359f9..be8347622ca 100644 --- a/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java +++ b/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java @@ -91,15 +91,7 @@ private boolean skip(final JavaFunction f) { private JavaFunction signature(final JavaFunction f) { - return new JavaFunction( - outputClass, - outputClassNameShort, - functionNamer.apply(f), - f.getTypeParameters(), - f.getReturnType(), - f.getParameterTypes(), - f.getParameterNames(), - f.isVarArgs()); + return f.relocate(outputClass, outputClassNameShort, functionNamer.apply(f)); } private void addPublicNonStatic(Method m) { @@ -716,7 +708,7 @@ private static String createCallArgs(final JavaFunction f) { private String createFunction(final JavaFunction f) { final String returnType = f.getReturnType().getTypeName().replace("$", "."); - final Class returnClass = f.getReturnClass(); + final Class returnClass = f.getReturnClass(); final JavaFunction signature = signature(f); String s = createFunctionSignature(f); diff --git a/Generators/src/main/java/io/deephaven/plot/util/GeneratePlottingConvenience.java b/Generators/src/main/java/io/deephaven/plot/util/GeneratePlottingConvenience.java index 91479a48973..2d533bd0504 100644 --- a/Generators/src/main/java/io/deephaven/plot/util/GeneratePlottingConvenience.java +++ b/Generators/src/main/java/io/deephaven/plot/util/GeneratePlottingConvenience.java @@ -6,7 +6,6 @@ import io.deephaven.plot.BaseFigureImpl; import io.deephaven.plot.FigureImpl; import io.deephaven.gen.JavaFunction; -import java.lang.reflect.WildcardType; import java.io.IOException; import java.io.PrintWriter; @@ -19,12 +18,14 @@ import java.util.logging.Level; import java.util.logging.Logger; +import static io.deephaven.gen.GenUtils.typesToImport; import static io.deephaven.plot.util.PlotGeneratorUtils.indent; /** * Create static functions that resolve against the last created instance of a plotting figure class. This is to make a * cleaner plotting interface */ +@SuppressWarnings("StringConcatenationInLoop") public class GeneratePlottingConvenience { // See also GroovyStaticImportGenerator @@ -102,15 +103,7 @@ private void addPublicMethod(Method m, Map functions log.info("Processing public method: " + m); final JavaFunction f = new JavaFunction(m); - final JavaFunction signature = new JavaFunction( - OUTPUT_CLASS, - OUTPUT_CLASS_NAME_SHORT, - functionNamer.apply(f), - f.getTypeParameters(), - f.getReturnType(), - f.getParameterTypes(), - f.getParameterNames(), - f.isVarArgs()); + final JavaFunction signature = f.relocate(OUTPUT_CLASS, OUTPUT_CLASS_NAME_SHORT, functionNamer.apply(f)); boolean skip = skip(f, ignoreSkips); @@ -150,44 +143,6 @@ private Set generateImports() { return imports; } - private static Set typesToImport(Type t) { - Set result = new LinkedHashSet<>(); - - if (t instanceof Class) { - final Class c = (Class) t; - final boolean isArray = c.isArray(); - final boolean isPrimitive = c.isPrimitive(); - - if (isPrimitive) { - return result; - } else if (isArray) { - return typesToImport(c.getComponentType()); - } else { - result.add(t.getTypeName()); - } - } else if (t instanceof ParameterizedType) { - final ParameterizedType pt = (ParameterizedType) t; - result.add(pt.getRawType().getTypeName()); - - for (Type a : pt.getActualTypeArguments()) { - result.addAll(typesToImport(a)); - } - } else if (t instanceof TypeVariable) { - // type variables are generic so they don't need importing - return result; - } else if (t instanceof WildcardType) { - // type variables are generic so they don't need importing - return result; - } else if (t instanceof GenericArrayType) { - GenericArrayType at = (GenericArrayType) t; - return typesToImport(at.getGenericComponentType()); - } else { - throw new UnsupportedOperationException("Unsupported Type type: " + t.getClass()); - } - - return result; - } - private String generateCode() { String code = "/**\n" + From 27dd6a878d41f607f0619d983f4d4bd3e39f3a1e Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Wed, 1 Nov 2023 14:29:15 -0600 Subject: [PATCH 056/150] Make axis transforms compile --- .../AxisTransformBusinessCalendar.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Plot/src/main/java/io/deephaven/plot/axistransformations/AxisTransformBusinessCalendar.java b/Plot/src/main/java/io/deephaven/plot/axistransformations/AxisTransformBusinessCalendar.java index 56d50074268..c8fbbb095d1 100644 --- a/Plot/src/main/java/io/deephaven/plot/axistransformations/AxisTransformBusinessCalendar.java +++ b/Plot/src/main/java/io/deephaven/plot/axistransformations/AxisTransformBusinessCalendar.java @@ -28,10 +28,10 @@ public class AxisTransformBusinessCalendar implements AxisTransform, Serializabl private static final long serialVersionUID = -8648623559661981847L; private static class Nugget { - private final BusinessSchedule businessDay; + private final BusinessSchedule businessDay; private final long cumulativeBusinessTimeNanosAtStartOfDay; - private Nugget(BusinessSchedule day, long cumulativeBusinessTimeNanosAtStartOfDay) { + private Nugget(BusinessSchedule day, long cumulativeBusinessTimeNanosAtStartOfDay) { this.businessDay = day; this.cumulativeBusinessTimeNanosAtStartOfDay = cumulativeBusinessTimeNanosAtStartOfDay; } @@ -65,14 +65,14 @@ private Nugget getNuggetByTime(final double timeNanos) { if (nMin == null) { final Instant t = DateTimeUtils.epochNanosToInstant((long) timeNanos); - nMin = new Nugget(busCal.businessSchedule(busCal.pastBusinessDate(t)), 0); + nMin = new Nugget(busCal.businessSchedule(busCal.minusBusinessDays(t,1)), 0); nMax = nMin; nuggets.add(nMin); } while (timeNanos < DateTimeUtils.epochNanos(nMin.businessDay.businessStart())) { - final BusinessSchedule d = - busCal.businessSchedule(busCal.pastBusinessDate(nMin.businessDay.businessStart())); + final BusinessSchedule d = + busCal.businessSchedule(busCal.minusBusinessDays(nMin.businessDay.businessStart(),1)); final Nugget n = new Nugget(d, nMin.cumulativeBusinessTimeNanosAtStartOfDay - d.businessNanos()); nuggets.add(0, n); @@ -81,7 +81,7 @@ private Nugget getNuggetByTime(final double timeNanos) { // noinspection ConstantConditions nMax can't cause NPE (for now! Don't add nulls to nuggets!) while (timeNanos > DateTimeUtils.epochNanos(nMax.businessDay.businessEnd())) { - final BusinessSchedule d = busCal.businessSchedule(busCal.futureBusinessDate(nMax.businessDay.businessEnd())); + final BusinessSchedule d = busCal.businessSchedule(busCal.plusBusinessDays(nMax.businessDay.businessEnd(),1)); final Nugget n = new Nugget(d, nMax.cumulativeBusinessTimeNanosAtStartOfDay + nMax.businessDay.businessNanos()); nuggets.add(n); @@ -104,8 +104,8 @@ private Nugget getNuggetByValue(final double value) { } while (value < nMin.cumulativeBusinessTimeNanosAtStartOfDay) { - final BusinessSchedule d = - busCal.businessSchedule(busCal.pastBusinessDate(nMin.businessDay.businessStart())); + final BusinessSchedule d = + busCal.businessSchedule(busCal.minusBusinessDays(nMin.businessDay.businessStart(),1)); final Nugget n = new Nugget(d, nMin.cumulativeBusinessTimeNanosAtStartOfDay - d.businessNanos()); nuggets.add(0, n); @@ -117,7 +117,7 @@ private Nugget getNuggetByValue(final double value) { } while (value > nMax.cumulativeBusinessTimeNanosAtStartOfDay + nMax.businessDay.businessNanos()) { - final BusinessSchedule d = busCal.businessSchedule(busCal.futureBusinessDate(nMax.businessDay.businessEnd())); + final BusinessSchedule d = busCal.businessSchedule(busCal.plusBusinessDays(nMax.businessDay.businessEnd(),1)); final Nugget n = new Nugget(d, nMax.cumulativeBusinessTimeNanosAtStartOfDay + nMax.businessDay.businessNanos()); nuggets.add(n); @@ -174,7 +174,7 @@ public double inverseTransform(final double value) { double busDayNanos = value - n.cumulativeBusinessTimeNanosAtStartOfDay; double timeNanos = DateTimeUtils.epochNanos(n.businessDay.businessStart()); - for (BusinessPeriod period : n.businessDay.periods()) { + for (BusinessPeriod period : n.businessDay.periods()) { final double start = DateTimeUtils.epochNanos(period.start()); final double end = DateTimeUtils.epochNanos(period.end()); final double length = end - start; @@ -203,7 +203,7 @@ public double transform(final double timeNanos) { double value = n.cumulativeBusinessTimeNanosAtStartOfDay; - for (BusinessPeriod period : n.businessDay.periods()) { + for (BusinessPeriod period : n.businessDay.periods()) { final double start = DateTimeUtils.epochNanos(period.start()); final double end = DateTimeUtils.epochNanos(period.end()); From 986ad6b15ae10be277b5af483fc64aceef64e239 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Wed, 1 Nov 2023 15:19:44 -0600 Subject: [PATCH 057/150] Refactoring code gen. Not fully working. --- .../main/java/io/deephaven/gen/GenUtils.java | 152 +++++++++ .../java/io/deephaven/gen/JavaFunction.java | 5 +- .../libs/GroovyStaticImportGenerator.java | 84 +---- .../plot/util/GenerateAxesPlotMethods.java | 7 +- .../plot/util/GenerateFigureImmutable.java | 300 +++++++----------- .../plot/util/GenerateMultiSeries.java | 10 +- .../util/GeneratePlottingConvenience.java | 93 +----- .../plot/util/GeneratePyV2FigureAPI.java | 6 +- .../plot/util/PlotGeneratorUtils.java | 31 -- .../main/java/io/deephaven/plot/Figure.java | 2 +- .../java/io/deephaven/plot/FigureImpl.java | 2 +- .../deephaven/plot/PlottingConvenience.java | 2 +- 12 files changed, 313 insertions(+), 381 deletions(-) delete mode 100644 Generators/src/main/java/io/deephaven/plot/util/PlotGeneratorUtils.java diff --git a/Generators/src/main/java/io/deephaven/gen/GenUtils.java b/Generators/src/main/java/io/deephaven/gen/GenUtils.java index 25f2caa0cd5..15136cb5e10 100644 --- a/Generators/src/main/java/io/deephaven/gen/GenUtils.java +++ b/Generators/src/main/java/io/deephaven/gen/GenUtils.java @@ -1,15 +1,75 @@ package io.deephaven.gen; +import gnu.trove.map.TIntObjectMap; +import gnu.trove.map.hash.TIntObjectHashMap; import org.jetbrains.annotations.NotNull; import java.lang.reflect.*; +import java.util.Arrays; +import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; +import java.util.logging.Logger; +@SuppressWarnings("StringConcatenationInLoop") public class GenUtils { private GenUtils() { } + //TODO: rename functions + + private static final Logger log = Logger.getLogger(GenUtils.class.toString()); + + private static final TIntObjectMap cachedIndents = new TIntObjectHashMap<>(); + + /** + * Get a String of spaces for indenting code. + * + * @param n The number of indents + * @return The String for indenting code with spaces + */ + public static String indent(final int n) { + String cached = cachedIndents.get(n); + if (cached == null) { + cachedIndents.put(n, cached = String.join("", Collections.nCopies(4 * n, " "))); + } + return cached; + } + + /** + * Creates the header for a generated java file. + * + * @param generatorClass class used to generate the code. + * @param gradleTask gradle task to generate the code. + * @return The header for a generated java file + */ + public static String javaHeader(final Class generatorClass, final String gradleTask) { + return "/**\n" + + " * Copyright (c) 2016-2023 Deephaven Data Labs and Patent Pending\n" + + " */\n" + + "/****************************************************************************************************************************\n" + + + " ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - Run " + generatorClass.getSimpleName() + " or \"./gradlew " + gradleTask + "\" to regenerate\n" + + + " ****************************************************************************************************************************/\n\n"; + + } + + /** + * Assert that the generated code is the same as the old code. + * + * @param generatorClass class used to generate the code. + * @param gradleTask gradle task to generate the code. + * @param oldCode old code + * @param newCode new code + */ + public static void assertGeneratedCodeSame(final Class generatorClass, final String gradleTask, final String oldCode, final String newCode) { + if (!newCode.equals(oldCode)) { + throw new RuntimeException( + "Change in generated code. Run " + generatorClass + " or \"./gradlew " + gradleTask + "\" to regenerate\n"); + } + } + public static Set typesToImport(Type t) { Set result = new LinkedHashSet<>(); @@ -66,5 +126,97 @@ public static String getParamTypeString(Type t) { return t.getTypeName(); } + /** + * Creates an argument string for a function. + * + * @param f function. + * @param includeTypes true to include types of the argument parameters; false to just include the parameter names. + * @return argument string. + */ + public static String argString(final JavaFunction f, boolean includeTypes) { + String callArgs = ""; + + for (int i = 0; i < f.getParameterTypes().length; i++) { + if (i != 0) { + callArgs += ","; + } + + Type t = f.getParameterTypes()[i]; + + String typeString = t.getTypeName().replace("$", "."); + + if (f.isVarArgs() && i == f.getParameterTypes().length - 1) { + final int index = typeString.lastIndexOf("[]"); + typeString = typeString.substring(0, index) + "..." + typeString.substring(index + 2); + } + if(includeTypes) { + callArgs += " " + typeString; + } + + callArgs += " " + f.getParameterNames()[i]; + } + + return callArgs; + } + + /** + * Create code for a function signature. + * + * @param f function signature. + * @param sigPrefix sigPrefix to add to the function signature (e.g. "public static"). + * @return code for the function signature. + */ + public static String createFunctionSignature(final JavaFunction f, final String sigPrefix) { + String returnType = f.getReturnType().getTypeName().replace("$", "."); + String s = indent(1) + (sigPrefix == null || sigPrefix.equals("") ? "" : (sigPrefix + " ")); + + if (f.getTypeParameters().length > 0) { + s += "<"; + + for (int i = 0; i < f.getTypeParameters().length; i++) { + if (i != 0) { + s += ","; + } + + TypeVariable t = f.getTypeParameters()[i]; + log.info("BOUNDS: " + Arrays.toString(t.getBounds())); + s += t; + + Type[] bounds = t.getBounds(); + + if (bounds.length != 1) { + throw new RuntimeException("Unsupported bounds: " + Arrays.toString(bounds)); + } + + Type bound = bounds[0]; + + if (!bound.equals(Object.class)) { + s += " extends " + bound.getTypeName(); + } + + } + + s += ">"; + } + + s += " " + returnType + " " + f.getMethodName() + "(" + argString(f, true) + " )"; + return s; + } + + /** + * Create a function with the given javadoc and body. + * + * @param f function signature. + * @param sigPrefix sigPrefix to add to the function signature (e.g. "public static"). + * @param javadoc javadoc. + * @param funcBody function body. + * @return code for the function. + */ + public static String createFunction(final JavaFunction f, final String sigPrefix, final String javadoc, final String funcBody) { + String s = javadoc == null || javadoc.equals("") ? "" : (javadoc + "\n"); + s += createFunctionSignature(f, sigPrefix); + s += funcBody; + return s; + } } diff --git a/Generators/src/main/java/io/deephaven/gen/JavaFunction.java b/Generators/src/main/java/io/deephaven/gen/JavaFunction.java index 7b1e039e85f..a6ce94175a6 100644 --- a/Generators/src/main/java/io/deephaven/gen/JavaFunction.java +++ b/Generators/src/main/java/io/deephaven/gen/JavaFunction.java @@ -167,15 +167,16 @@ public boolean isVarArgs() { * @param className class name or null if the current name should be used. * @param classNameShort short class name or null if the current short name should be used. * @param methodName method name or null if the current name should be used. + * @param returnType return type or null if the current return type should be used. * @return a new JavaFunction with the same signature, but with new class and method names. */ - public JavaFunction relocate(final String className, final String classNameShort, final String methodName) { + public JavaFunction transform(final String className, final String classNameShort, final String methodName, Type returnType) { return new JavaFunction( className == null ? this.className : className, classNameShort == null ? this.classNameShort : classNameShort, methodName == null ? this.methodName : methodName, getTypeParameters(), - getReturnType(), + returnType == null ? getReturnType() : returnType, getParameterTypes(), getParameterNames(), isVarArgs()); diff --git a/Generators/src/main/java/io/deephaven/libs/GroovyStaticImportGenerator.java b/Generators/src/main/java/io/deephaven/libs/GroovyStaticImportGenerator.java index b488128be13..2b269e3984f 100644 --- a/Generators/src/main/java/io/deephaven/libs/GroovyStaticImportGenerator.java +++ b/Generators/src/main/java/io/deephaven/libs/GroovyStaticImportGenerator.java @@ -5,7 +5,6 @@ import io.deephaven.gen.GenUtils; import io.deephaven.gen.JavaFunction; -import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.io.PrintWriter; @@ -29,6 +28,7 @@ @SuppressWarnings("StringConcatenationInLoop") public class GroovyStaticImportGenerator { private static final Logger log = Logger.getLogger(GroovyStaticImportGenerator.class.toString()); + private static final String GRADLE_TASK = ":Generators:groovyStaticImportGenerator"; private final Map staticFunctions = new TreeMap<>(); @@ -89,15 +89,7 @@ private Set generateImports() { private String generateCode() { - String code = "/**\n" + - " * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending\n" + - " */\n" + - "/****************************************************************************************************************************\n" - + - " ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - Run GroovyStaticImportGenerator or \"./gradlew :Generators:groovyStaticImportGenerator\" to regenerate\n" - + - " ****************************************************************************************************************************/\n\n"; - + String code = GenUtils.javaHeader(this.getClass(), GRADLE_TASK); code += "package io.deephaven.libs;\n\n"; Set imports = generateImports(); @@ -125,64 +117,15 @@ private String generateCode() { continue; } - String returnType = f.getReturnType().getTypeName(); - String s = - " /** @see " + f.getClassName() + "#" + f.getMethodName() + "(" + - Arrays.stream(f.getParameterTypes()).map(GenUtils::getParamTypeString) - .collect(Collectors.joining(",")) - + - ") */\n" + - " public static "; - - if (f.getTypeParameters().length > 0) { - s += "<"; - - for (int i = 0; i < f.getTypeParameters().length; i++) { - if (i != 0) { - s += ","; - } - - TypeVariable t = f.getTypeParameters()[i]; - log.info("BOUNDS: " + Arrays.toString(t.getBounds())); - s += t; - - Type[] bounds = t.getBounds(); - - if (bounds.length != 1) { - throw new RuntimeException("Unsupported bounds: " + Arrays.toString(bounds)); - } - - Type bound = bounds[0]; - - if (!bound.equals(Object.class)) { - s += " extends " + bound.getTypeName(); - } - - } - - s += ">"; - } - - s += " " + returnType + " " + f.getMethodName() + "("; - String callArgs = ""; - - for (int i = 0; i < f.getParameterTypes().length; i++) { - if (i != 0) { - s += ","; - callArgs += ","; - } - - Type t = f.getParameterTypes()[i]; - - s += " " + t.getTypeName() + " " + f.getParameterNames()[i]; - callArgs += " " + f.getParameterNames()[i]; - } - - s += " ) {"; - s += "return " + f.getClassNameShort() + "." + f.getMethodName() + "(" + callArgs + " );"; - s += "}"; - - code += s; + final String javadoc = " /** @see " + f.getClassName() + "#" + f.getMethodName() + "(" + + Arrays.stream(f.getParameterTypes()).map(GenUtils::getParamTypeString) + .collect(Collectors.joining(",")) + + + ") */"; + final String sigPrefix = "public static"; + final String callArgs = GenUtils.argString(f, false); + final String funcBody = " {return " + f.getClassNameShort() + "." + f.getMethodName() + "(" + callArgs + " );}\n"; + code += GenUtils.createFunction(f, sigPrefix, javadoc, funcBody); code += "\n"; } @@ -234,10 +177,7 @@ public static void main(String[] args) throws ClassNotFoundException, IOExceptio if (assertNoChange) { String oldCode = new String(Files.readAllBytes(Paths.get(file))); - if (!code.equals(oldCode)) { - throw new RuntimeException( - "Change in generated code. Run GroovyStaticImportGenerator or \"./gradlew :Generators:groovyStaticImportGenerator\" to regenerate\n"); - } + GenUtils.assertGeneratedCodeSame(GroovyStaticImportGenerator.class, GRADLE_TASK, oldCode, code); } else { PrintWriter out = new PrintWriter(file); diff --git a/Generators/src/main/java/io/deephaven/plot/util/GenerateAxesPlotMethods.java b/Generators/src/main/java/io/deephaven/plot/util/GenerateAxesPlotMethods.java index f648b10d95a..c2bbba7739f 100644 --- a/Generators/src/main/java/io/deephaven/plot/util/GenerateAxesPlotMethods.java +++ b/Generators/src/main/java/io/deephaven/plot/util/GenerateAxesPlotMethods.java @@ -4,6 +4,7 @@ package io.deephaven.plot.util; import io.deephaven.base.verify.Require; +import io.deephaven.gen.GenUtils; import java.io.IOException; import java.io.PrintWriter; @@ -20,6 +21,7 @@ public class GenerateAxesPlotMethods { private static final Logger log = Logger.getLogger(GenerateAxesPlotMethods.class.toString()); + private static final String GRADLE_TASK = ":Generators:generateAxesPlotMethods"; private static final String PLOT_INFO_ID = "new PlotInfo(this, seriesName)"; @@ -863,10 +865,7 @@ private static void generate(final boolean assertNoChange, final String file, fi if (assertNoChange) { String oldCode = new String(Files.readAllBytes(Paths.get(file))); - if (!newcode.equals(oldCode)) { - throw new RuntimeException( - "Change in generated code. Run GenerateAxesPlotMethods or \"./gradlew :Generators:generateAxesPlotMethods\" to regenerate\n"); - } + GenUtils.assertGeneratedCodeSame(GenerateAxesPlotMethods.class, GRADLE_TASK, oldCode, newcode); } else { PrintWriter out = new PrintWriter(file); diff --git a/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java b/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java index be8347622ca..47cc32c8ecf 100644 --- a/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java +++ b/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java @@ -3,6 +3,7 @@ */ package io.deephaven.plot.util; +import io.deephaven.gen.GenUtils; import io.deephaven.plot.*; import io.deephaven.plot.datasets.DataSeries; import io.deephaven.plot.datasets.multiseries.MultiSeries; @@ -22,8 +23,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static io.deephaven.gen.GenUtils.indent; import static io.deephaven.gen.GenUtils.typesToImport; -import static io.deephaven.plot.util.PlotGeneratorUtils.indent; /** * Creates a functional interface for plotting. @@ -33,6 +34,7 @@ public class GenerateFigureImmutable { // See also GroovyStaticImportGenerator private static final Logger log = Logger.getLogger(GenerateFigureImmutable.class.toString()); + private static final String GRADLE_TASK = ":Generators:generateFigureImmutable"; private static final String CLASS_NAME_INTERFACE = "io.deephaven.plot.Figure"; private static final String CLASS_NAME_IMPLEMENTATION = "io.deephaven.plot.FigureImpl"; @@ -91,7 +93,14 @@ private boolean skip(final JavaFunction f) { private JavaFunction signature(final JavaFunction f) { - return f.relocate(outputClass, outputClassNameShort, functionNamer.apply(f)); + final Type returnType = new Type() { + @Override + public String getTypeName() { + return isInterface ? "Figure" : "FigureImpl"; + } + }; + + return f.transform(outputClass, outputClassNameShort, functionNamer.apply(f), returnType); } private void addPublicNonStatic(Method m) { @@ -166,15 +175,7 @@ private String generateImplements() { private String generateCode() { - String code = "/**\n" + - " * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending\n" + - " */\n" + - "/****************************************************************************************************************************\n" - + - " ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - Run GenerateFigureImmutable or \"./gradlew :Generators:generateFigureImmutable\" to regenerate\n" - + - " ****************************************************************************************************************************/\n\n"; - + String code = GenUtils.javaHeader(GenerateFigureImmutable.class, GRADLE_TASK); code += "package io.deephaven.plot;\n\n"; Set imports = generateImports(); @@ -616,6 +617,7 @@ private String createFigureFuncs() { + "\n"); } + @SuppressWarnings("DuplicateBranchesInSwitch") private static String createInstanceGetter(final JavaFunction f) { switch (f.getClassName()) { case "io.deephaven.plot.BaseFigure": @@ -637,136 +639,73 @@ private static String createInstanceGetter(final JavaFunction f) { } private String createFunctionSignature(final JavaFunction f) { - String s = " " + (isInterface ? "@Override " : "@Override public "); - - if (f.getTypeParameters().length > 0) { - s += "<"; - - for (int i = 0; i < f.getTypeParameters().length; i++) { - if (i != 0) { - s += ","; - } - - TypeVariable t = f.getTypeParameters()[i]; - log.info("BOUNDS: " + Arrays.toString(t.getBounds())); - s += t; - - Type[] bounds = t.getBounds(); - - if (bounds.length != 1) { - throw new RuntimeException("Unsupported bounds: " + Arrays.toString(bounds)); - } - - Type bound = bounds[0]; - - if (!bound.equals(Object.class)) { - s += " extends " + bound.getTypeName(); - } - - } - - s += ">"; - } - - s += " " + outputClassNameShort + " " + f.getMethodName() + "("; - - for (int i = 0; i < f.getParameterTypes().length; i++) { - if (i != 0) { - s += ","; - } - - Type t = f.getParameterTypes()[i]; - - String typeString = t.getTypeName().replace("$", "."); - - if (f.isVarArgs() && i == f.getParameterTypes().length - 1) { - final int index = typeString.lastIndexOf("[]"); - typeString = typeString.substring(0, index) + "..." + typeString.substring(index + 2); - } - - s += " " + typeString + " " + f.getParameterNames()[i]; - } - - s += " )"; - - return s; - } - - private static String createCallArgs(final JavaFunction f) { - String callArgs = ""; - - for (int i = 0; i < f.getParameterTypes().length; i++) { - if (i != 0) { - callArgs += ","; - } - - callArgs += " " + f.getParameterNames()[i]; - } - - return callArgs; + return GenUtils.createFunctionSignature(f, (isInterface ? "@Override" : "@Override public")); } private String createFunction(final JavaFunction f) { - final String returnType = f.getReturnType().getTypeName().replace("$", "."); final Class returnClass = f.getReturnClass(); final JavaFunction signature = signature(f); - String s = createFunctionSignature(f); + String sigPrefix; + String javadoc = null; + String funcBody; if (isInterface) { - return s + ";\n"; - } - - final String callArgs = createCallArgs(f); - - s += " {\n" + indent(2) + "final BaseFigureImpl fc = this.figure.copy();\n"; - - if (returnClass != null && BaseFigure.class.isAssignableFrom(returnClass)) { - s += indent(2) + createInstanceGetter(f) + "." + signature.getMethodName() + "(" + callArgs + ");\n" + - indent(2) + "return make(fc);\n"; - } else if (returnClass != null && Chart.class.isAssignableFrom(returnClass)) { - s += indent(2) + "final ChartImpl chart = (ChartImpl) " + createInstanceGetter(f) + "." - + signature.getMethodName() + "(" + callArgs + ");\n" + - indent(2) + "return make(chart);\n"; - } else if (returnClass != null && Axes.class.isAssignableFrom(returnClass)) { - s += indent(2) + "final AxesImpl axes = (AxesImpl) " + createInstanceGetter(f) + "." - + signature.getMethodName() + "(" + callArgs + ");\n" + - indent(2) + "return make(axes);\n"; - } else if (returnClass != null && Axis.class.isAssignableFrom(returnClass) - && f.getClassName().equals("io.deephaven.plot.Axes")) { - s += indent(2) + "final AxesImpl axes = " + createInstanceGetter(f) + ";\n"; - s += indent(2) + "final AxisImpl axis = (AxisImpl) axes." + signature.getMethodName() + "(" + callArgs - + ");\n" + - indent(2) + "return make(axes, axis);\n"; - } else if (returnClass != null && Axis.class.isAssignableFrom(returnClass)) { - s += indent(2) + "final AxisImpl axis = (AxisImpl) " + createInstanceGetter(f) + "." - + signature.getMethodName() + "(" + callArgs + ");\n" + - indent(2) + "return make(null, axis);\n"; - } else if (returnClass != null && DataSeries.class.isAssignableFrom(returnClass)) { - s += indent(2) + "final DataSeriesInternal series = (DataSeriesInternal) " + createInstanceGetter(f) + "." - + signature.getMethodName() + "(" + callArgs + ");\n" + - indent(2) + "return make(series);\n"; - } else if (returnClass != null && Series.class.isAssignableFrom(returnClass)) { - s += indent(2) + "final SeriesInternal series = (SeriesInternal) " + createInstanceGetter(f) + "." - + signature.getMethodName() + "(" + callArgs + ");\n" + - indent(2) + "return make(series);\n"; - } else if (returnClass != null && MultiSeries.class.isAssignableFrom(returnClass)) { - s += indent(2) + "final " + returnClass.getSimpleName() + " mseries = " + createInstanceGetter(f) + "." - + signature.getMethodName() + "(" + callArgs + ");\n" + - indent(2) + "return make((SeriesInternal) mseries);\n"; - } else if (returnClass != null && void.class.equals(returnClass)) { - s += indent(2) + createInstanceGetter(f) + "." + signature.getMethodName() + "(" + callArgs + ");\n" + - indent(2) + "return make(fc);\n"; + sigPrefix = "@Override "; + funcBody = ";\n"; } else { - System.out.println("WARN: UnsupportedReturnType: " + returnType + " " + f); + final String callArgs = GenUtils.argString(f, false); + sigPrefix = "@Override public"; + funcBody = " {\n" + indent(2) + "final BaseFigureImpl fc = this.figure.copy();\n"; + + if (returnClass != null && BaseFigure.class.isAssignableFrom(returnClass)) { + funcBody += indent(2) + createInstanceGetter(f) + "." + signature.getMethodName() + "(" + callArgs + ");\n" + + indent(2) + "return make(fc);\n"; + } else if (returnClass != null && Chart.class.isAssignableFrom(returnClass)) { + funcBody += indent(2) + "final ChartImpl chart = (ChartImpl) " + createInstanceGetter(f) + "." + + signature.getMethodName() + "(" + callArgs + ");\n" + + indent(2) + "return make(chart);\n"; + } else if (returnClass != null && Axes.class.isAssignableFrom(returnClass)) { + funcBody += indent(2) + "final AxesImpl axes = (AxesImpl) " + createInstanceGetter(f) + "." + + signature.getMethodName() + "(" + callArgs + ");\n" + + indent(2) + "return make(axes);\n"; + } else if (returnClass != null && Axis.class.isAssignableFrom(returnClass) + && f.getClassName().equals("io.deephaven.plot.Axes")) { + funcBody += indent(2) + "final AxesImpl axes = " + createInstanceGetter(f) + ";\n"; + funcBody += indent(2) + "final AxisImpl axis = (AxisImpl) axes." + signature.getMethodName() + "(" + callArgs + + ");\n" + + indent(2) + "return make(axes, axis);\n"; + } else if (returnClass != null && Axis.class.isAssignableFrom(returnClass)) { + funcBody += indent(2) + "final AxisImpl axis = (AxisImpl) " + createInstanceGetter(f) + "." + + signature.getMethodName() + "(" + callArgs + ");\n" + + indent(2) + "return make(null, axis);\n"; + } else if (returnClass != null && DataSeries.class.isAssignableFrom(returnClass)) { + funcBody += indent(2) + "final DataSeriesInternal series = (DataSeriesInternal) " + createInstanceGetter(f) + "." + + signature.getMethodName() + "(" + callArgs + ");\n" + + indent(2) + "return make(series);\n"; + } else if (returnClass != null && Series.class.isAssignableFrom(returnClass)) { + funcBody += indent(2) + "final SeriesInternal series = (SeriesInternal) " + createInstanceGetter(f) + "." + + signature.getMethodName() + "(" + callArgs + ");\n" + + indent(2) + "return make(series);\n"; + } else if (returnClass != null && MultiSeries.class.isAssignableFrom(returnClass)) { + funcBody += indent(2) + "final " + returnClass.getSimpleName() + " mseries = " + createInstanceGetter(f) + "." + + signature.getMethodName() + "(" + callArgs + ");\n" + + indent(2) + "return make((SeriesInternal) mseries);\n"; + } else if (void.class.equals(returnClass)) { + funcBody += indent(2) + createInstanceGetter(f) + "." + signature.getMethodName() + "(" + callArgs + ");\n" + + indent(2) + "return make(fc);\n"; + } else { + final String returnType = f.getReturnType().getTypeName().replace("$", "."); + System.out.println("WARN: UnsupportedReturnType: " + returnType + " " + f); - s += indent(2) + createInstanceGetter(f) + "." + signature.getMethodName() + "(" + callArgs + ");\n" + - indent(2) + "return make(fc);\n"; - } + funcBody += indent(2) + createInstanceGetter(f) + "." + signature.getMethodName() + "(" + callArgs + ");\n" + + indent(2) + "return make(fc);\n"; + } - s += indent(1) + "}\n"; + funcBody += indent(1) + "}\n"; + } - return s; + return GenUtils.createFunction(signature, sigPrefix, javadoc, funcBody); } private String createSignatureGroupFunction(final TreeSet fs) { @@ -778,65 +717,67 @@ private String createSignatureGroupFunction(final TreeSet fs) { final JavaFunction f0 = fs.first(); final JavaFunction s0 = signature(f0); - - final String signature = createFunctionSignature(s0); + String sigPrefix; + String javadoc = null; + String funcBody; if (isInterface) { - return signature + ";\n"; - } - - final String callArgs = createCallArgs(f0); - - String s = signature; - s += " {\n" + - indent(2) + "final BaseFigureImpl fc = this.figure.copy();\n" + - indent(2) + "Series series = series(fc);\n"; + sigPrefix = "@Override"; + funcBody = ";\n"; + } else { + final String callArgs = GenUtils.argString(f0, false); + sigPrefix = "@Override public"; + final String signature = GenUtils.createFunctionSignature(s0, sigPrefix); + funcBody = " {\n" + + indent(2) + "final BaseFigureImpl fc = this.figure.copy();\n" + + indent(2) + "Series series = series(fc);\n"; - boolean firstFunc = true; + boolean firstFunc = true; - for (final JavaFunction f : fs) { - final String returnType = f.getReturnType().getTypeName().replace("$", "."); - Class returnClass = f.getReturnClass(); + for (final JavaFunction f : fs) { + final String returnType = f.getReturnType().getTypeName().replace("$", "."); + Class returnClass = f.getReturnClass(); - if (returnClass == null) { - throw new UnsupportedOperationException("Null return class. f=" + f); - } + if (returnClass == null) { + throw new UnsupportedOperationException("Null return class. f=" + f); + } - if (firstFunc) { - s += indent(2) + "if( series instanceof " + f.getClassNameShort() + "){\n"; - } else { - s += indent(2) + "} else if( series instanceof " + f.getClassNameShort() + "){\n"; - } + if (firstFunc) { + funcBody += indent(2) + "if( series instanceof " + f.getClassNameShort() + "){\n"; + } else { + funcBody += indent(2) + "} else if( series instanceof " + f.getClassNameShort() + "){\n"; + } - s += indent(3) + returnClass.getSimpleName() + " result = ((" + f.getClassNameShort() + ") series)." - + f.getMethodName() + "(" + callArgs + ");\n"; + funcBody += indent(3) + returnClass.getSimpleName() + " result = ((" + f.getClassNameShort() + ") series)." + + f.getMethodName() + "(" + callArgs + ");\n"; + + if (DataSeries.class.isAssignableFrom(returnClass)) { + funcBody += indent(3) + "return make((DataSeriesInternal)result);\n"; + } else if (MultiSeries.class.isAssignableFrom(returnClass) || Series.class.isAssignableFrom(returnClass)) { + funcBody += indent(3) + "return make((SeriesInternal)result);\n"; + } else { + throw new IllegalStateException("UnsupportedReturnType: " + returnType + " " + f); + // System.out.println("WARN: UnsupportedReturnType: " + returnType + " " + f); + // funcBody += indent(3) + "return make(fc);"; + } - if (DataSeries.class.isAssignableFrom(returnClass)) { - s += indent(3) + "return make((DataSeriesInternal)result);\n"; - } else if (MultiSeries.class.isAssignableFrom(returnClass) || Series.class.isAssignableFrom(returnClass)) { - s += indent(3) + "return make((SeriesInternal)result);\n"; - } else { - throw new IllegalStateException("UnsupportedReturnType: " + returnType + " " + f); - // System.out.println("WARN: UnsupportedReturnType: " + returnType + " " + f); - // s += indent(3) + "return make(fc);"; - } + funcBody += indent(2) + "} "; - s += indent(2) + "} "; + if (!f.getClassNameShort().equals("MultiSeries") && !f.getClassNameShort().equals("XYDataSeriesFunction")) { + funcBody += makeMultiSeriesGetter(f); + } - if (!f.getClassNameShort().equals("MultiSeries") && !f.getClassNameShort().equals("XYDataSeriesFunction")) { - s += makeMultiSeriesGetter(f); + firstFunc = false; } - - firstFunc = false; + funcBody += "else {\n" + + indent(3) + + "throw new PlotUnsupportedOperationException(\"Series type does not support this method. seriesType=\" + series.getClass() + \" method='" + + signature.trim() + "'\", figure);\n" + + indent(2) + "}\n"; + funcBody += indent(1) + "}\n"; } - s += "else {\n" + - indent(3) - + "throw new PlotUnsupportedOperationException(\"Series type does not support this method. seriesType=\" + series.getClass() + \" method='" - + signature.trim() + "'\", figure);\n" + - indent(2) + "}\n"; - s += indent(1) + "}\n"; - - return s; + + return GenUtils.createFunction(s0, sigPrefix, javadoc, funcBody); } private Map> commonSignatureGroups( @@ -880,7 +821,6 @@ private static String makeMultiSeriesGetter(final JavaFunction f) { } private static String createMultiSeriesArgs(JavaFunction f) { - final Type[] types = f.getParameterTypes(); final String[] names = f.getParameterNames(); String args = String.join(", ", names); if (!names[names.length - 1].equals("keys")) { @@ -950,7 +890,6 @@ private static void generateFile(final String devroot, final boolean assertNoCha }); - @SuppressWarnings("unchecked") GenerateFigureImmutable gen = new GenerateFigureImmutable(isInterface, imports, interfaces, seriesInterfaces, skips, JavaFunction::getMethodName); @@ -962,10 +901,7 @@ private static void generateFile(final String devroot, final boolean assertNoCha if (assertNoChange) { String oldCode = new String(Files.readAllBytes(Paths.get(file))); - if (!code.equals(oldCode)) { - throw new RuntimeException( - "Change in generated code. Run GenerateFigureImmutable or \"./gradlew :Generators:generateFigureImmutable\" to regenerate\n"); - } + GenUtils.assertGeneratedCodeSame(GenerateFigureImmutable.class, GRADLE_TASK, oldCode, code); } else { PrintWriter out = new PrintWriter(file); diff --git a/Generators/src/main/java/io/deephaven/plot/util/GenerateMultiSeries.java b/Generators/src/main/java/io/deephaven/plot/util/GenerateMultiSeries.java index ac43698bcb6..fce4750c212 100644 --- a/Generators/src/main/java/io/deephaven/plot/util/GenerateMultiSeries.java +++ b/Generators/src/main/java/io/deephaven/plot/util/GenerateMultiSeries.java @@ -5,6 +5,7 @@ import io.deephaven.base.ClassUtil; import io.deephaven.base.Pair; +import io.deephaven.gen.GenUtils; import io.deephaven.gen.JavaFunction; import io.deephaven.plot.util.functions.ClosureFunction; import io.deephaven.engine.table.Table; @@ -23,13 +24,15 @@ import java.util.function.Function; import java.util.logging.Logger; -import static io.deephaven.plot.util.PlotGeneratorUtils.indent; +import static io.deephaven.gen.GenUtils.indent; + /** * Generates methods for the MultiSeries datasets. */ public class GenerateMultiSeries { private static final Logger log = Logger.getLogger(GenerateMultiSeries.class.toString()); + private static final String GRADLE_TASK = ":Generators:generateMultiSeries"; public static void main(String[] args) throws ClassNotFoundException, IOException, NoSuchMethodException { @@ -220,10 +223,7 @@ private void generateCode(final String devroot, final boolean assertNoChange, fi if (assertNoChange) { String oldCode = new String(Files.readAllBytes(Paths.get(outputFile))); - if (!newcode.equals(oldCode)) { - throw new RuntimeException("Change in generated code for " + outputFile - + ". Run GenerateMultiSeries or \"./gradlew :Generators:generateMultiSeries\" to regenerate\n"); - } + GenUtils.assertGeneratedCodeSame(GenerateMultiSeries.class, GRADLE_TASK, oldCode, newcode); } else { PrintWriter out = new PrintWriter(outputFile); out.print(newcode); diff --git a/Generators/src/main/java/io/deephaven/plot/util/GeneratePlottingConvenience.java b/Generators/src/main/java/io/deephaven/plot/util/GeneratePlottingConvenience.java index 2d533bd0504..92fb4286ed7 100644 --- a/Generators/src/main/java/io/deephaven/plot/util/GeneratePlottingConvenience.java +++ b/Generators/src/main/java/io/deephaven/plot/util/GeneratePlottingConvenience.java @@ -3,6 +3,7 @@ */ package io.deephaven.plot.util; +import io.deephaven.gen.GenUtils; import io.deephaven.plot.BaseFigureImpl; import io.deephaven.plot.FigureImpl; import io.deephaven.gen.JavaFunction; @@ -18,8 +19,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import static io.deephaven.gen.GenUtils.indent; import static io.deephaven.gen.GenUtils.typesToImport; -import static io.deephaven.plot.util.PlotGeneratorUtils.indent; /** * Create static functions that resolve against the last created instance of a plotting figure class. This is to make a @@ -30,6 +31,7 @@ public class GeneratePlottingConvenience { // See also GroovyStaticImportGenerator private static final Logger log = Logger.getLogger(GeneratePlottingConvenience.class.toString()); + private static final String GRADLE_TASK = ":Generators:generatePlottingConvenience"; private static final String OUTPUT_CLASS = "io.deephaven.plot.PlottingConvenience"; private static final String OUTPUT_CLASS_NAME_SHORT = OUTPUT_CLASS.substring(OUTPUT_CLASS.lastIndexOf('.') + 1); @@ -103,7 +105,7 @@ private void addPublicMethod(Method m, Map functions log.info("Processing public method: " + m); final JavaFunction f = new JavaFunction(m); - final JavaFunction signature = f.relocate(OUTPUT_CLASS, OUTPUT_CLASS_NAME_SHORT, functionNamer.apply(f)); + final JavaFunction signature = f.transform(OUTPUT_CLASS, OUTPUT_CLASS_NAME_SHORT, functionNamer.apply(f), null); boolean skip = skip(f, ignoreSkips); @@ -145,15 +147,7 @@ private Set generateImports() { private String generateCode() { - String code = "/**\n" + - " * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending\n" + - " */\n" + - "/****************************************************************************************************************************\n" - + - " ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - Run GeneratePlottingConvenience or \"./gradlew :Generators:generatePlottingConvenience\" to regenerate\n" - + - " ****************************************************************************************************************************/\n\n"; - + String code = GenUtils.javaHeader(GeneratePlottingConvenience.class, GRADLE_TASK); code += "package io.deephaven.plot;\n\n"; Set imports = generateImports(); @@ -205,72 +199,19 @@ private String generateCode() { } private static String createFunction(final JavaFunction f, final JavaFunction signature, final boolean isStatic) { - String returnType = f.getReturnType().getTypeName().replace("$", "."); - String s = createJavadoc(f, signature); - s += " public static "; - - if (f.getTypeParameters().length > 0) { - s += "<"; - - for (int i = 0; i < f.getTypeParameters().length; i++) { - if (i != 0) { - s += ","; - } - - TypeVariable t = f.getTypeParameters()[i]; - log.info("BOUNDS: " + Arrays.toString(t.getBounds())); - s += t; - - Type[] bounds = t.getBounds(); - - if (bounds.length != 1) { - throw new RuntimeException("Unsupported bounds: " + Arrays.toString(bounds)); - } - - Type bound = bounds[0]; - - if (!bound.equals(Object.class)) { - s += " extends " + bound.getTypeName(); - } - - } - - s += ">"; - } - - s += " " + returnType + " " + signature.getMethodName() + "("; - String callArgs = ""; - - for (int i = 0; i < f.getParameterTypes().length; i++) { - if (i != 0) { - s += ","; - callArgs += ","; - } - - Type t = f.getParameterTypes()[i]; - - String typeString = t.getTypeName().replace("$", "."); - - if (f.isVarArgs() && i == f.getParameterTypes().length - 1) { - final int index = typeString.lastIndexOf("[]"); - typeString = typeString.substring(0, index) + "..." + typeString.substring(index + 2); - } - - s += " " + typeString + " " + f.getParameterNames()[i]; - callArgs += " " + f.getParameterNames()[i]; - } - - s += " ) {\n"; - s += indent(2) + (f.getReturnType().equals(void.class) ? "" : "return ") + final String javadoc = createJavadoc(f, signature); + final String sigPrefix = "public static"; + final String callArgs = GenUtils.argString(signature, false); + String funcBody = " {\n"; + funcBody += indent(2) + (f.getReturnType().equals(void.class) ? "" : "return ") + (isStatic ? (f.getClassNameShort() + ".") : "FigureFactory.figure().") + f.getMethodName() + "(" + callArgs + " );\n"; - s += indent(1) + "}\n"; - - return s; + funcBody += indent(1) + "}\n"; + return GenUtils.createFunction(signature, sigPrefix, javadoc, funcBody); } private static String createJavadoc(final JavaFunction f, final JavaFunction signature) { - return " /**\n * See {@link " + f.getClassName() + "#" + signature.getMethodName() + "} \n **/\n"; + return " /**\n * See {@link " + f.getClassName() + "#" + signature.getMethodName() + "} \n **/"; } public static void main(String[] args) throws ClassNotFoundException, IOException { @@ -347,9 +288,8 @@ public static void main(String[] args) throws ClassNotFoundException, IOExceptio "catErrorBarBy", "treemapPlot")); - @SuppressWarnings("unchecked") GeneratePlottingConvenience gen = new GeneratePlottingConvenience(staticImports, imports, - Arrays.asList(javaFunction -> !keepers.contains(javaFunction.getMethodName())), + List.of(javaFunction -> !keepers.contains(javaFunction.getMethodName())), JavaFunction::getMethodName); final String code = gen.generateCode() @@ -361,10 +301,7 @@ public static void main(String[] args) throws ClassNotFoundException, IOExceptio if (assertNoChange) { String oldCode = new String(Files.readAllBytes(Paths.get(file))); - if (!code.equals(oldCode)) { - throw new RuntimeException( - "Change in generated code. Run GeneratePlottingConvenience or \"./gradlew :Generators:generatePlottingConvenience\" to regenerate\n"); - } + GenUtils.assertGeneratedCodeSame(GeneratePlottingConvenience.class, GRADLE_TASK, oldCode, code); } else { PrintWriter out = new PrintWriter(file); diff --git a/Generators/src/main/java/io/deephaven/plot/util/GeneratePyV2FigureAPI.java b/Generators/src/main/java/io/deephaven/plot/util/GeneratePyV2FigureAPI.java index d06e32397e3..e9cda5bc6cc 100644 --- a/Generators/src/main/java/io/deephaven/plot/util/GeneratePyV2FigureAPI.java +++ b/Generators/src/main/java/io/deephaven/plot/util/GeneratePyV2FigureAPI.java @@ -4,6 +4,7 @@ package io.deephaven.plot.util; import io.deephaven.base.Pair; +import io.deephaven.gen.GenUtils; import io.deephaven.gen.JavaFunction; import org.jetbrains.annotations.NotNull; @@ -73,10 +74,7 @@ public static void main(String[] args) throws ClassNotFoundException, IOExceptio if (assertNoChange) { String oldCode = new String(Files.readAllBytes(Paths.get(figureWrapperOutput))); - if (!pyCode.equals(oldCode)) { - throw new RuntimeException( - "Change in generated code. Run GeneratePyV2FigureAPI or \"./gradlew :Generators:generatePythonFigureWrapper\" to regenerate\n"); - } + GenUtils.assertGeneratedCodeSame(GeneratePyV2FigureAPI.class, ":Generators:generatePythonFigureWrapper", oldCode, pyCode); } else { try (final PrintWriter out = new PrintWriter(pythonFile)) { out.print(pyCode); diff --git a/Generators/src/main/java/io/deephaven/plot/util/PlotGeneratorUtils.java b/Generators/src/main/java/io/deephaven/plot/util/PlotGeneratorUtils.java deleted file mode 100644 index 9b872de6c19..00000000000 --- a/Generators/src/main/java/io/deephaven/plot/util/PlotGeneratorUtils.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending - */ -package io.deephaven.plot.util; - -import gnu.trove.map.TIntObjectMap; -import gnu.trove.map.hash.TIntObjectHashMap; - -import java.util.Collections; - -/** - * Repository of general utilities for plot code generation. - */ -public class PlotGeneratorUtils { - - private static final TIntObjectMap cachedIndents = new TIntObjectHashMap<>(); - - /** - * Get a String of spaces for indenting code. - * - * @param n The number of indents - * @return The String for indenting code with spaces - */ - static String indent(final int n) { - String cached = cachedIndents.get(n); - if (cached == null) { - cachedIndents.put(n, cached = String.join("", Collections.nCopies(4 * n, " "))); - } - return cached; - } -} diff --git a/Plot/src/main/java/io/deephaven/plot/Figure.java b/Plot/src/main/java/io/deephaven/plot/Figure.java index b25614c53f9..b88826dc4c9 100644 --- a/Plot/src/main/java/io/deephaven/plot/Figure.java +++ b/Plot/src/main/java/io/deephaven/plot/Figure.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending + * Copyright (c) 2016-2023 Deephaven Data Labs and Patent Pending */ /**************************************************************************************************************************** ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - Run GenerateFigureImmutable or "./gradlew :Generators:generateFigureImmutable" to regenerate diff --git a/Plot/src/main/java/io/deephaven/plot/FigureImpl.java b/Plot/src/main/java/io/deephaven/plot/FigureImpl.java index 5fe25773a52..cf257d652a2 100644 --- a/Plot/src/main/java/io/deephaven/plot/FigureImpl.java +++ b/Plot/src/main/java/io/deephaven/plot/FigureImpl.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending + * Copyright (c) 2016-2023 Deephaven Data Labs and Patent Pending */ /**************************************************************************************************************************** ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - Run GenerateFigureImmutable or "./gradlew :Generators:generateFigureImmutable" to regenerate diff --git a/Plot/src/main/java/io/deephaven/plot/PlottingConvenience.java b/Plot/src/main/java/io/deephaven/plot/PlottingConvenience.java index 3b266861ab7..40007965f35 100644 --- a/Plot/src/main/java/io/deephaven/plot/PlottingConvenience.java +++ b/Plot/src/main/java/io/deephaven/plot/PlottingConvenience.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending + * Copyright (c) 2016-2023 Deephaven Data Labs and Patent Pending */ /**************************************************************************************************************************** ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - Run GeneratePlottingConvenience or "./gradlew :Generators:generatePlottingConvenience" to regenerate From 7631d13b2f588b54d7b3c79831cfcfcea1a200fd Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Fri, 3 Nov 2023 08:52:46 -0600 Subject: [PATCH 058/150] Updated GroovyStaticImports --- .../deephaven/libs/GroovyStaticImports.java | 2853 +++++++++++++++-- 1 file changed, 2564 insertions(+), 289 deletions(-) diff --git a/engine/table/src/main/java/io/deephaven/libs/GroovyStaticImports.java b/engine/table/src/main/java/io/deephaven/libs/GroovyStaticImports.java index 4f99780eb8c..f3ba2a1cce9 100644 --- a/engine/table/src/main/java/io/deephaven/libs/GroovyStaticImports.java +++ b/engine/table/src/main/java/io/deephaven/libs/GroovyStaticImports.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending + * Copyright (c) 2016-2023 Deephaven Data Labs and Patent Pending */ /**************************************************************************************************************************** ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - Run GroovyStaticImportGenerator or "./gradlew :Generators:groovyStaticImportGenerator" to regenerate @@ -45,4553 +45,6828 @@ public class GroovyStaticImports { /** @see io.deephaven.function.Numeric#abs(byte) */ public static byte abs( byte value ) {return Numeric.abs( value );} + /** @see io.deephaven.function.Numeric#abs(double) */ public static double abs( double value ) {return Numeric.abs( value );} + /** @see io.deephaven.function.Numeric#abs(float) */ public static float abs( float value ) {return Numeric.abs( value );} + /** @see io.deephaven.function.Numeric#abs(int) */ public static int abs( int value ) {return Numeric.abs( value );} + /** @see io.deephaven.function.Numeric#abs(long) */ public static long abs( long value ) {return Numeric.abs( value );} + /** @see io.deephaven.function.Numeric#abs(short) */ public static short abs( short value ) {return Numeric.abs( value );} + /** @see io.deephaven.function.Numeric#absAvg(byte[]) */ - public static double absAvg( byte[] values ) {return Numeric.absAvg( values );} + public static double absAvg( byte... values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(double[]) */ - public static double absAvg( double[] values ) {return Numeric.absAvg( values );} + public static double absAvg( double... values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(float[]) */ - public static double absAvg( float[] values ) {return Numeric.absAvg( values );} + public static double absAvg( float... values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(int[]) */ - public static double absAvg( int[] values ) {return Numeric.absAvg( values );} + public static double absAvg( int... values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(long[]) */ - public static double absAvg( long[] values ) {return Numeric.absAvg( values );} + public static double absAvg( long... values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(java.lang.Byte[]) */ public static double absAvg( java.lang.Byte[] values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(java.lang.Double[]) */ public static double absAvg( java.lang.Double[] values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(java.lang.Float[]) */ public static double absAvg( java.lang.Float[] values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(java.lang.Integer[]) */ public static double absAvg( java.lang.Integer[] values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(java.lang.Long[]) */ public static double absAvg( java.lang.Long[] values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(java.lang.Short[]) */ public static double absAvg( java.lang.Short[] values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(short[]) */ - public static double absAvg( short[] values ) {return Numeric.absAvg( values );} + public static double absAvg( short... values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(io.deephaven.vector.ByteVector) */ public static double absAvg( io.deephaven.vector.ByteVector values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(io.deephaven.vector.DoubleVector) */ public static double absAvg( io.deephaven.vector.DoubleVector values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(io.deephaven.vector.FloatVector) */ public static double absAvg( io.deephaven.vector.FloatVector values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(io.deephaven.vector.IntVector) */ public static double absAvg( io.deephaven.vector.IntVector values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(io.deephaven.vector.LongVector) */ public static double absAvg( io.deephaven.vector.LongVector values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#absAvg(io.deephaven.vector.ShortVector) */ public static double absAvg( io.deephaven.vector.ShortVector values ) {return Numeric.absAvg( values );} + /** @see io.deephaven.function.Numeric#acos(byte) */ public static double acos( byte value ) {return Numeric.acos( value );} + /** @see io.deephaven.function.Numeric#acos(double) */ public static double acos( double value ) {return Numeric.acos( value );} + /** @see io.deephaven.function.Numeric#acos(float) */ public static double acos( float value ) {return Numeric.acos( value );} + /** @see io.deephaven.function.Numeric#acos(int) */ public static double acos( int value ) {return Numeric.acos( value );} + /** @see io.deephaven.function.Numeric#acos(long) */ public static double acos( long value ) {return Numeric.acos( value );} + /** @see io.deephaven.function.Numeric#acos(short) */ public static double acos( short value ) {return Numeric.acos( value );} + /** @see io.deephaven.function.Logic#and(java.lang.Boolean[]) */ - public static java.lang.Boolean and( java.lang.Boolean[] values ) {return Logic.and( values );} + public static java.lang.Boolean and( java.lang.Boolean... values ) {return Logic.and( values );} + /** @see io.deephaven.function.Logic#and(boolean[]) */ - public static java.lang.Boolean and( boolean[] values ) {return Logic.and( values );} + public static java.lang.Boolean and( boolean... values ) {return Logic.and( values );} + /** @see io.deephaven.function.Logic#and(io.deephaven.vector.ObjectVector) */ public static java.lang.Boolean and( io.deephaven.vector.ObjectVector values ) {return Logic.and( values );} + /** @see io.deephaven.function.Logic#and(java.lang.Boolean[],java.lang.Boolean) */ public static java.lang.Boolean and( java.lang.Boolean[] values, java.lang.Boolean nullValue ) {return Logic.and( values, nullValue );} + /** @see io.deephaven.function.Logic#and(io.deephaven.vector.ObjectVector,java.lang.Boolean) */ public static java.lang.Boolean and( io.deephaven.vector.ObjectVector values, java.lang.Boolean nullValue ) {return Logic.and( values, nullValue );} + /** @see io.deephaven.function.Basic#array(io.deephaven.vector.ByteVector) */ public static byte[] array( io.deephaven.vector.ByteVector values ) {return Basic.array( values );} + /** @see io.deephaven.function.Basic#array(io.deephaven.vector.CharVector) */ public static char[] array( io.deephaven.vector.CharVector values ) {return Basic.array( values );} + /** @see io.deephaven.function.Basic#array(io.deephaven.vector.DoubleVector) */ public static double[] array( io.deephaven.vector.DoubleVector values ) {return Basic.array( values );} + /** @see io.deephaven.function.Basic#array(io.deephaven.vector.FloatVector) */ public static float[] array( io.deephaven.vector.FloatVector values ) {return Basic.array( values );} + /** @see io.deephaven.function.Basic#array(io.deephaven.vector.IntVector) */ public static int[] array( io.deephaven.vector.IntVector values ) {return Basic.array( values );} + /** @see io.deephaven.function.Basic#array(io.deephaven.vector.LongVector) */ public static long[] array( io.deephaven.vector.LongVector values ) {return Basic.array( values );} + /** @see io.deephaven.function.Basic#array(io.deephaven.vector.ShortVector) */ public static short[] array( io.deephaven.vector.ShortVector values ) {return Basic.array( values );} + /** @see io.deephaven.function.Basic#arrayObj(io.deephaven.vector.ObjectVector) */ public static T[] arrayObj( io.deephaven.vector.ObjectVector values ) {return Basic.arrayObj( values );} + /** @see io.deephaven.function.Numeric#asin(byte) */ public static double asin( byte value ) {return Numeric.asin( value );} + /** @see io.deephaven.function.Numeric#asin(double) */ public static double asin( double value ) {return Numeric.asin( value );} + /** @see io.deephaven.function.Numeric#asin(float) */ public static double asin( float value ) {return Numeric.asin( value );} + /** @see io.deephaven.function.Numeric#asin(int) */ public static double asin( int value ) {return Numeric.asin( value );} + /** @see io.deephaven.function.Numeric#asin(long) */ public static double asin( long value ) {return Numeric.asin( value );} + /** @see io.deephaven.function.Numeric#asin(short) */ public static double asin( short value ) {return Numeric.asin( value );} + /** @see io.deephaven.function.Numeric#atan(byte) */ public static double atan( byte value ) {return Numeric.atan( value );} + /** @see io.deephaven.function.Numeric#atan(double) */ public static double atan( double value ) {return Numeric.atan( value );} + /** @see io.deephaven.function.Numeric#atan(float) */ public static double atan( float value ) {return Numeric.atan( value );} + /** @see io.deephaven.function.Numeric#atan(int) */ public static double atan( int value ) {return Numeric.atan( value );} + /** @see io.deephaven.function.Numeric#atan(long) */ public static double atan( long value ) {return Numeric.atan( value );} + /** @see io.deephaven.function.Numeric#atan(short) */ public static double atan( short value ) {return Numeric.atan( value );} + /** @see io.deephaven.function.Numeric#avg(byte[]) */ - public static double avg( byte[] values ) {return Numeric.avg( values );} + public static double avg( byte... values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(double[]) */ - public static double avg( double[] values ) {return Numeric.avg( values );} + public static double avg( double... values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(float[]) */ - public static double avg( float[] values ) {return Numeric.avg( values );} + public static double avg( float... values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(int[]) */ - public static double avg( int[] values ) {return Numeric.avg( values );} + public static double avg( int... values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(long[]) */ - public static double avg( long[] values ) {return Numeric.avg( values );} + public static double avg( long... values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(java.lang.Byte[]) */ public static double avg( java.lang.Byte[] values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(java.lang.Double[]) */ public static double avg( java.lang.Double[] values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(java.lang.Float[]) */ public static double avg( java.lang.Float[] values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(java.lang.Integer[]) */ public static double avg( java.lang.Integer[] values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(java.lang.Long[]) */ public static double avg( java.lang.Long[] values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(java.lang.Short[]) */ public static double avg( java.lang.Short[] values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(short[]) */ - public static double avg( short[] values ) {return Numeric.avg( values );} + public static double avg( short... values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(io.deephaven.vector.ByteVector) */ public static double avg( io.deephaven.vector.ByteVector values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(io.deephaven.vector.DoubleVector) */ public static double avg( io.deephaven.vector.DoubleVector values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(io.deephaven.vector.FloatVector) */ public static double avg( io.deephaven.vector.FloatVector values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(io.deephaven.vector.IntVector) */ public static double avg( io.deephaven.vector.IntVector values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(io.deephaven.vector.LongVector) */ public static double avg( io.deephaven.vector.LongVector values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.Numeric#avg(io.deephaven.vector.ShortVector) */ public static double avg( io.deephaven.vector.ShortVector values ) {return Numeric.avg( values );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(java.lang.Comparable[],java.lang.Comparable,io.deephaven.function.BinSearchAlgo) */ public static > int binSearchIndex( T[] values, T key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(byte[],byte,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( byte[] values, byte key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(char[],char,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( char[] values, char key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(double[],double,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( double[] values, double key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(float[],float,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( float[] values, float key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(int[],int,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( int[] values, int key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(long[],long,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( long[] values, long key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(short[],short,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( short[] values, short key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(io.deephaven.vector.ByteVector,byte,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( io.deephaven.vector.ByteVector values, byte key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(io.deephaven.vector.CharVector,char,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( io.deephaven.vector.CharVector values, char key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(io.deephaven.vector.DoubleVector,double,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( io.deephaven.vector.DoubleVector values, double key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(io.deephaven.vector.FloatVector,float,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( io.deephaven.vector.FloatVector values, float key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(io.deephaven.vector.IntVector,int,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( io.deephaven.vector.IntVector values, int key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(io.deephaven.vector.LongVector,long,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( io.deephaven.vector.LongVector values, long key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(io.deephaven.vector.ShortVector,short,io.deephaven.function.BinSearchAlgo) */ public static int binSearchIndex( io.deephaven.vector.ShortVector values, short key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#binSearchIndex(io.deephaven.vector.ObjectVector,java.lang.Comparable,io.deephaven.function.BinSearchAlgo) */ public static > int binSearchIndex( io.deephaven.vector.ObjectVector values, T key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.binSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.Cast#castDouble(byte) */ public static double castDouble( byte value ) {return Cast.castDouble( value );} + /** @see io.deephaven.function.Cast#castDouble(byte[]) */ - public static double[] castDouble( byte[] values ) {return Cast.castDouble( values );} + public static double[] castDouble( byte... values ) {return Cast.castDouble( values );} + /** @see io.deephaven.function.Cast#castDouble(double[]) */ - public static double[] castDouble( double[] values ) {return Cast.castDouble( values );} + public static double[] castDouble( double... values ) {return Cast.castDouble( values );} + /** @see io.deephaven.function.Cast#castDouble(float[]) */ - public static double[] castDouble( float[] values ) {return Cast.castDouble( values );} + public static double[] castDouble( float... values ) {return Cast.castDouble( values );} + /** @see io.deephaven.function.Cast#castDouble(int[]) */ - public static double[] castDouble( int[] values ) {return Cast.castDouble( values );} + public static double[] castDouble( int... values ) {return Cast.castDouble( values );} + /** @see io.deephaven.function.Cast#castDouble(long[]) */ - public static double[] castDouble( long[] values ) {return Cast.castDouble( values );} + public static double[] castDouble( long... values ) {return Cast.castDouble( values );} + /** @see io.deephaven.function.Cast#castDouble(short[]) */ - public static double[] castDouble( short[] values ) {return Cast.castDouble( values );} + public static double[] castDouble( short... values ) {return Cast.castDouble( values );} + /** @see io.deephaven.function.Cast#castDouble(double) */ public static double castDouble( double value ) {return Cast.castDouble( value );} + /** @see io.deephaven.function.Cast#castDouble(float) */ public static double castDouble( float value ) {return Cast.castDouble( value );} + /** @see io.deephaven.function.Cast#castDouble(int) */ public static double castDouble( int value ) {return Cast.castDouble( value );} + /** @see io.deephaven.function.Cast#castDouble(io.deephaven.vector.ByteVector) */ public static double[] castDouble( io.deephaven.vector.ByteVector values ) {return Cast.castDouble( values );} + /** @see io.deephaven.function.Cast#castDouble(io.deephaven.vector.DoubleVector) */ public static double[] castDouble( io.deephaven.vector.DoubleVector values ) {return Cast.castDouble( values );} + /** @see io.deephaven.function.Cast#castDouble(io.deephaven.vector.FloatVector) */ public static double[] castDouble( io.deephaven.vector.FloatVector values ) {return Cast.castDouble( values );} + /** @see io.deephaven.function.Cast#castDouble(io.deephaven.vector.IntVector) */ public static double[] castDouble( io.deephaven.vector.IntVector values ) {return Cast.castDouble( values );} + /** @see io.deephaven.function.Cast#castDouble(io.deephaven.vector.LongVector) */ public static double[] castDouble( io.deephaven.vector.LongVector values ) {return Cast.castDouble( values );} + /** @see io.deephaven.function.Cast#castDouble(io.deephaven.vector.ShortVector) */ public static double[] castDouble( io.deephaven.vector.ShortVector values ) {return Cast.castDouble( values );} + /** @see io.deephaven.function.Cast#castDouble(long) */ public static double castDouble( long value ) {return Cast.castDouble( value );} + /** @see io.deephaven.function.Cast#castDouble(short) */ public static double castDouble( short value ) {return Cast.castDouble( value );} + /** @see io.deephaven.function.Cast#castDouble(byte,boolean) */ public static double castDouble( byte value, boolean checkFidelity ) {return Cast.castDouble( value, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(byte[],boolean) */ public static double[] castDouble( byte[] values, boolean checkFidelity ) {return Cast.castDouble( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(double[],boolean) */ public static double[] castDouble( double[] values, boolean checkFidelity ) {return Cast.castDouble( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(float[],boolean) */ public static double[] castDouble( float[] values, boolean checkFidelity ) {return Cast.castDouble( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(int[],boolean) */ public static double[] castDouble( int[] values, boolean checkFidelity ) {return Cast.castDouble( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(long[],boolean) */ public static double[] castDouble( long[] values, boolean checkFidelity ) {return Cast.castDouble( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(short[],boolean) */ public static double[] castDouble( short[] values, boolean checkFidelity ) {return Cast.castDouble( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(double,boolean) */ public static double castDouble( double value, boolean checkFidelity ) {return Cast.castDouble( value, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(float,boolean) */ public static double castDouble( float value, boolean checkFidelity ) {return Cast.castDouble( value, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(int,boolean) */ public static double castDouble( int value, boolean checkFidelity ) {return Cast.castDouble( value, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(io.deephaven.vector.ByteVector,boolean) */ public static double[] castDouble( io.deephaven.vector.ByteVector values, boolean checkFidelity ) {return Cast.castDouble( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(io.deephaven.vector.DoubleVector,boolean) */ public static double[] castDouble( io.deephaven.vector.DoubleVector values, boolean checkFidelity ) {return Cast.castDouble( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(io.deephaven.vector.FloatVector,boolean) */ public static double[] castDouble( io.deephaven.vector.FloatVector values, boolean checkFidelity ) {return Cast.castDouble( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(io.deephaven.vector.IntVector,boolean) */ public static double[] castDouble( io.deephaven.vector.IntVector values, boolean checkFidelity ) {return Cast.castDouble( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(io.deephaven.vector.LongVector,boolean) */ public static double[] castDouble( io.deephaven.vector.LongVector values, boolean checkFidelity ) {return Cast.castDouble( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(io.deephaven.vector.ShortVector,boolean) */ public static double[] castDouble( io.deephaven.vector.ShortVector values, boolean checkFidelity ) {return Cast.castDouble( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(long,boolean) */ public static double castDouble( long value, boolean checkFidelity ) {return Cast.castDouble( value, checkFidelity );} + /** @see io.deephaven.function.Cast#castDouble(short,boolean) */ public static double castDouble( short value, boolean checkFidelity ) {return Cast.castDouble( value, checkFidelity );} + /** @see io.deephaven.function.Cast#castInt(byte) */ public static int castInt( byte value ) {return Cast.castInt( value );} + /** @see io.deephaven.function.Cast#castInt(byte[]) */ - public static int[] castInt( byte[] values ) {return Cast.castInt( values );} + public static int[] castInt( byte... values ) {return Cast.castInt( values );} + /** @see io.deephaven.function.Cast#castInt(int[]) */ - public static int[] castInt( int[] values ) {return Cast.castInt( values );} + public static int[] castInt( int... values ) {return Cast.castInt( values );} + /** @see io.deephaven.function.Cast#castInt(long[]) */ - public static int[] castInt( long[] values ) {return Cast.castInt( values );} + public static int[] castInt( long... values ) {return Cast.castInt( values );} + /** @see io.deephaven.function.Cast#castInt(short[]) */ - public static int[] castInt( short[] values ) {return Cast.castInt( values );} + public static int[] castInt( short... values ) {return Cast.castInt( values );} + /** @see io.deephaven.function.Cast#castInt(int) */ public static int castInt( int value ) {return Cast.castInt( value );} + /** @see io.deephaven.function.Cast#castInt(io.deephaven.vector.ByteVector) */ public static int[] castInt( io.deephaven.vector.ByteVector values ) {return Cast.castInt( values );} + /** @see io.deephaven.function.Cast#castInt(io.deephaven.vector.IntVector) */ public static int[] castInt( io.deephaven.vector.IntVector values ) {return Cast.castInt( values );} + /** @see io.deephaven.function.Cast#castInt(io.deephaven.vector.LongVector) */ public static int[] castInt( io.deephaven.vector.LongVector values ) {return Cast.castInt( values );} + /** @see io.deephaven.function.Cast#castInt(io.deephaven.vector.ShortVector) */ public static int[] castInt( io.deephaven.vector.ShortVector values ) {return Cast.castInt( values );} + /** @see io.deephaven.function.Cast#castInt(long) */ public static int castInt( long value ) {return Cast.castInt( value );} + /** @see io.deephaven.function.Cast#castInt(short) */ public static int castInt( short value ) {return Cast.castInt( value );} + /** @see io.deephaven.function.Cast#castInt(byte,boolean) */ public static int castInt( byte value, boolean checkFidelity ) {return Cast.castInt( value, checkFidelity );} + /** @see io.deephaven.function.Cast#castInt(byte[],boolean) */ public static int[] castInt( byte[] values, boolean checkFidelity ) {return Cast.castInt( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castInt(int[],boolean) */ public static int[] castInt( int[] values, boolean checkFidelity ) {return Cast.castInt( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castInt(long[],boolean) */ public static int[] castInt( long[] values, boolean checkFidelity ) {return Cast.castInt( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castInt(short[],boolean) */ public static int[] castInt( short[] values, boolean checkFidelity ) {return Cast.castInt( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castInt(int,boolean) */ public static int castInt( int value, boolean checkFidelity ) {return Cast.castInt( value, checkFidelity );} + /** @see io.deephaven.function.Cast#castInt(io.deephaven.vector.ByteVector,boolean) */ public static int[] castInt( io.deephaven.vector.ByteVector values, boolean checkFidelity ) {return Cast.castInt( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castInt(io.deephaven.vector.IntVector,boolean) */ public static int[] castInt( io.deephaven.vector.IntVector values, boolean checkFidelity ) {return Cast.castInt( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castInt(io.deephaven.vector.LongVector,boolean) */ public static int[] castInt( io.deephaven.vector.LongVector values, boolean checkFidelity ) {return Cast.castInt( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castInt(io.deephaven.vector.ShortVector,boolean) */ public static int[] castInt( io.deephaven.vector.ShortVector values, boolean checkFidelity ) {return Cast.castInt( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castInt(long,boolean) */ public static int castInt( long value, boolean checkFidelity ) {return Cast.castInt( value, checkFidelity );} + /** @see io.deephaven.function.Cast#castInt(short,boolean) */ public static int castInt( short value, boolean checkFidelity ) {return Cast.castInt( value, checkFidelity );} + /** @see io.deephaven.function.Cast#castLong(byte) */ public static long castLong( byte value ) {return Cast.castLong( value );} + /** @see io.deephaven.function.Cast#castLong(byte[]) */ - public static long[] castLong( byte[] values ) {return Cast.castLong( values );} + public static long[] castLong( byte... values ) {return Cast.castLong( values );} + /** @see io.deephaven.function.Cast#castLong(int[]) */ - public static long[] castLong( int[] values ) {return Cast.castLong( values );} + public static long[] castLong( int... values ) {return Cast.castLong( values );} + /** @see io.deephaven.function.Cast#castLong(long[]) */ - public static long[] castLong( long[] values ) {return Cast.castLong( values );} + public static long[] castLong( long... values ) {return Cast.castLong( values );} + /** @see io.deephaven.function.Cast#castLong(short[]) */ - public static long[] castLong( short[] values ) {return Cast.castLong( values );} + public static long[] castLong( short... values ) {return Cast.castLong( values );} + /** @see io.deephaven.function.Cast#castLong(int) */ public static long castLong( int value ) {return Cast.castLong( value );} + /** @see io.deephaven.function.Cast#castLong(io.deephaven.vector.ByteVector) */ public static long[] castLong( io.deephaven.vector.ByteVector values ) {return Cast.castLong( values );} + /** @see io.deephaven.function.Cast#castLong(io.deephaven.vector.IntVector) */ public static long[] castLong( io.deephaven.vector.IntVector values ) {return Cast.castLong( values );} + /** @see io.deephaven.function.Cast#castLong(io.deephaven.vector.LongVector) */ public static long[] castLong( io.deephaven.vector.LongVector values ) {return Cast.castLong( values );} + /** @see io.deephaven.function.Cast#castLong(io.deephaven.vector.ShortVector) */ public static long[] castLong( io.deephaven.vector.ShortVector values ) {return Cast.castLong( values );} + /** @see io.deephaven.function.Cast#castLong(long) */ public static long castLong( long value ) {return Cast.castLong( value );} + /** @see io.deephaven.function.Cast#castLong(short) */ public static long castLong( short value ) {return Cast.castLong( value );} + /** @see io.deephaven.function.Cast#castLong(byte,boolean) */ public static long castLong( byte value, boolean checkFidelity ) {return Cast.castLong( value, checkFidelity );} + /** @see io.deephaven.function.Cast#castLong(byte[],boolean) */ public static long[] castLong( byte[] values, boolean checkFidelity ) {return Cast.castLong( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castLong(int[],boolean) */ public static long[] castLong( int[] values, boolean checkFidelity ) {return Cast.castLong( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castLong(long[],boolean) */ public static long[] castLong( long[] values, boolean checkFidelity ) {return Cast.castLong( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castLong(short[],boolean) */ public static long[] castLong( short[] values, boolean checkFidelity ) {return Cast.castLong( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castLong(int,boolean) */ public static long castLong( int value, boolean checkFidelity ) {return Cast.castLong( value, checkFidelity );} + /** @see io.deephaven.function.Cast#castLong(io.deephaven.vector.ByteVector,boolean) */ public static long[] castLong( io.deephaven.vector.ByteVector values, boolean checkFidelity ) {return Cast.castLong( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castLong(io.deephaven.vector.IntVector,boolean) */ public static long[] castLong( io.deephaven.vector.IntVector values, boolean checkFidelity ) {return Cast.castLong( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castLong(io.deephaven.vector.LongVector,boolean) */ public static long[] castLong( io.deephaven.vector.LongVector values, boolean checkFidelity ) {return Cast.castLong( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castLong(io.deephaven.vector.ShortVector,boolean) */ public static long[] castLong( io.deephaven.vector.ShortVector values, boolean checkFidelity ) {return Cast.castLong( values, checkFidelity );} + /** @see io.deephaven.function.Cast#castLong(long,boolean) */ public static long castLong( long value, boolean checkFidelity ) {return Cast.castLong( value, checkFidelity );} + /** @see io.deephaven.function.Cast#castLong(short,boolean) */ public static long castLong( short value, boolean checkFidelity ) {return Cast.castLong( value, checkFidelity );} + /** @see io.deephaven.function.Numeric#ceil(byte) */ public static double ceil( byte value ) {return Numeric.ceil( value );} + /** @see io.deephaven.function.Numeric#ceil(double) */ public static double ceil( double value ) {return Numeric.ceil( value );} + /** @see io.deephaven.function.Numeric#ceil(float) */ public static double ceil( float value ) {return Numeric.ceil( value );} + /** @see io.deephaven.function.Numeric#ceil(int) */ public static double ceil( int value ) {return Numeric.ceil( value );} + /** @see io.deephaven.function.Numeric#ceil(long) */ public static double ceil( long value ) {return Numeric.ceil( value );} + /** @see io.deephaven.function.Numeric#ceil(short) */ public static double ceil( short value ) {return Numeric.ceil( value );} + /** @see io.deephaven.function.Numeric#clamp(byte,byte,byte) */ public static byte clamp( byte value, byte min, byte max ) {return Numeric.clamp( value, min, max );} + /** @see io.deephaven.function.Numeric#clamp(double,double,double) */ public static double clamp( double value, double min, double max ) {return Numeric.clamp( value, min, max );} + /** @see io.deephaven.function.Numeric#clamp(float,float,float) */ public static float clamp( float value, float min, float max ) {return Numeric.clamp( value, min, max );} + /** @see io.deephaven.function.Numeric#clamp(int,int,int) */ public static int clamp( int value, int min, int max ) {return Numeric.clamp( value, min, max );} + /** @see io.deephaven.function.Numeric#clamp(long,long,long) */ public static long clamp( long value, long min, long max ) {return Numeric.clamp( value, min, max );} + /** @see io.deephaven.function.Numeric#clamp(short,short,short) */ public static short clamp( short value, short min, short max ) {return Numeric.clamp( value, min, max );} + /** @see io.deephaven.function.Basic#concat(java.lang.Object[][]) */ - public static T[] concat( T[][] values ) {return Basic.concat( values );} + public static T[] concat( T[]... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(io.deephaven.vector.ByteVector[]) */ - public static byte[] concat( io.deephaven.vector.ByteVector[] values ) {return Basic.concat( values );} + public static byte[] concat( io.deephaven.vector.ByteVector... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(io.deephaven.vector.CharVector[]) */ - public static char[] concat( io.deephaven.vector.CharVector[] values ) {return Basic.concat( values );} + public static char[] concat( io.deephaven.vector.CharVector... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(io.deephaven.vector.DoubleVector[]) */ - public static double[] concat( io.deephaven.vector.DoubleVector[] values ) {return Basic.concat( values );} + public static double[] concat( io.deephaven.vector.DoubleVector... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(io.deephaven.vector.FloatVector[]) */ - public static float[] concat( io.deephaven.vector.FloatVector[] values ) {return Basic.concat( values );} + public static float[] concat( io.deephaven.vector.FloatVector... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(io.deephaven.vector.IntVector[]) */ - public static int[] concat( io.deephaven.vector.IntVector[] values ) {return Basic.concat( values );} + public static int[] concat( io.deephaven.vector.IntVector... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(io.deephaven.vector.LongVector[]) */ - public static long[] concat( io.deephaven.vector.LongVector[] values ) {return Basic.concat( values );} + public static long[] concat( io.deephaven.vector.LongVector... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(io.deephaven.vector.ShortVector[]) */ - public static short[] concat( io.deephaven.vector.ShortVector[] values ) {return Basic.concat( values );} + public static short[] concat( io.deephaven.vector.ShortVector... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(byte[][]) */ - public static byte[] concat( byte[][] values ) {return Basic.concat( values );} + public static byte[] concat( byte[]... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(char[][]) */ - public static char[] concat( char[][] values ) {return Basic.concat( values );} + public static char[] concat( char[]... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(double[][]) */ - public static double[] concat( double[][] values ) {return Basic.concat( values );} + public static double[] concat( double[]... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(float[][]) */ - public static float[] concat( float[][] values ) {return Basic.concat( values );} + public static float[] concat( float[]... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(int[][]) */ - public static int[] concat( int[][] values ) {return Basic.concat( values );} + public static int[] concat( int[]... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(long[][]) */ - public static long[] concat( long[][] values ) {return Basic.concat( values );} + public static long[] concat( long[]... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(short[][]) */ - public static short[] concat( short[][] values ) {return Basic.concat( values );} + public static short[] concat( short[]... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Basic#concat(io.deephaven.vector.ObjectVector[]) */ - public static T[] concat( io.deephaven.vector.ObjectVector[] values ) {return Basic.concat( values );} + public static T[] concat( io.deephaven.vector.ObjectVector... values ) {return Basic.concat( values );} + /** @see io.deephaven.function.Numeric#containsNonFinite(byte[]) */ - public static boolean containsNonFinite( byte[] values ) {return Numeric.containsNonFinite( values );} + public static boolean containsNonFinite( byte... values ) {return Numeric.containsNonFinite( values );} + /** @see io.deephaven.function.Numeric#containsNonFinite(double[]) */ - public static boolean containsNonFinite( double[] values ) {return Numeric.containsNonFinite( values );} + public static boolean containsNonFinite( double... values ) {return Numeric.containsNonFinite( values );} + /** @see io.deephaven.function.Numeric#containsNonFinite(float[]) */ - public static boolean containsNonFinite( float[] values ) {return Numeric.containsNonFinite( values );} + public static boolean containsNonFinite( float... values ) {return Numeric.containsNonFinite( values );} + /** @see io.deephaven.function.Numeric#containsNonFinite(int[]) */ - public static boolean containsNonFinite( int[] values ) {return Numeric.containsNonFinite( values );} + public static boolean containsNonFinite( int... values ) {return Numeric.containsNonFinite( values );} + /** @see io.deephaven.function.Numeric#containsNonFinite(long[]) */ - public static boolean containsNonFinite( long[] values ) {return Numeric.containsNonFinite( values );} + public static boolean containsNonFinite( long... values ) {return Numeric.containsNonFinite( values );} + /** @see io.deephaven.function.Numeric#containsNonFinite(java.lang.Byte[]) */ public static boolean containsNonFinite( java.lang.Byte[] values ) {return Numeric.containsNonFinite( values );} + /** @see io.deephaven.function.Numeric#containsNonFinite(java.lang.Double[]) */ public static boolean containsNonFinite( java.lang.Double[] values ) {return Numeric.containsNonFinite( values );} + /** @see io.deephaven.function.Numeric#containsNonFinite(java.lang.Float[]) */ public static boolean containsNonFinite( java.lang.Float[] values ) {return Numeric.containsNonFinite( values );} + /** @see io.deephaven.function.Numeric#containsNonFinite(java.lang.Integer[]) */ public static boolean containsNonFinite( java.lang.Integer[] values ) {return Numeric.containsNonFinite( values );} + /** @see io.deephaven.function.Numeric#containsNonFinite(java.lang.Long[]) */ public static boolean containsNonFinite( java.lang.Long[] values ) {return Numeric.containsNonFinite( values );} + /** @see io.deephaven.function.Numeric#containsNonFinite(java.lang.Short[]) */ public static boolean containsNonFinite( java.lang.Short[] values ) {return Numeric.containsNonFinite( values );} + /** @see io.deephaven.function.Numeric#containsNonFinite(short[]) */ - public static boolean containsNonFinite( short[] values ) {return Numeric.containsNonFinite( values );} + public static boolean containsNonFinite( short... values ) {return Numeric.containsNonFinite( values );} + /** @see io.deephaven.function.Numeric#cor(byte[],byte[]) */ public static double cor( byte[] values0, byte[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(byte[],double[]) */ public static double cor( byte[] values0, double[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(byte[],float[]) */ public static double cor( byte[] values0, float[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(byte[],int[]) */ public static double cor( byte[] values0, int[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(byte[],long[]) */ public static double cor( byte[] values0, long[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(byte[],short[]) */ public static double cor( byte[] values0, short[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(byte[],io.deephaven.vector.ByteVector) */ public static double cor( byte[] values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(byte[],io.deephaven.vector.DoubleVector) */ public static double cor( byte[] values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(byte[],io.deephaven.vector.FloatVector) */ public static double cor( byte[] values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(byte[],io.deephaven.vector.IntVector) */ public static double cor( byte[] values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(byte[],io.deephaven.vector.LongVector) */ public static double cor( byte[] values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(byte[],io.deephaven.vector.ShortVector) */ public static double cor( byte[] values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(double[],byte[]) */ public static double cor( double[] values0, byte[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(double[],double[]) */ public static double cor( double[] values0, double[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(double[],float[]) */ public static double cor( double[] values0, float[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(double[],int[]) */ public static double cor( double[] values0, int[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(double[],long[]) */ public static double cor( double[] values0, long[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(double[],short[]) */ public static double cor( double[] values0, short[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(double[],io.deephaven.vector.ByteVector) */ public static double cor( double[] values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(double[],io.deephaven.vector.DoubleVector) */ public static double cor( double[] values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(double[],io.deephaven.vector.FloatVector) */ public static double cor( double[] values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(double[],io.deephaven.vector.IntVector) */ public static double cor( double[] values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(double[],io.deephaven.vector.LongVector) */ public static double cor( double[] values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(double[],io.deephaven.vector.ShortVector) */ public static double cor( double[] values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(float[],byte[]) */ public static double cor( float[] values0, byte[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(float[],double[]) */ public static double cor( float[] values0, double[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(float[],float[]) */ public static double cor( float[] values0, float[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(float[],int[]) */ public static double cor( float[] values0, int[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(float[],long[]) */ public static double cor( float[] values0, long[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(float[],short[]) */ public static double cor( float[] values0, short[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(float[],io.deephaven.vector.ByteVector) */ public static double cor( float[] values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(float[],io.deephaven.vector.DoubleVector) */ public static double cor( float[] values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(float[],io.deephaven.vector.FloatVector) */ public static double cor( float[] values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(float[],io.deephaven.vector.IntVector) */ public static double cor( float[] values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(float[],io.deephaven.vector.LongVector) */ public static double cor( float[] values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(float[],io.deephaven.vector.ShortVector) */ public static double cor( float[] values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(int[],byte[]) */ public static double cor( int[] values0, byte[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(int[],double[]) */ public static double cor( int[] values0, double[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(int[],float[]) */ public static double cor( int[] values0, float[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(int[],int[]) */ public static double cor( int[] values0, int[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(int[],long[]) */ public static double cor( int[] values0, long[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(int[],short[]) */ public static double cor( int[] values0, short[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(int[],io.deephaven.vector.ByteVector) */ public static double cor( int[] values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(int[],io.deephaven.vector.DoubleVector) */ public static double cor( int[] values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(int[],io.deephaven.vector.FloatVector) */ public static double cor( int[] values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(int[],io.deephaven.vector.IntVector) */ public static double cor( int[] values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(int[],io.deephaven.vector.LongVector) */ public static double cor( int[] values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(int[],io.deephaven.vector.ShortVector) */ public static double cor( int[] values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(long[],byte[]) */ public static double cor( long[] values0, byte[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(long[],double[]) */ public static double cor( long[] values0, double[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(long[],float[]) */ public static double cor( long[] values0, float[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(long[],int[]) */ public static double cor( long[] values0, int[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(long[],long[]) */ public static double cor( long[] values0, long[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(long[],short[]) */ public static double cor( long[] values0, short[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(long[],io.deephaven.vector.ByteVector) */ public static double cor( long[] values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(long[],io.deephaven.vector.DoubleVector) */ public static double cor( long[] values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(long[],io.deephaven.vector.FloatVector) */ public static double cor( long[] values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(long[],io.deephaven.vector.IntVector) */ public static double cor( long[] values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(long[],io.deephaven.vector.LongVector) */ public static double cor( long[] values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(long[],io.deephaven.vector.ShortVector) */ public static double cor( long[] values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(short[],byte[]) */ public static double cor( short[] values0, byte[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(short[],double[]) */ public static double cor( short[] values0, double[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(short[],float[]) */ public static double cor( short[] values0, float[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(short[],int[]) */ public static double cor( short[] values0, int[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(short[],long[]) */ public static double cor( short[] values0, long[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(short[],short[]) */ public static double cor( short[] values0, short[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(short[],io.deephaven.vector.ByteVector) */ public static double cor( short[] values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(short[],io.deephaven.vector.DoubleVector) */ public static double cor( short[] values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(short[],io.deephaven.vector.FloatVector) */ public static double cor( short[] values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(short[],io.deephaven.vector.IntVector) */ public static double cor( short[] values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(short[],io.deephaven.vector.LongVector) */ public static double cor( short[] values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(short[],io.deephaven.vector.ShortVector) */ public static double cor( short[] values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ByteVector,byte[]) */ public static double cor( io.deephaven.vector.ByteVector values0, byte[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ByteVector,double[]) */ public static double cor( io.deephaven.vector.ByteVector values0, double[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ByteVector,float[]) */ public static double cor( io.deephaven.vector.ByteVector values0, float[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ByteVector,int[]) */ public static double cor( io.deephaven.vector.ByteVector values0, int[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ByteVector,long[]) */ public static double cor( io.deephaven.vector.ByteVector values0, long[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ByteVector,short[]) */ public static double cor( io.deephaven.vector.ByteVector values0, short[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ByteVector,io.deephaven.vector.ByteVector) */ public static double cor( io.deephaven.vector.ByteVector values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ByteVector,io.deephaven.vector.DoubleVector) */ public static double cor( io.deephaven.vector.ByteVector values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ByteVector,io.deephaven.vector.FloatVector) */ public static double cor( io.deephaven.vector.ByteVector values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ByteVector,io.deephaven.vector.IntVector) */ public static double cor( io.deephaven.vector.ByteVector values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ByteVector,io.deephaven.vector.LongVector) */ public static double cor( io.deephaven.vector.ByteVector values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ByteVector,io.deephaven.vector.ShortVector) */ public static double cor( io.deephaven.vector.ByteVector values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.DoubleVector,byte[]) */ public static double cor( io.deephaven.vector.DoubleVector values0, byte[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.DoubleVector,double[]) */ public static double cor( io.deephaven.vector.DoubleVector values0, double[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.DoubleVector,float[]) */ public static double cor( io.deephaven.vector.DoubleVector values0, float[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.DoubleVector,int[]) */ public static double cor( io.deephaven.vector.DoubleVector values0, int[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.DoubleVector,long[]) */ public static double cor( io.deephaven.vector.DoubleVector values0, long[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.DoubleVector,short[]) */ public static double cor( io.deephaven.vector.DoubleVector values0, short[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.DoubleVector,io.deephaven.vector.ByteVector) */ public static double cor( io.deephaven.vector.DoubleVector values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.DoubleVector,io.deephaven.vector.DoubleVector) */ public static double cor( io.deephaven.vector.DoubleVector values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.DoubleVector,io.deephaven.vector.FloatVector) */ public static double cor( io.deephaven.vector.DoubleVector values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.DoubleVector,io.deephaven.vector.IntVector) */ public static double cor( io.deephaven.vector.DoubleVector values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.DoubleVector,io.deephaven.vector.LongVector) */ public static double cor( io.deephaven.vector.DoubleVector values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.DoubleVector,io.deephaven.vector.ShortVector) */ public static double cor( io.deephaven.vector.DoubleVector values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.FloatVector,byte[]) */ public static double cor( io.deephaven.vector.FloatVector values0, byte[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.FloatVector,double[]) */ public static double cor( io.deephaven.vector.FloatVector values0, double[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.FloatVector,float[]) */ public static double cor( io.deephaven.vector.FloatVector values0, float[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.FloatVector,int[]) */ public static double cor( io.deephaven.vector.FloatVector values0, int[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.FloatVector,long[]) */ public static double cor( io.deephaven.vector.FloatVector values0, long[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.FloatVector,short[]) */ public static double cor( io.deephaven.vector.FloatVector values0, short[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.FloatVector,io.deephaven.vector.ByteVector) */ public static double cor( io.deephaven.vector.FloatVector values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.FloatVector,io.deephaven.vector.DoubleVector) */ public static double cor( io.deephaven.vector.FloatVector values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.FloatVector,io.deephaven.vector.FloatVector) */ public static double cor( io.deephaven.vector.FloatVector values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.FloatVector,io.deephaven.vector.IntVector) */ public static double cor( io.deephaven.vector.FloatVector values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.FloatVector,io.deephaven.vector.LongVector) */ public static double cor( io.deephaven.vector.FloatVector values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.FloatVector,io.deephaven.vector.ShortVector) */ public static double cor( io.deephaven.vector.FloatVector values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.IntVector,byte[]) */ public static double cor( io.deephaven.vector.IntVector values0, byte[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.IntVector,double[]) */ public static double cor( io.deephaven.vector.IntVector values0, double[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.IntVector,float[]) */ public static double cor( io.deephaven.vector.IntVector values0, float[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.IntVector,int[]) */ public static double cor( io.deephaven.vector.IntVector values0, int[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.IntVector,long[]) */ public static double cor( io.deephaven.vector.IntVector values0, long[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.IntVector,short[]) */ public static double cor( io.deephaven.vector.IntVector values0, short[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.IntVector,io.deephaven.vector.ByteVector) */ public static double cor( io.deephaven.vector.IntVector values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.IntVector,io.deephaven.vector.DoubleVector) */ public static double cor( io.deephaven.vector.IntVector values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.IntVector,io.deephaven.vector.FloatVector) */ public static double cor( io.deephaven.vector.IntVector values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.IntVector,io.deephaven.vector.IntVector) */ public static double cor( io.deephaven.vector.IntVector values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.IntVector,io.deephaven.vector.LongVector) */ public static double cor( io.deephaven.vector.IntVector values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.IntVector,io.deephaven.vector.ShortVector) */ public static double cor( io.deephaven.vector.IntVector values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.LongVector,byte[]) */ public static double cor( io.deephaven.vector.LongVector values0, byte[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.LongVector,double[]) */ public static double cor( io.deephaven.vector.LongVector values0, double[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.LongVector,float[]) */ public static double cor( io.deephaven.vector.LongVector values0, float[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.LongVector,int[]) */ public static double cor( io.deephaven.vector.LongVector values0, int[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.LongVector,long[]) */ public static double cor( io.deephaven.vector.LongVector values0, long[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.LongVector,short[]) */ public static double cor( io.deephaven.vector.LongVector values0, short[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.LongVector,io.deephaven.vector.ByteVector) */ public static double cor( io.deephaven.vector.LongVector values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.LongVector,io.deephaven.vector.DoubleVector) */ public static double cor( io.deephaven.vector.LongVector values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.LongVector,io.deephaven.vector.FloatVector) */ public static double cor( io.deephaven.vector.LongVector values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.LongVector,io.deephaven.vector.IntVector) */ public static double cor( io.deephaven.vector.LongVector values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.LongVector,io.deephaven.vector.LongVector) */ public static double cor( io.deephaven.vector.LongVector values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.LongVector,io.deephaven.vector.ShortVector) */ public static double cor( io.deephaven.vector.LongVector values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ShortVector,byte[]) */ public static double cor( io.deephaven.vector.ShortVector values0, byte[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ShortVector,double[]) */ public static double cor( io.deephaven.vector.ShortVector values0, double[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ShortVector,float[]) */ public static double cor( io.deephaven.vector.ShortVector values0, float[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ShortVector,int[]) */ public static double cor( io.deephaven.vector.ShortVector values0, int[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ShortVector,long[]) */ public static double cor( io.deephaven.vector.ShortVector values0, long[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ShortVector,short[]) */ public static double cor( io.deephaven.vector.ShortVector values0, short[] values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ShortVector,io.deephaven.vector.ByteVector) */ public static double cor( io.deephaven.vector.ShortVector values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ShortVector,io.deephaven.vector.DoubleVector) */ public static double cor( io.deephaven.vector.ShortVector values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ShortVector,io.deephaven.vector.FloatVector) */ public static double cor( io.deephaven.vector.ShortVector values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ShortVector,io.deephaven.vector.IntVector) */ public static double cor( io.deephaven.vector.ShortVector values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ShortVector,io.deephaven.vector.LongVector) */ public static double cor( io.deephaven.vector.ShortVector values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cor(io.deephaven.vector.ShortVector,io.deephaven.vector.ShortVector) */ public static double cor( io.deephaven.vector.ShortVector values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cor( values0, values1 );} + /** @see io.deephaven.function.Numeric#cos(byte) */ public static double cos( byte value ) {return Numeric.cos( value );} + /** @see io.deephaven.function.Numeric#cos(double) */ public static double cos( double value ) {return Numeric.cos( value );} + /** @see io.deephaven.function.Numeric#cos(float) */ public static double cos( float value ) {return Numeric.cos( value );} + /** @see io.deephaven.function.Numeric#cos(int) */ public static double cos( int value ) {return Numeric.cos( value );} + /** @see io.deephaven.function.Numeric#cos(long) */ public static double cos( long value ) {return Numeric.cos( value );} + /** @see io.deephaven.function.Numeric#cos(short) */ public static double cos( short value ) {return Numeric.cos( value );} + /** @see io.deephaven.function.Basic#count(byte[]) */ - public static long count( byte[] values ) {return Basic.count( values );} + public static long count( byte... values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#count(char[]) */ - public static long count( char[] values ) {return Basic.count( values );} + public static long count( char... values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#count(double[]) */ - public static long count( double[] values ) {return Basic.count( values );} + public static long count( double... values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#count(float[]) */ - public static long count( float[] values ) {return Basic.count( values );} + public static long count( float... values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#count(int[]) */ - public static long count( int[] values ) {return Basic.count( values );} + public static long count( int... values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#count(long[]) */ - public static long count( long[] values ) {return Basic.count( values );} + public static long count( long... values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#count(short[]) */ - public static long count( short[] values ) {return Basic.count( values );} + public static long count( short... values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#count(io.deephaven.vector.ByteVector) */ public static long count( io.deephaven.vector.ByteVector values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#count(io.deephaven.vector.CharVector) */ public static long count( io.deephaven.vector.CharVector values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#count(io.deephaven.vector.DoubleVector) */ public static long count( io.deephaven.vector.DoubleVector values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#count(io.deephaven.vector.FloatVector) */ public static long count( io.deephaven.vector.FloatVector values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#count(io.deephaven.vector.IntVector) */ public static long count( io.deephaven.vector.IntVector values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#count(io.deephaven.vector.LongVector) */ public static long count( io.deephaven.vector.LongVector values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#count(io.deephaven.vector.ShortVector) */ public static long count( io.deephaven.vector.ShortVector values ) {return Basic.count( values );} + /** @see io.deephaven.function.Basic#countDistinct(byte[]) */ - public static long countDistinct( byte[] values ) {return Basic.countDistinct( values );} + public static long countDistinct( byte... values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(char[]) */ - public static long countDistinct( char[] values ) {return Basic.countDistinct( values );} + public static long countDistinct( char... values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(double[]) */ - public static long countDistinct( double[] values ) {return Basic.countDistinct( values );} + public static long countDistinct( double... values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(float[]) */ - public static long countDistinct( float[] values ) {return Basic.countDistinct( values );} + public static long countDistinct( float... values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(int[]) */ - public static long countDistinct( int[] values ) {return Basic.countDistinct( values );} + public static long countDistinct( int... values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(long[]) */ - public static long countDistinct( long[] values ) {return Basic.countDistinct( values );} + public static long countDistinct( long... values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(short[]) */ - public static long countDistinct( short[] values ) {return Basic.countDistinct( values );} + public static long countDistinct( short... values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.ByteVector) */ public static long countDistinct( io.deephaven.vector.ByteVector values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.CharVector) */ public static long countDistinct( io.deephaven.vector.CharVector values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.DoubleVector) */ public static long countDistinct( io.deephaven.vector.DoubleVector values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.FloatVector) */ public static long countDistinct( io.deephaven.vector.FloatVector values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.IntVector) */ public static long countDistinct( io.deephaven.vector.IntVector values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.LongVector) */ public static long countDistinct( io.deephaven.vector.LongVector values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.ShortVector) */ public static long countDistinct( io.deephaven.vector.ShortVector values ) {return Basic.countDistinct( values );} + /** @see io.deephaven.function.Basic#countDistinct(byte[],boolean) */ public static long countDistinct( byte[] values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinct(char[],boolean) */ public static long countDistinct( char[] values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinct(double[],boolean) */ public static long countDistinct( double[] values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinct(float[],boolean) */ public static long countDistinct( float[] values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinct(int[],boolean) */ public static long countDistinct( int[] values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinct(long[],boolean) */ public static long countDistinct( long[] values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinct(short[],boolean) */ public static long countDistinct( short[] values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.ByteVector,boolean) */ public static long countDistinct( io.deephaven.vector.ByteVector values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.CharVector,boolean) */ public static long countDistinct( io.deephaven.vector.CharVector values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.DoubleVector,boolean) */ public static long countDistinct( io.deephaven.vector.DoubleVector values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.FloatVector,boolean) */ public static long countDistinct( io.deephaven.vector.FloatVector values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.IntVector,boolean) */ public static long countDistinct( io.deephaven.vector.IntVector values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.LongVector,boolean) */ public static long countDistinct( io.deephaven.vector.LongVector values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinct(io.deephaven.vector.ShortVector,boolean) */ public static long countDistinct( io.deephaven.vector.ShortVector values, boolean countNull ) {return Basic.countDistinct( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinctObj(java.lang.Comparable[]) */ - public static > long countDistinctObj( T[] values ) {return Basic.countDistinctObj( values );} + public static > long countDistinctObj( T... values ) {return Basic.countDistinctObj( values );} + /** @see io.deephaven.function.Basic#countDistinctObj(io.deephaven.vector.ObjectVector) */ public static > long countDistinctObj( io.deephaven.vector.ObjectVector values ) {return Basic.countDistinctObj( values );} + /** @see io.deephaven.function.Basic#countDistinctObj(java.lang.Comparable[],boolean) */ public static > long countDistinctObj( T[] values, boolean countNull ) {return Basic.countDistinctObj( values, countNull );} + /** @see io.deephaven.function.Basic#countDistinctObj(io.deephaven.vector.ObjectVector,boolean) */ public static > long countDistinctObj( io.deephaven.vector.ObjectVector values, boolean countNull ) {return Basic.countDistinctObj( values, countNull );} + /** @see io.deephaven.function.Numeric#countNeg(byte[]) */ - public static long countNeg( byte[] values ) {return Numeric.countNeg( values );} + public static long countNeg( byte... values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(double[]) */ - public static long countNeg( double[] values ) {return Numeric.countNeg( values );} + public static long countNeg( double... values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(float[]) */ - public static long countNeg( float[] values ) {return Numeric.countNeg( values );} + public static long countNeg( float... values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(int[]) */ - public static long countNeg( int[] values ) {return Numeric.countNeg( values );} + public static long countNeg( int... values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(long[]) */ - public static long countNeg( long[] values ) {return Numeric.countNeg( values );} + public static long countNeg( long... values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(java.lang.Byte[]) */ public static long countNeg( java.lang.Byte[] values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(java.lang.Double[]) */ public static long countNeg( java.lang.Double[] values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(java.lang.Float[]) */ public static long countNeg( java.lang.Float[] values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(java.lang.Integer[]) */ public static long countNeg( java.lang.Integer[] values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(java.lang.Long[]) */ public static long countNeg( java.lang.Long[] values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(java.lang.Short[]) */ public static long countNeg( java.lang.Short[] values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(short[]) */ - public static long countNeg( short[] values ) {return Numeric.countNeg( values );} + public static long countNeg( short... values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(io.deephaven.vector.ByteVector) */ public static long countNeg( io.deephaven.vector.ByteVector values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(io.deephaven.vector.DoubleVector) */ public static long countNeg( io.deephaven.vector.DoubleVector values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(io.deephaven.vector.FloatVector) */ public static long countNeg( io.deephaven.vector.FloatVector values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(io.deephaven.vector.IntVector) */ public static long countNeg( io.deephaven.vector.IntVector values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(io.deephaven.vector.LongVector) */ public static long countNeg( io.deephaven.vector.LongVector values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Numeric#countNeg(io.deephaven.vector.ShortVector) */ public static long countNeg( io.deephaven.vector.ShortVector values ) {return Numeric.countNeg( values );} + /** @see io.deephaven.function.Basic#countObj(java.lang.Object[]) */ - public static long countObj( T[] values ) {return Basic.countObj( values );} + public static long countObj( T... values ) {return Basic.countObj( values );} + /** @see io.deephaven.function.Basic#countObj(io.deephaven.vector.ObjectVector) */ public static long countObj( io.deephaven.vector.ObjectVector values ) {return Basic.countObj( values );} + /** @see io.deephaven.function.Numeric#countPos(byte[]) */ - public static long countPos( byte[] values ) {return Numeric.countPos( values );} + public static long countPos( byte... values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(double[]) */ - public static long countPos( double[] values ) {return Numeric.countPos( values );} + public static long countPos( double... values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(float[]) */ - public static long countPos( float[] values ) {return Numeric.countPos( values );} + public static long countPos( float... values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(int[]) */ - public static long countPos( int[] values ) {return Numeric.countPos( values );} + public static long countPos( int... values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(long[]) */ - public static long countPos( long[] values ) {return Numeric.countPos( values );} + public static long countPos( long... values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(java.lang.Byte[]) */ public static long countPos( java.lang.Byte[] values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(java.lang.Double[]) */ public static long countPos( java.lang.Double[] values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(java.lang.Float[]) */ public static long countPos( java.lang.Float[] values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(java.lang.Integer[]) */ public static long countPos( java.lang.Integer[] values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(java.lang.Long[]) */ public static long countPos( java.lang.Long[] values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(java.lang.Short[]) */ public static long countPos( java.lang.Short[] values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(short[]) */ - public static long countPos( short[] values ) {return Numeric.countPos( values );} + public static long countPos( short... values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(io.deephaven.vector.ByteVector) */ public static long countPos( io.deephaven.vector.ByteVector values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(io.deephaven.vector.DoubleVector) */ public static long countPos( io.deephaven.vector.DoubleVector values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(io.deephaven.vector.FloatVector) */ public static long countPos( io.deephaven.vector.FloatVector values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(io.deephaven.vector.IntVector) */ public static long countPos( io.deephaven.vector.IntVector values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(io.deephaven.vector.LongVector) */ public static long countPos( io.deephaven.vector.LongVector values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countPos(io.deephaven.vector.ShortVector) */ public static long countPos( io.deephaven.vector.ShortVector values ) {return Numeric.countPos( values );} + /** @see io.deephaven.function.Numeric#countZero(byte[]) */ - public static long countZero( byte[] values ) {return Numeric.countZero( values );} + public static long countZero( byte... values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(double[]) */ - public static long countZero( double[] values ) {return Numeric.countZero( values );} + public static long countZero( double... values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(float[]) */ - public static long countZero( float[] values ) {return Numeric.countZero( values );} + public static long countZero( float... values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(int[]) */ - public static long countZero( int[] values ) {return Numeric.countZero( values );} + public static long countZero( int... values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(long[]) */ - public static long countZero( long[] values ) {return Numeric.countZero( values );} + public static long countZero( long... values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(java.lang.Byte[]) */ public static long countZero( java.lang.Byte[] values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(java.lang.Double[]) */ public static long countZero( java.lang.Double[] values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(java.lang.Float[]) */ public static long countZero( java.lang.Float[] values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(java.lang.Integer[]) */ public static long countZero( java.lang.Integer[] values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(java.lang.Long[]) */ public static long countZero( java.lang.Long[] values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(java.lang.Short[]) */ public static long countZero( java.lang.Short[] values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(short[]) */ - public static long countZero( short[] values ) {return Numeric.countZero( values );} + public static long countZero( short... values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(io.deephaven.vector.ByteVector) */ public static long countZero( io.deephaven.vector.ByteVector values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(io.deephaven.vector.DoubleVector) */ public static long countZero( io.deephaven.vector.DoubleVector values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(io.deephaven.vector.FloatVector) */ public static long countZero( io.deephaven.vector.FloatVector values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(io.deephaven.vector.IntVector) */ public static long countZero( io.deephaven.vector.IntVector values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(io.deephaven.vector.LongVector) */ public static long countZero( io.deephaven.vector.LongVector values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#countZero(io.deephaven.vector.ShortVector) */ public static long countZero( io.deephaven.vector.ShortVector values ) {return Numeric.countZero( values );} + /** @see io.deephaven.function.Numeric#cov(byte[],byte[]) */ public static double cov( byte[] values0, byte[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(byte[],double[]) */ public static double cov( byte[] values0, double[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(byte[],float[]) */ public static double cov( byte[] values0, float[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(byte[],int[]) */ public static double cov( byte[] values0, int[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(byte[],long[]) */ public static double cov( byte[] values0, long[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(byte[],short[]) */ public static double cov( byte[] values0, short[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(byte[],io.deephaven.vector.ByteVector) */ public static double cov( byte[] values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(byte[],io.deephaven.vector.DoubleVector) */ public static double cov( byte[] values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(byte[],io.deephaven.vector.FloatVector) */ public static double cov( byte[] values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(byte[],io.deephaven.vector.IntVector) */ public static double cov( byte[] values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(byte[],io.deephaven.vector.LongVector) */ public static double cov( byte[] values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(byte[],io.deephaven.vector.ShortVector) */ public static double cov( byte[] values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(double[],byte[]) */ public static double cov( double[] values0, byte[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(double[],double[]) */ public static double cov( double[] values0, double[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(double[],float[]) */ public static double cov( double[] values0, float[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(double[],int[]) */ public static double cov( double[] values0, int[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(double[],long[]) */ public static double cov( double[] values0, long[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(double[],short[]) */ public static double cov( double[] values0, short[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(double[],io.deephaven.vector.ByteVector) */ public static double cov( double[] values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(double[],io.deephaven.vector.DoubleVector) */ public static double cov( double[] values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(double[],io.deephaven.vector.FloatVector) */ public static double cov( double[] values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(double[],io.deephaven.vector.IntVector) */ public static double cov( double[] values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(double[],io.deephaven.vector.LongVector) */ public static double cov( double[] values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(double[],io.deephaven.vector.ShortVector) */ public static double cov( double[] values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(float[],byte[]) */ public static double cov( float[] values0, byte[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(float[],double[]) */ public static double cov( float[] values0, double[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(float[],float[]) */ public static double cov( float[] values0, float[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(float[],int[]) */ public static double cov( float[] values0, int[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(float[],long[]) */ public static double cov( float[] values0, long[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(float[],short[]) */ public static double cov( float[] values0, short[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(float[],io.deephaven.vector.ByteVector) */ public static double cov( float[] values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(float[],io.deephaven.vector.DoubleVector) */ public static double cov( float[] values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(float[],io.deephaven.vector.FloatVector) */ public static double cov( float[] values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(float[],io.deephaven.vector.IntVector) */ public static double cov( float[] values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(float[],io.deephaven.vector.LongVector) */ public static double cov( float[] values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(float[],io.deephaven.vector.ShortVector) */ public static double cov( float[] values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(int[],byte[]) */ public static double cov( int[] values0, byte[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(int[],double[]) */ public static double cov( int[] values0, double[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(int[],float[]) */ public static double cov( int[] values0, float[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(int[],int[]) */ public static double cov( int[] values0, int[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(int[],long[]) */ public static double cov( int[] values0, long[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(int[],short[]) */ public static double cov( int[] values0, short[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(int[],io.deephaven.vector.ByteVector) */ public static double cov( int[] values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(int[],io.deephaven.vector.DoubleVector) */ public static double cov( int[] values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(int[],io.deephaven.vector.FloatVector) */ public static double cov( int[] values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(int[],io.deephaven.vector.IntVector) */ public static double cov( int[] values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(int[],io.deephaven.vector.LongVector) */ public static double cov( int[] values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(int[],io.deephaven.vector.ShortVector) */ public static double cov( int[] values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(long[],byte[]) */ public static double cov( long[] values0, byte[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(long[],double[]) */ public static double cov( long[] values0, double[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(long[],float[]) */ public static double cov( long[] values0, float[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(long[],int[]) */ public static double cov( long[] values0, int[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(long[],long[]) */ public static double cov( long[] values0, long[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(long[],short[]) */ public static double cov( long[] values0, short[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(long[],io.deephaven.vector.ByteVector) */ public static double cov( long[] values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(long[],io.deephaven.vector.DoubleVector) */ public static double cov( long[] values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(long[],io.deephaven.vector.FloatVector) */ public static double cov( long[] values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(long[],io.deephaven.vector.IntVector) */ public static double cov( long[] values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(long[],io.deephaven.vector.LongVector) */ public static double cov( long[] values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(long[],io.deephaven.vector.ShortVector) */ public static double cov( long[] values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(short[],byte[]) */ public static double cov( short[] values0, byte[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(short[],double[]) */ public static double cov( short[] values0, double[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(short[],float[]) */ public static double cov( short[] values0, float[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(short[],int[]) */ public static double cov( short[] values0, int[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(short[],long[]) */ public static double cov( short[] values0, long[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(short[],short[]) */ public static double cov( short[] values0, short[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(short[],io.deephaven.vector.ByteVector) */ public static double cov( short[] values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(short[],io.deephaven.vector.DoubleVector) */ public static double cov( short[] values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(short[],io.deephaven.vector.FloatVector) */ public static double cov( short[] values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(short[],io.deephaven.vector.IntVector) */ public static double cov( short[] values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(short[],io.deephaven.vector.LongVector) */ public static double cov( short[] values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(short[],io.deephaven.vector.ShortVector) */ public static double cov( short[] values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ByteVector,byte[]) */ public static double cov( io.deephaven.vector.ByteVector values0, byte[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ByteVector,double[]) */ public static double cov( io.deephaven.vector.ByteVector values0, double[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ByteVector,float[]) */ public static double cov( io.deephaven.vector.ByteVector values0, float[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ByteVector,int[]) */ public static double cov( io.deephaven.vector.ByteVector values0, int[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ByteVector,long[]) */ public static double cov( io.deephaven.vector.ByteVector values0, long[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ByteVector,short[]) */ public static double cov( io.deephaven.vector.ByteVector values0, short[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ByteVector,io.deephaven.vector.ByteVector) */ public static double cov( io.deephaven.vector.ByteVector values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ByteVector,io.deephaven.vector.DoubleVector) */ public static double cov( io.deephaven.vector.ByteVector values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ByteVector,io.deephaven.vector.FloatVector) */ public static double cov( io.deephaven.vector.ByteVector values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ByteVector,io.deephaven.vector.IntVector) */ public static double cov( io.deephaven.vector.ByteVector values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ByteVector,io.deephaven.vector.LongVector) */ public static double cov( io.deephaven.vector.ByteVector values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ByteVector,io.deephaven.vector.ShortVector) */ public static double cov( io.deephaven.vector.ByteVector values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.DoubleVector,byte[]) */ public static double cov( io.deephaven.vector.DoubleVector values0, byte[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.DoubleVector,double[]) */ public static double cov( io.deephaven.vector.DoubleVector values0, double[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.DoubleVector,float[]) */ public static double cov( io.deephaven.vector.DoubleVector values0, float[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.DoubleVector,int[]) */ public static double cov( io.deephaven.vector.DoubleVector values0, int[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.DoubleVector,long[]) */ public static double cov( io.deephaven.vector.DoubleVector values0, long[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.DoubleVector,short[]) */ public static double cov( io.deephaven.vector.DoubleVector values0, short[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.DoubleVector,io.deephaven.vector.ByteVector) */ public static double cov( io.deephaven.vector.DoubleVector values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.DoubleVector,io.deephaven.vector.DoubleVector) */ public static double cov( io.deephaven.vector.DoubleVector values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.DoubleVector,io.deephaven.vector.FloatVector) */ public static double cov( io.deephaven.vector.DoubleVector values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.DoubleVector,io.deephaven.vector.IntVector) */ public static double cov( io.deephaven.vector.DoubleVector values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.DoubleVector,io.deephaven.vector.LongVector) */ public static double cov( io.deephaven.vector.DoubleVector values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.DoubleVector,io.deephaven.vector.ShortVector) */ public static double cov( io.deephaven.vector.DoubleVector values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.FloatVector,byte[]) */ public static double cov( io.deephaven.vector.FloatVector values0, byte[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.FloatVector,double[]) */ public static double cov( io.deephaven.vector.FloatVector values0, double[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.FloatVector,float[]) */ public static double cov( io.deephaven.vector.FloatVector values0, float[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.FloatVector,int[]) */ public static double cov( io.deephaven.vector.FloatVector values0, int[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.FloatVector,long[]) */ public static double cov( io.deephaven.vector.FloatVector values0, long[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.FloatVector,short[]) */ public static double cov( io.deephaven.vector.FloatVector values0, short[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.FloatVector,io.deephaven.vector.ByteVector) */ public static double cov( io.deephaven.vector.FloatVector values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.FloatVector,io.deephaven.vector.DoubleVector) */ public static double cov( io.deephaven.vector.FloatVector values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.FloatVector,io.deephaven.vector.FloatVector) */ public static double cov( io.deephaven.vector.FloatVector values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.FloatVector,io.deephaven.vector.IntVector) */ public static double cov( io.deephaven.vector.FloatVector values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.FloatVector,io.deephaven.vector.LongVector) */ public static double cov( io.deephaven.vector.FloatVector values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.FloatVector,io.deephaven.vector.ShortVector) */ public static double cov( io.deephaven.vector.FloatVector values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.IntVector,byte[]) */ public static double cov( io.deephaven.vector.IntVector values0, byte[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.IntVector,double[]) */ public static double cov( io.deephaven.vector.IntVector values0, double[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.IntVector,float[]) */ public static double cov( io.deephaven.vector.IntVector values0, float[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.IntVector,int[]) */ public static double cov( io.deephaven.vector.IntVector values0, int[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.IntVector,long[]) */ public static double cov( io.deephaven.vector.IntVector values0, long[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.IntVector,short[]) */ public static double cov( io.deephaven.vector.IntVector values0, short[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.IntVector,io.deephaven.vector.ByteVector) */ public static double cov( io.deephaven.vector.IntVector values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.IntVector,io.deephaven.vector.DoubleVector) */ public static double cov( io.deephaven.vector.IntVector values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.IntVector,io.deephaven.vector.FloatVector) */ public static double cov( io.deephaven.vector.IntVector values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.IntVector,io.deephaven.vector.IntVector) */ public static double cov( io.deephaven.vector.IntVector values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.IntVector,io.deephaven.vector.LongVector) */ public static double cov( io.deephaven.vector.IntVector values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.IntVector,io.deephaven.vector.ShortVector) */ public static double cov( io.deephaven.vector.IntVector values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.LongVector,byte[]) */ public static double cov( io.deephaven.vector.LongVector values0, byte[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.LongVector,double[]) */ public static double cov( io.deephaven.vector.LongVector values0, double[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.LongVector,float[]) */ public static double cov( io.deephaven.vector.LongVector values0, float[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.LongVector,int[]) */ public static double cov( io.deephaven.vector.LongVector values0, int[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.LongVector,long[]) */ public static double cov( io.deephaven.vector.LongVector values0, long[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.LongVector,short[]) */ public static double cov( io.deephaven.vector.LongVector values0, short[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.LongVector,io.deephaven.vector.ByteVector) */ public static double cov( io.deephaven.vector.LongVector values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.LongVector,io.deephaven.vector.DoubleVector) */ public static double cov( io.deephaven.vector.LongVector values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.LongVector,io.deephaven.vector.FloatVector) */ public static double cov( io.deephaven.vector.LongVector values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.LongVector,io.deephaven.vector.IntVector) */ public static double cov( io.deephaven.vector.LongVector values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.LongVector,io.deephaven.vector.LongVector) */ public static double cov( io.deephaven.vector.LongVector values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.LongVector,io.deephaven.vector.ShortVector) */ public static double cov( io.deephaven.vector.LongVector values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ShortVector,byte[]) */ public static double cov( io.deephaven.vector.ShortVector values0, byte[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ShortVector,double[]) */ public static double cov( io.deephaven.vector.ShortVector values0, double[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ShortVector,float[]) */ public static double cov( io.deephaven.vector.ShortVector values0, float[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ShortVector,int[]) */ public static double cov( io.deephaven.vector.ShortVector values0, int[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ShortVector,long[]) */ public static double cov( io.deephaven.vector.ShortVector values0, long[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ShortVector,short[]) */ public static double cov( io.deephaven.vector.ShortVector values0, short[] values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ShortVector,io.deephaven.vector.ByteVector) */ public static double cov( io.deephaven.vector.ShortVector values0, io.deephaven.vector.ByteVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ShortVector,io.deephaven.vector.DoubleVector) */ public static double cov( io.deephaven.vector.ShortVector values0, io.deephaven.vector.DoubleVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ShortVector,io.deephaven.vector.FloatVector) */ public static double cov( io.deephaven.vector.ShortVector values0, io.deephaven.vector.FloatVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ShortVector,io.deephaven.vector.IntVector) */ public static double cov( io.deephaven.vector.ShortVector values0, io.deephaven.vector.IntVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ShortVector,io.deephaven.vector.LongVector) */ public static double cov( io.deephaven.vector.ShortVector values0, io.deephaven.vector.LongVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cov(io.deephaven.vector.ShortVector,io.deephaven.vector.ShortVector) */ public static double cov( io.deephaven.vector.ShortVector values0, io.deephaven.vector.ShortVector values1 ) {return Numeric.cov( values0, values1 );} + /** @see io.deephaven.function.Numeric#cummax(byte[]) */ - public static byte[] cummax( byte[] values ) {return Numeric.cummax( values );} + public static byte[] cummax( byte... values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(double[]) */ - public static double[] cummax( double[] values ) {return Numeric.cummax( values );} + public static double[] cummax( double... values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(float[]) */ - public static float[] cummax( float[] values ) {return Numeric.cummax( values );} + public static float[] cummax( float... values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(int[]) */ - public static int[] cummax( int[] values ) {return Numeric.cummax( values );} + public static int[] cummax( int... values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(long[]) */ - public static long[] cummax( long[] values ) {return Numeric.cummax( values );} + public static long[] cummax( long... values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(java.lang.Byte[]) */ public static byte[] cummax( java.lang.Byte[] values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(java.lang.Double[]) */ public static double[] cummax( java.lang.Double[] values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(java.lang.Float[]) */ public static float[] cummax( java.lang.Float[] values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(java.lang.Integer[]) */ public static int[] cummax( java.lang.Integer[] values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(java.lang.Long[]) */ public static long[] cummax( java.lang.Long[] values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(java.lang.Short[]) */ public static short[] cummax( java.lang.Short[] values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(short[]) */ - public static short[] cummax( short[] values ) {return Numeric.cummax( values );} + public static short[] cummax( short... values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(io.deephaven.vector.ByteVector) */ public static byte[] cummax( io.deephaven.vector.ByteVector values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(io.deephaven.vector.DoubleVector) */ public static double[] cummax( io.deephaven.vector.DoubleVector values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(io.deephaven.vector.FloatVector) */ public static float[] cummax( io.deephaven.vector.FloatVector values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(io.deephaven.vector.IntVector) */ public static int[] cummax( io.deephaven.vector.IntVector values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(io.deephaven.vector.LongVector) */ public static long[] cummax( io.deephaven.vector.LongVector values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummax(io.deephaven.vector.ShortVector) */ public static short[] cummax( io.deephaven.vector.ShortVector values ) {return Numeric.cummax( values );} + /** @see io.deephaven.function.Numeric#cummin(byte[]) */ - public static byte[] cummin( byte[] values ) {return Numeric.cummin( values );} + public static byte[] cummin( byte... values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(double[]) */ - public static double[] cummin( double[] values ) {return Numeric.cummin( values );} + public static double[] cummin( double... values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(float[]) */ - public static float[] cummin( float[] values ) {return Numeric.cummin( values );} + public static float[] cummin( float... values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(int[]) */ - public static int[] cummin( int[] values ) {return Numeric.cummin( values );} + public static int[] cummin( int... values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(long[]) */ - public static long[] cummin( long[] values ) {return Numeric.cummin( values );} + public static long[] cummin( long... values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(java.lang.Byte[]) */ public static byte[] cummin( java.lang.Byte[] values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(java.lang.Double[]) */ public static double[] cummin( java.lang.Double[] values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(java.lang.Float[]) */ public static float[] cummin( java.lang.Float[] values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(java.lang.Integer[]) */ public static int[] cummin( java.lang.Integer[] values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(java.lang.Long[]) */ public static long[] cummin( java.lang.Long[] values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(java.lang.Short[]) */ public static short[] cummin( java.lang.Short[] values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(short[]) */ - public static short[] cummin( short[] values ) {return Numeric.cummin( values );} + public static short[] cummin( short... values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(io.deephaven.vector.ByteVector) */ public static byte[] cummin( io.deephaven.vector.ByteVector values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(io.deephaven.vector.DoubleVector) */ public static double[] cummin( io.deephaven.vector.DoubleVector values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(io.deephaven.vector.FloatVector) */ public static float[] cummin( io.deephaven.vector.FloatVector values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(io.deephaven.vector.IntVector) */ public static int[] cummin( io.deephaven.vector.IntVector values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(io.deephaven.vector.LongVector) */ public static long[] cummin( io.deephaven.vector.LongVector values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cummin(io.deephaven.vector.ShortVector) */ public static short[] cummin( io.deephaven.vector.ShortVector values ) {return Numeric.cummin( values );} + /** @see io.deephaven.function.Numeric#cumprod(byte[]) */ - public static byte[] cumprod( byte[] values ) {return Numeric.cumprod( values );} + public static byte[] cumprod( byte... values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(double[]) */ - public static double[] cumprod( double[] values ) {return Numeric.cumprod( values );} + public static double[] cumprod( double... values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(float[]) */ - public static float[] cumprod( float[] values ) {return Numeric.cumprod( values );} + public static float[] cumprod( float... values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(int[]) */ - public static int[] cumprod( int[] values ) {return Numeric.cumprod( values );} + public static int[] cumprod( int... values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(long[]) */ - public static long[] cumprod( long[] values ) {return Numeric.cumprod( values );} + public static long[] cumprod( long... values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(java.lang.Byte[]) */ public static byte[] cumprod( java.lang.Byte[] values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(java.lang.Double[]) */ public static double[] cumprod( java.lang.Double[] values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(java.lang.Float[]) */ public static float[] cumprod( java.lang.Float[] values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(java.lang.Integer[]) */ public static int[] cumprod( java.lang.Integer[] values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(java.lang.Long[]) */ public static long[] cumprod( java.lang.Long[] values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(java.lang.Short[]) */ public static short[] cumprod( java.lang.Short[] values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(short[]) */ - public static short[] cumprod( short[] values ) {return Numeric.cumprod( values );} + public static short[] cumprod( short... values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(io.deephaven.vector.ByteVector) */ public static byte[] cumprod( io.deephaven.vector.ByteVector values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(io.deephaven.vector.DoubleVector) */ public static double[] cumprod( io.deephaven.vector.DoubleVector values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(io.deephaven.vector.FloatVector) */ public static float[] cumprod( io.deephaven.vector.FloatVector values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(io.deephaven.vector.IntVector) */ public static int[] cumprod( io.deephaven.vector.IntVector values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(io.deephaven.vector.LongVector) */ public static long[] cumprod( io.deephaven.vector.LongVector values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumprod(io.deephaven.vector.ShortVector) */ public static short[] cumprod( io.deephaven.vector.ShortVector values ) {return Numeric.cumprod( values );} + /** @see io.deephaven.function.Numeric#cumsum(byte[]) */ - public static byte[] cumsum( byte[] values ) {return Numeric.cumsum( values );} + public static byte[] cumsum( byte... values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(double[]) */ - public static double[] cumsum( double[] values ) {return Numeric.cumsum( values );} + public static double[] cumsum( double... values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(float[]) */ - public static float[] cumsum( float[] values ) {return Numeric.cumsum( values );} + public static float[] cumsum( float... values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(int[]) */ - public static int[] cumsum( int[] values ) {return Numeric.cumsum( values );} + public static int[] cumsum( int... values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(long[]) */ - public static long[] cumsum( long[] values ) {return Numeric.cumsum( values );} + public static long[] cumsum( long... values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(java.lang.Byte[]) */ public static byte[] cumsum( java.lang.Byte[] values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(java.lang.Double[]) */ public static double[] cumsum( java.lang.Double[] values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(java.lang.Float[]) */ public static float[] cumsum( java.lang.Float[] values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(java.lang.Integer[]) */ public static int[] cumsum( java.lang.Integer[] values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(java.lang.Long[]) */ public static long[] cumsum( java.lang.Long[] values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(java.lang.Short[]) */ public static short[] cumsum( java.lang.Short[] values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(short[]) */ - public static short[] cumsum( short[] values ) {return Numeric.cumsum( values );} + public static short[] cumsum( short... values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(io.deephaven.vector.ByteVector) */ public static byte[] cumsum( io.deephaven.vector.ByteVector values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(io.deephaven.vector.DoubleVector) */ public static double[] cumsum( io.deephaven.vector.DoubleVector values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(io.deephaven.vector.FloatVector) */ public static float[] cumsum( io.deephaven.vector.FloatVector values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(io.deephaven.vector.IntVector) */ public static int[] cumsum( io.deephaven.vector.IntVector values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(io.deephaven.vector.LongVector) */ public static long[] cumsum( io.deephaven.vector.LongVector values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Numeric#cumsum(io.deephaven.vector.ShortVector) */ public static short[] cumsum( io.deephaven.vector.ShortVector values ) {return Numeric.cumsum( values );} + /** @see io.deephaven.function.Basic#distinct(byte[]) */ - public static byte[] distinct( byte[] values ) {return Basic.distinct( values );} + public static byte[] distinct( byte... values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(char[]) */ - public static char[] distinct( char[] values ) {return Basic.distinct( values );} + public static char[] distinct( char... values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(double[]) */ - public static double[] distinct( double[] values ) {return Basic.distinct( values );} + public static double[] distinct( double... values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(float[]) */ - public static float[] distinct( float[] values ) {return Basic.distinct( values );} + public static float[] distinct( float... values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(int[]) */ - public static int[] distinct( int[] values ) {return Basic.distinct( values );} + public static int[] distinct( int... values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(long[]) */ - public static long[] distinct( long[] values ) {return Basic.distinct( values );} + public static long[] distinct( long... values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(short[]) */ - public static short[] distinct( short[] values ) {return Basic.distinct( values );} + public static short[] distinct( short... values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.ByteVector) */ public static byte[] distinct( io.deephaven.vector.ByteVector values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.CharVector) */ public static char[] distinct( io.deephaven.vector.CharVector values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.DoubleVector) */ public static double[] distinct( io.deephaven.vector.DoubleVector values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.FloatVector) */ public static float[] distinct( io.deephaven.vector.FloatVector values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.IntVector) */ public static int[] distinct( io.deephaven.vector.IntVector values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.LongVector) */ public static long[] distinct( io.deephaven.vector.LongVector values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.ShortVector) */ public static short[] distinct( io.deephaven.vector.ShortVector values ) {return Basic.distinct( values );} + /** @see io.deephaven.function.Basic#distinct(byte[],boolean) */ public static byte[] distinct( byte[] values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinct(char[],boolean) */ public static char[] distinct( char[] values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinct(double[],boolean) */ public static double[] distinct( double[] values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinct(float[],boolean) */ public static float[] distinct( float[] values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinct(int[],boolean) */ public static int[] distinct( int[] values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinct(long[],boolean) */ public static long[] distinct( long[] values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinct(short[],boolean) */ public static short[] distinct( short[] values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.ByteVector,boolean) */ public static byte[] distinct( io.deephaven.vector.ByteVector values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.CharVector,boolean) */ public static char[] distinct( io.deephaven.vector.CharVector values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.DoubleVector,boolean) */ public static double[] distinct( io.deephaven.vector.DoubleVector values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.FloatVector,boolean) */ public static float[] distinct( io.deephaven.vector.FloatVector values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.IntVector,boolean) */ public static int[] distinct( io.deephaven.vector.IntVector values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.LongVector,boolean) */ public static long[] distinct( io.deephaven.vector.LongVector values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinct(io.deephaven.vector.ShortVector,boolean) */ public static short[] distinct( io.deephaven.vector.ShortVector values, boolean includeNull ) {return Basic.distinct( values, includeNull );} + /** @see io.deephaven.function.Basic#distinctObj(java.lang.Comparable[]) */ - public static > T[] distinctObj( T[] values ) {return Basic.distinctObj( values );} + public static > T[] distinctObj( T... values ) {return Basic.distinctObj( values );} + /** @see io.deephaven.function.Basic#distinctObj(io.deephaven.vector.ObjectVector) */ public static > T[] distinctObj( io.deephaven.vector.ObjectVector values ) {return Basic.distinctObj( values );} + /** @see io.deephaven.function.Basic#distinctObj(java.lang.Comparable[],boolean) */ public static > T[] distinctObj( T[] values, boolean includeNull ) {return Basic.distinctObj( values, includeNull );} + /** @see io.deephaven.function.Basic#distinctObj(io.deephaven.vector.ObjectVector,boolean) */ public static > T[] distinctObj( io.deephaven.vector.ObjectVector values, boolean includeNull ) {return Basic.distinctObj( values, includeNull );} + /** @see io.deephaven.function.Basic#enlist(byte[]) */ - public static byte[] enlist( byte[] values ) {return Basic.enlist( values );} + public static byte[] enlist( byte... values ) {return Basic.enlist( values );} + /** @see io.deephaven.function.Basic#enlist(char[]) */ - public static char[] enlist( char[] values ) {return Basic.enlist( values );} + public static char[] enlist( char... values ) {return Basic.enlist( values );} + /** @see io.deephaven.function.Basic#enlist(double[]) */ - public static double[] enlist( double[] values ) {return Basic.enlist( values );} + public static double[] enlist( double... values ) {return Basic.enlist( values );} + /** @see io.deephaven.function.Basic#enlist(float[]) */ - public static float[] enlist( float[] values ) {return Basic.enlist( values );} + public static float[] enlist( float... values ) {return Basic.enlist( values );} + /** @see io.deephaven.function.Basic#enlist(int[]) */ - public static int[] enlist( int[] values ) {return Basic.enlist( values );} + public static int[] enlist( int... values ) {return Basic.enlist( values );} + /** @see io.deephaven.function.Basic#enlist(long[]) */ - public static long[] enlist( long[] values ) {return Basic.enlist( values );} + public static long[] enlist( long... values ) {return Basic.enlist( values );} + /** @see io.deephaven.function.Basic#enlist(short[]) */ - public static short[] enlist( short[] values ) {return Basic.enlist( values );} + public static short[] enlist( short... values ) {return Basic.enlist( values );} + /** @see io.deephaven.function.Numeric#exp(byte) */ public static double exp( byte value ) {return Numeric.exp( value );} + /** @see io.deephaven.function.Numeric#exp(double) */ public static double exp( double value ) {return Numeric.exp( value );} + /** @see io.deephaven.function.Numeric#exp(float) */ public static double exp( float value ) {return Numeric.exp( value );} + /** @see io.deephaven.function.Numeric#exp(int) */ public static double exp( int value ) {return Numeric.exp( value );} + /** @see io.deephaven.function.Numeric#exp(long) */ public static double exp( long value ) {return Numeric.exp( value );} + /** @see io.deephaven.function.Numeric#exp(short) */ public static double exp( short value ) {return Numeric.exp( value );} + /** @see io.deephaven.function.Basic#first(byte[]) */ - public static byte first( byte[] values ) {return Basic.first( values );} + public static byte first( byte... values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#first(char[]) */ - public static char first( char[] values ) {return Basic.first( values );} + public static char first( char... values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#first(double[]) */ - public static double first( double[] values ) {return Basic.first( values );} + public static double first( double... values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#first(float[]) */ - public static float first( float[] values ) {return Basic.first( values );} + public static float first( float... values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#first(int[]) */ - public static int first( int[] values ) {return Basic.first( values );} + public static int first( int... values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#first(long[]) */ - public static long first( long[] values ) {return Basic.first( values );} + public static long first( long... values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#first(short[]) */ - public static short first( short[] values ) {return Basic.first( values );} + public static short first( short... values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#first(io.deephaven.vector.ByteVector) */ public static byte first( io.deephaven.vector.ByteVector values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#first(io.deephaven.vector.CharVector) */ public static char first( io.deephaven.vector.CharVector values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#first(io.deephaven.vector.DoubleVector) */ public static double first( io.deephaven.vector.DoubleVector values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#first(io.deephaven.vector.FloatVector) */ public static float first( io.deephaven.vector.FloatVector values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#first(io.deephaven.vector.IntVector) */ public static int first( io.deephaven.vector.IntVector values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#first(io.deephaven.vector.LongVector) */ public static long first( io.deephaven.vector.LongVector values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#first(io.deephaven.vector.ShortVector) */ public static short first( io.deephaven.vector.ShortVector values ) {return Basic.first( values );} + /** @see io.deephaven.function.Basic#firstIndexOf(byte,byte[]) */ - public static long firstIndexOf( byte val, byte[] values ) {return Basic.firstIndexOf( val, values );} + public static long firstIndexOf( byte val, byte... values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOf(byte,io.deephaven.vector.ByteVector) */ public static long firstIndexOf( byte val, io.deephaven.vector.ByteVector values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOf(char,char[]) */ - public static long firstIndexOf( char val, char[] values ) {return Basic.firstIndexOf( val, values );} + public static long firstIndexOf( char val, char... values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOf(char,io.deephaven.vector.CharVector) */ public static long firstIndexOf( char val, io.deephaven.vector.CharVector values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOf(double,double[]) */ - public static long firstIndexOf( double val, double[] values ) {return Basic.firstIndexOf( val, values );} + public static long firstIndexOf( double val, double... values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOf(double,io.deephaven.vector.DoubleVector) */ public static long firstIndexOf( double val, io.deephaven.vector.DoubleVector values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOf(float,float[]) */ - public static long firstIndexOf( float val, float[] values ) {return Basic.firstIndexOf( val, values );} + public static long firstIndexOf( float val, float... values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOf(float,io.deephaven.vector.FloatVector) */ public static long firstIndexOf( float val, io.deephaven.vector.FloatVector values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOf(int,int[]) */ - public static long firstIndexOf( int val, int[] values ) {return Basic.firstIndexOf( val, values );} + public static long firstIndexOf( int val, int... values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOf(int,io.deephaven.vector.IntVector) */ public static long firstIndexOf( int val, io.deephaven.vector.IntVector values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOf(long,long[]) */ - public static long firstIndexOf( long val, long[] values ) {return Basic.firstIndexOf( val, values );} + public static long firstIndexOf( long val, long... values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOf(long,io.deephaven.vector.LongVector) */ public static long firstIndexOf( long val, io.deephaven.vector.LongVector values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOf(short,short[]) */ - public static long firstIndexOf( short val, short[] values ) {return Basic.firstIndexOf( val, values );} + public static long firstIndexOf( short val, short... values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOf(short,io.deephaven.vector.ShortVector) */ public static long firstIndexOf( short val, io.deephaven.vector.ShortVector values ) {return Basic.firstIndexOf( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOfObj(java.lang.Object,java.lang.Object[]) */ - public static long firstIndexOfObj( T val, T[] values ) {return Basic.firstIndexOfObj( val, values );} + public static long firstIndexOfObj( T val, T... values ) {return Basic.firstIndexOfObj( val, values );} + /** @see io.deephaven.function.Basic#firstIndexOfObj(java.lang.Object,io.deephaven.vector.ObjectVector) */ public static long firstIndexOfObj( T val, io.deephaven.vector.ObjectVector values ) {return Basic.firstIndexOfObj( val, values );} + /** @see io.deephaven.function.Basic#firstObj(java.lang.Object[]) */ - public static T firstObj( T[] values ) {return Basic.firstObj( values );} + public static T firstObj( T... values ) {return Basic.firstObj( values );} + /** @see io.deephaven.function.Basic#firstObj(io.deephaven.vector.ObjectVector) */ public static T firstObj( io.deephaven.vector.ObjectVector values ) {return Basic.firstObj( values );} + /** @see io.deephaven.function.Numeric#floor(byte) */ public static double floor( byte value ) {return Numeric.floor( value );} + /** @see io.deephaven.function.Numeric#floor(double) */ public static double floor( double value ) {return Numeric.floor( value );} + /** @see io.deephaven.function.Numeric#floor(float) */ public static double floor( float value ) {return Numeric.floor( value );} + /** @see io.deephaven.function.Numeric#floor(int) */ public static double floor( int value ) {return Numeric.floor( value );} + /** @see io.deephaven.function.Numeric#floor(long) */ public static double floor( long value ) {return Numeric.floor( value );} + /** @see io.deephaven.function.Numeric#floor(short) */ public static double floor( short value ) {return Numeric.floor( value );} + /** @see io.deephaven.function.Basic#forwardFill(byte[]) */ - public static byte[] forwardFill( byte[] values ) {return Basic.forwardFill( values );} + public static byte[] forwardFill( byte... values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFill(char[]) */ - public static char[] forwardFill( char[] values ) {return Basic.forwardFill( values );} + public static char[] forwardFill( char... values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFill(double[]) */ - public static double[] forwardFill( double[] values ) {return Basic.forwardFill( values );} + public static double[] forwardFill( double... values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFill(float[]) */ - public static float[] forwardFill( float[] values ) {return Basic.forwardFill( values );} + public static float[] forwardFill( float... values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFill(int[]) */ - public static int[] forwardFill( int[] values ) {return Basic.forwardFill( values );} + public static int[] forwardFill( int... values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFill(long[]) */ - public static long[] forwardFill( long[] values ) {return Basic.forwardFill( values );} + public static long[] forwardFill( long... values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFill(short[]) */ - public static short[] forwardFill( short[] values ) {return Basic.forwardFill( values );} + public static short[] forwardFill( short... values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFill(io.deephaven.vector.ByteVector) */ public static byte[] forwardFill( io.deephaven.vector.ByteVector values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFill(io.deephaven.vector.CharVector) */ public static char[] forwardFill( io.deephaven.vector.CharVector values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFill(io.deephaven.vector.DoubleVector) */ public static double[] forwardFill( io.deephaven.vector.DoubleVector values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFill(io.deephaven.vector.FloatVector) */ public static float[] forwardFill( io.deephaven.vector.FloatVector values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFill(io.deephaven.vector.IntVector) */ public static int[] forwardFill( io.deephaven.vector.IntVector values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFill(io.deephaven.vector.LongVector) */ public static long[] forwardFill( io.deephaven.vector.LongVector values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFill(io.deephaven.vector.ShortVector) */ public static short[] forwardFill( io.deephaven.vector.ShortVector values ) {return Basic.forwardFill( values );} + /** @see io.deephaven.function.Basic#forwardFillObj(java.lang.Object[]) */ - public static T[] forwardFillObj( T[] values ) {return Basic.forwardFillObj( values );} + public static T[] forwardFillObj( T... values ) {return Basic.forwardFillObj( values );} + /** @see io.deephaven.function.Basic#forwardFillObj(io.deephaven.vector.ObjectVector) */ public static T[] forwardFillObj( io.deephaven.vector.ObjectVector values ) {return Basic.forwardFillObj( values );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],byte,byte) */ public static byte[] ifelse( java.lang.Boolean[] condition, byte trueCase, byte falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],char,char) */ public static char[] ifelse( java.lang.Boolean[] condition, char trueCase, char falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],byte[],byte[]) */ public static byte[] ifelse( java.lang.Boolean[] condition, byte[] trueCase, byte[] falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],char[],char[]) */ public static char[] ifelse( java.lang.Boolean[] condition, char[] trueCase, char[] falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],double[],double[]) */ public static double[] ifelse( java.lang.Boolean[] condition, double[] trueCase, double[] falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],float[],float[]) */ public static float[] ifelse( java.lang.Boolean[] condition, float[] trueCase, float[] falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],int[],int[]) */ public static int[] ifelse( java.lang.Boolean[] condition, int[] trueCase, int[] falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],long[],long[]) */ public static long[] ifelse( java.lang.Boolean[] condition, long[] trueCase, long[] falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],short[],short[]) */ public static short[] ifelse( java.lang.Boolean[] condition, short[] trueCase, short[] falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],double,double) */ public static double[] ifelse( java.lang.Boolean[] condition, double trueCase, double falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],float,float) */ public static float[] ifelse( java.lang.Boolean[] condition, float trueCase, float falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],int,int) */ public static int[] ifelse( java.lang.Boolean[] condition, int trueCase, int falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],long,long) */ public static long[] ifelse( java.lang.Boolean[] condition, long trueCase, long falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean[],short,short) */ public static short[] ifelse( java.lang.Boolean[] condition, short trueCase, short falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean,byte,byte) */ public static byte ifelse( java.lang.Boolean condition, byte trueCase, byte falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean,char,char) */ public static char ifelse( java.lang.Boolean condition, char trueCase, char falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean,double,double) */ public static double ifelse( java.lang.Boolean condition, double trueCase, double falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean,float,float) */ public static float ifelse( java.lang.Boolean condition, float trueCase, float falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean,int,int) */ public static int ifelse( java.lang.Boolean condition, int trueCase, int falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean,long,long) */ public static long ifelse( java.lang.Boolean condition, long trueCase, long falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(java.lang.Boolean,short,short) */ public static short ifelse( java.lang.Boolean condition, short trueCase, short falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,byte,byte) */ public static byte[] ifelse( io.deephaven.vector.ObjectVector condition, byte trueCase, byte falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,char,char) */ public static char[] ifelse( io.deephaven.vector.ObjectVector condition, char trueCase, char falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,double,double) */ public static double[] ifelse( io.deephaven.vector.ObjectVector condition, double trueCase, double falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,float,float) */ public static float[] ifelse( io.deephaven.vector.ObjectVector condition, float trueCase, float falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,int,int) */ public static int[] ifelse( io.deephaven.vector.ObjectVector condition, int trueCase, int falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,io.deephaven.vector.ByteVector,io.deephaven.vector.ByteVector) */ public static byte[] ifelse( io.deephaven.vector.ObjectVector condition, io.deephaven.vector.ByteVector trueCase, io.deephaven.vector.ByteVector falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,io.deephaven.vector.CharVector,io.deephaven.vector.CharVector) */ public static char[] ifelse( io.deephaven.vector.ObjectVector condition, io.deephaven.vector.CharVector trueCase, io.deephaven.vector.CharVector falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,io.deephaven.vector.DoubleVector,io.deephaven.vector.DoubleVector) */ public static double[] ifelse( io.deephaven.vector.ObjectVector condition, io.deephaven.vector.DoubleVector trueCase, io.deephaven.vector.DoubleVector falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,io.deephaven.vector.FloatVector,io.deephaven.vector.FloatVector) */ public static float[] ifelse( io.deephaven.vector.ObjectVector condition, io.deephaven.vector.FloatVector trueCase, io.deephaven.vector.FloatVector falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,io.deephaven.vector.IntVector,io.deephaven.vector.IntVector) */ public static int[] ifelse( io.deephaven.vector.ObjectVector condition, io.deephaven.vector.IntVector trueCase, io.deephaven.vector.IntVector falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,io.deephaven.vector.LongVector,io.deephaven.vector.LongVector) */ public static long[] ifelse( io.deephaven.vector.ObjectVector condition, io.deephaven.vector.LongVector trueCase, io.deephaven.vector.LongVector falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,io.deephaven.vector.ShortVector,io.deephaven.vector.ShortVector) */ public static short[] ifelse( io.deephaven.vector.ObjectVector condition, io.deephaven.vector.ShortVector trueCase, io.deephaven.vector.ShortVector falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,long,long) */ public static long[] ifelse( io.deephaven.vector.ObjectVector condition, long trueCase, long falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelse(io.deephaven.vector.ObjectVector,short,short) */ public static short[] ifelse( io.deephaven.vector.ObjectVector condition, short trueCase, short falseCase ) {return Basic.ifelse( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelseObj(java.lang.Boolean[],java.lang.Object,java.lang.Object) */ public static T[] ifelseObj( java.lang.Boolean[] condition, T trueCase, T falseCase ) {return Basic.ifelseObj( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelseObj(java.lang.Boolean[],java.lang.Object[],java.lang.Object[]) */ public static T[] ifelseObj( java.lang.Boolean[] condition, T[] trueCase, T[] falseCase ) {return Basic.ifelseObj( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelseObj(java.lang.Boolean,java.lang.Object,java.lang.Object) */ public static T ifelseObj( java.lang.Boolean condition, T trueCase, T falseCase ) {return Basic.ifelseObj( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelseObj(io.deephaven.vector.ObjectVector,java.lang.Object,java.lang.Object) */ public static T[] ifelseObj( io.deephaven.vector.ObjectVector condition, T trueCase, T falseCase ) {return Basic.ifelseObj( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#ifelseObj(io.deephaven.vector.ObjectVector,io.deephaven.vector.ObjectVector,io.deephaven.vector.ObjectVector) */ public static T[] ifelseObj( io.deephaven.vector.ObjectVector condition, io.deephaven.vector.ObjectVector trueCase, io.deephaven.vector.ObjectVector falseCase ) {return Basic.ifelseObj( condition, trueCase, falseCase );} + /** @see io.deephaven.function.Basic#in(byte,byte[]) */ - public static boolean in( byte testedValues, byte[] possibleValues ) {return Basic.in( testedValues, possibleValues );} + public static boolean in( byte testedValues, byte... possibleValues ) {return Basic.in( testedValues, possibleValues );} + /** @see io.deephaven.function.Basic#in(char,char[]) */ - public static boolean in( char testedValues, char[] possibleValues ) {return Basic.in( testedValues, possibleValues );} + public static boolean in( char testedValues, char... possibleValues ) {return Basic.in( testedValues, possibleValues );} + /** @see io.deephaven.function.Basic#in(double,double[]) */ - public static boolean in( double testedValues, double[] possibleValues ) {return Basic.in( testedValues, possibleValues );} + public static boolean in( double testedValues, double... possibleValues ) {return Basic.in( testedValues, possibleValues );} + /** @see io.deephaven.function.Basic#in(float,float[]) */ - public static boolean in( float testedValues, float[] possibleValues ) {return Basic.in( testedValues, possibleValues );} + public static boolean in( float testedValues, float... possibleValues ) {return Basic.in( testedValues, possibleValues );} + /** @see io.deephaven.function.Basic#in(int,int[]) */ - public static boolean in( int testedValues, int[] possibleValues ) {return Basic.in( testedValues, possibleValues );} + public static boolean in( int testedValues, int... possibleValues ) {return Basic.in( testedValues, possibleValues );} + /** @see io.deephaven.function.Basic#in(long,long[]) */ - public static boolean in( long testedValues, long[] possibleValues ) {return Basic.in( testedValues, possibleValues );} + public static boolean in( long testedValues, long... possibleValues ) {return Basic.in( testedValues, possibleValues );} + /** @see io.deephaven.function.Basic#in(short,short[]) */ - public static boolean in( short testedValues, short[] possibleValues ) {return Basic.in( testedValues, possibleValues );} + public static boolean in( short testedValues, short... possibleValues ) {return Basic.in( testedValues, possibleValues );} + /** @see io.deephaven.function.Basic#inObj(java.lang.Object,java.lang.Object[]) */ - public static boolean inObj( T testedValue, T[] possibleValues ) {return Basic.inObj( testedValue, possibleValues );} + public static boolean inObj( T testedValue, T... possibleValues ) {return Basic.inObj( testedValue, possibleValues );} + /** @see io.deephaven.function.Basic#inObj(java.lang.Object,io.deephaven.vector.ObjectVector) */ public static boolean inObj( T testedValue, io.deephaven.vector.ObjectVector possibleValues ) {return Basic.inObj( testedValue, possibleValues );} + /** @see io.deephaven.function.Basic#inRange(java.lang.Comparable,java.lang.Comparable,java.lang.Comparable) */ public static > boolean inRange( T testedValue, T lowInclusiveValue, T highInclusiveValue ) {return Basic.inRange( testedValue, lowInclusiveValue, highInclusiveValue );} + /** @see io.deephaven.function.Basic#inRange(byte,byte,byte) */ public static boolean inRange( byte testedValue, byte lowInclusiveValue, byte highInclusiveValue ) {return Basic.inRange( testedValue, lowInclusiveValue, highInclusiveValue );} + /** @see io.deephaven.function.Basic#inRange(char,char,char) */ public static boolean inRange( char testedValue, char lowInclusiveValue, char highInclusiveValue ) {return Basic.inRange( testedValue, lowInclusiveValue, highInclusiveValue );} + /** @see io.deephaven.function.Basic#inRange(double,double,double) */ public static boolean inRange( double testedValue, double lowInclusiveValue, double highInclusiveValue ) {return Basic.inRange( testedValue, lowInclusiveValue, highInclusiveValue );} + /** @see io.deephaven.function.Basic#inRange(float,float,float) */ public static boolean inRange( float testedValue, float lowInclusiveValue, float highInclusiveValue ) {return Basic.inRange( testedValue, lowInclusiveValue, highInclusiveValue );} + /** @see io.deephaven.function.Basic#inRange(int,int,int) */ public static boolean inRange( int testedValue, int lowInclusiveValue, int highInclusiveValue ) {return Basic.inRange( testedValue, lowInclusiveValue, highInclusiveValue );} + /** @see io.deephaven.function.Basic#inRange(long,long,long) */ public static boolean inRange( long testedValue, long lowInclusiveValue, long highInclusiveValue ) {return Basic.inRange( testedValue, lowInclusiveValue, highInclusiveValue );} + /** @see io.deephaven.function.Basic#inRange(short,short,short) */ public static boolean inRange( short testedValue, short lowInclusiveValue, short highInclusiveValue ) {return Basic.inRange( testedValue, lowInclusiveValue, highInclusiveValue );} + /** @see io.deephaven.function.Numeric#indexOfMax(byte[]) */ - public static long indexOfMax( byte[] values ) {return Numeric.indexOfMax( values );} + public static long indexOfMax( byte... values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(double[]) */ - public static long indexOfMax( double[] values ) {return Numeric.indexOfMax( values );} + public static long indexOfMax( double... values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(float[]) */ - public static long indexOfMax( float[] values ) {return Numeric.indexOfMax( values );} + public static long indexOfMax( float... values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(int[]) */ - public static long indexOfMax( int[] values ) {return Numeric.indexOfMax( values );} + public static long indexOfMax( int... values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(long[]) */ - public static long indexOfMax( long[] values ) {return Numeric.indexOfMax( values );} + public static long indexOfMax( long... values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(java.lang.Byte[]) */ public static long indexOfMax( java.lang.Byte[] values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(java.lang.Double[]) */ public static long indexOfMax( java.lang.Double[] values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(java.lang.Float[]) */ public static long indexOfMax( java.lang.Float[] values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(java.lang.Integer[]) */ public static long indexOfMax( java.lang.Integer[] values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(java.lang.Long[]) */ public static long indexOfMax( java.lang.Long[] values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(java.lang.Short[]) */ public static long indexOfMax( java.lang.Short[] values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(short[]) */ - public static long indexOfMax( short[] values ) {return Numeric.indexOfMax( values );} + public static long indexOfMax( short... values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(io.deephaven.vector.ByteVector) */ public static long indexOfMax( io.deephaven.vector.ByteVector values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(io.deephaven.vector.DoubleVector) */ public static long indexOfMax( io.deephaven.vector.DoubleVector values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(io.deephaven.vector.FloatVector) */ public static long indexOfMax( io.deephaven.vector.FloatVector values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(io.deephaven.vector.IntVector) */ public static long indexOfMax( io.deephaven.vector.IntVector values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(io.deephaven.vector.LongVector) */ public static long indexOfMax( io.deephaven.vector.LongVector values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMax(io.deephaven.vector.ShortVector) */ public static long indexOfMax( io.deephaven.vector.ShortVector values ) {return Numeric.indexOfMax( values );} + /** @see io.deephaven.function.Numeric#indexOfMaxObj(java.lang.Comparable[]) */ - public static > long indexOfMaxObj( T[] values ) {return Numeric.indexOfMaxObj( values );} + public static > long indexOfMaxObj( T... values ) {return Numeric.indexOfMaxObj( values );} + /** @see io.deephaven.function.Numeric#indexOfMaxObj(io.deephaven.vector.ObjectVector) */ public static > long indexOfMaxObj( io.deephaven.vector.ObjectVector values ) {return Numeric.indexOfMaxObj( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(byte[]) */ - public static long indexOfMin( byte[] values ) {return Numeric.indexOfMin( values );} + public static long indexOfMin( byte... values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(double[]) */ - public static long indexOfMin( double[] values ) {return Numeric.indexOfMin( values );} + public static long indexOfMin( double... values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(float[]) */ - public static long indexOfMin( float[] values ) {return Numeric.indexOfMin( values );} + public static long indexOfMin( float... values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(int[]) */ - public static long indexOfMin( int[] values ) {return Numeric.indexOfMin( values );} + public static long indexOfMin( int... values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(long[]) */ - public static long indexOfMin( long[] values ) {return Numeric.indexOfMin( values );} + public static long indexOfMin( long... values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(java.lang.Byte[]) */ public static long indexOfMin( java.lang.Byte[] values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(java.lang.Double[]) */ public static long indexOfMin( java.lang.Double[] values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(java.lang.Float[]) */ public static long indexOfMin( java.lang.Float[] values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(java.lang.Integer[]) */ public static long indexOfMin( java.lang.Integer[] values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(java.lang.Long[]) */ public static long indexOfMin( java.lang.Long[] values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(java.lang.Short[]) */ public static long indexOfMin( java.lang.Short[] values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(short[]) */ - public static long indexOfMin( short[] values ) {return Numeric.indexOfMin( values );} + public static long indexOfMin( short... values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(io.deephaven.vector.ByteVector) */ public static long indexOfMin( io.deephaven.vector.ByteVector values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(io.deephaven.vector.DoubleVector) */ public static long indexOfMin( io.deephaven.vector.DoubleVector values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(io.deephaven.vector.FloatVector) */ public static long indexOfMin( io.deephaven.vector.FloatVector values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(io.deephaven.vector.IntVector) */ public static long indexOfMin( io.deephaven.vector.IntVector values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(io.deephaven.vector.LongVector) */ public static long indexOfMin( io.deephaven.vector.LongVector values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMin(io.deephaven.vector.ShortVector) */ public static long indexOfMin( io.deephaven.vector.ShortVector values ) {return Numeric.indexOfMin( values );} + /** @see io.deephaven.function.Numeric#indexOfMinObj(java.lang.Comparable[]) */ - public static > long indexOfMinObj( T[] values ) {return Numeric.indexOfMinObj( values );} + public static > long indexOfMinObj( T... values ) {return Numeric.indexOfMinObj( values );} + /** @see io.deephaven.function.Numeric#indexOfMinObj(io.deephaven.vector.ObjectVector) */ public static > long indexOfMinObj( io.deephaven.vector.ObjectVector values ) {return Numeric.indexOfMinObj( values );} + /** @see io.deephaven.function.Numeric#isFinite(byte) */ public static boolean isFinite( byte value ) {return Numeric.isFinite( value );} + /** @see io.deephaven.function.Numeric#isFinite(java.lang.Byte) */ public static boolean isFinite( java.lang.Byte value ) {return Numeric.isFinite( value );} + /** @see io.deephaven.function.Numeric#isFinite(java.lang.Double) */ public static boolean isFinite( java.lang.Double value ) {return Numeric.isFinite( value );} + /** @see io.deephaven.function.Numeric#isFinite(java.lang.Float) */ public static boolean isFinite( java.lang.Float value ) {return Numeric.isFinite( value );} + /** @see io.deephaven.function.Numeric#isFinite(java.lang.Integer) */ public static boolean isFinite( java.lang.Integer value ) {return Numeric.isFinite( value );} + /** @see io.deephaven.function.Numeric#isFinite(java.lang.Long) */ public static boolean isFinite( java.lang.Long value ) {return Numeric.isFinite( value );} + /** @see io.deephaven.function.Numeric#isFinite(java.lang.Short) */ public static boolean isFinite( java.lang.Short value ) {return Numeric.isFinite( value );} + /** @see io.deephaven.function.Numeric#isFinite(double) */ public static boolean isFinite( double value ) {return Numeric.isFinite( value );} + /** @see io.deephaven.function.Numeric#isFinite(float) */ public static boolean isFinite( float value ) {return Numeric.isFinite( value );} + /** @see io.deephaven.function.Numeric#isFinite(int) */ public static boolean isFinite( int value ) {return Numeric.isFinite( value );} + /** @see io.deephaven.function.Numeric#isFinite(long) */ public static boolean isFinite( long value ) {return Numeric.isFinite( value );} + /** @see io.deephaven.function.Numeric#isFinite(short) */ public static boolean isFinite( short value ) {return Numeric.isFinite( value );} + /** @see io.deephaven.function.Numeric#isInf(byte) */ public static boolean isInf( byte value ) {return Numeric.isInf( value );} + /** @see io.deephaven.function.Numeric#isInf(java.lang.Byte) */ public static boolean isInf( java.lang.Byte value ) {return Numeric.isInf( value );} + /** @see io.deephaven.function.Numeric#isInf(java.lang.Double) */ public static boolean isInf( java.lang.Double value ) {return Numeric.isInf( value );} + /** @see io.deephaven.function.Numeric#isInf(java.lang.Float) */ public static boolean isInf( java.lang.Float value ) {return Numeric.isInf( value );} + /** @see io.deephaven.function.Numeric#isInf(java.lang.Integer) */ public static boolean isInf( java.lang.Integer value ) {return Numeric.isInf( value );} + /** @see io.deephaven.function.Numeric#isInf(java.lang.Long) */ public static boolean isInf( java.lang.Long value ) {return Numeric.isInf( value );} + /** @see io.deephaven.function.Numeric#isInf(java.lang.Short) */ public static boolean isInf( java.lang.Short value ) {return Numeric.isInf( value );} + /** @see io.deephaven.function.Numeric#isInf(double) */ public static boolean isInf( double value ) {return Numeric.isInf( value );} + /** @see io.deephaven.function.Numeric#isInf(float) */ public static boolean isInf( float value ) {return Numeric.isInf( value );} + /** @see io.deephaven.function.Numeric#isInf(int) */ public static boolean isInf( int value ) {return Numeric.isInf( value );} + /** @see io.deephaven.function.Numeric#isInf(long) */ public static boolean isInf( long value ) {return Numeric.isInf( value );} + /** @see io.deephaven.function.Numeric#isInf(short) */ public static boolean isInf( short value ) {return Numeric.isInf( value );} + /** @see io.deephaven.function.Numeric#isNaN(byte) */ public static boolean isNaN( byte value ) {return Numeric.isNaN( value );} + /** @see io.deephaven.function.Numeric#isNaN(java.lang.Byte) */ public static boolean isNaN( java.lang.Byte value ) {return Numeric.isNaN( value );} + /** @see io.deephaven.function.Numeric#isNaN(java.lang.Double) */ public static boolean isNaN( java.lang.Double value ) {return Numeric.isNaN( value );} + /** @see io.deephaven.function.Numeric#isNaN(java.lang.Float) */ public static boolean isNaN( java.lang.Float value ) {return Numeric.isNaN( value );} + /** @see io.deephaven.function.Numeric#isNaN(java.lang.Integer) */ public static boolean isNaN( java.lang.Integer value ) {return Numeric.isNaN( value );} + /** @see io.deephaven.function.Numeric#isNaN(java.lang.Long) */ public static boolean isNaN( java.lang.Long value ) {return Numeric.isNaN( value );} + /** @see io.deephaven.function.Numeric#isNaN(java.lang.Short) */ public static boolean isNaN( java.lang.Short value ) {return Numeric.isNaN( value );} + /** @see io.deephaven.function.Numeric#isNaN(double) */ public static boolean isNaN( double value ) {return Numeric.isNaN( value );} + /** @see io.deephaven.function.Numeric#isNaN(float) */ public static boolean isNaN( float value ) {return Numeric.isNaN( value );} + /** @see io.deephaven.function.Numeric#isNaN(int) */ public static boolean isNaN( int value ) {return Numeric.isNaN( value );} + /** @see io.deephaven.function.Numeric#isNaN(long) */ public static boolean isNaN( long value ) {return Numeric.isNaN( value );} + /** @see io.deephaven.function.Numeric#isNaN(short) */ public static boolean isNaN( short value ) {return Numeric.isNaN( value );} + /** @see io.deephaven.function.Basic#isNull(java.lang.Object) */ public static boolean isNull( T value ) {return Basic.isNull( value );} + /** @see io.deephaven.function.Basic#isNull(byte) */ public static boolean isNull( byte value ) {return Basic.isNull( value );} + /** @see io.deephaven.function.Basic#isNull(char) */ public static boolean isNull( char value ) {return Basic.isNull( value );} + /** @see io.deephaven.function.Basic#isNull(double) */ public static boolean isNull( double value ) {return Basic.isNull( value );} + /** @see io.deephaven.function.Basic#isNull(float) */ public static boolean isNull( float value ) {return Basic.isNull( value );} + /** @see io.deephaven.function.Basic#isNull(int) */ public static boolean isNull( int value ) {return Basic.isNull( value );} + /** @see io.deephaven.function.Basic#isNull(long) */ public static boolean isNull( long value ) {return Basic.isNull( value );} + /** @see io.deephaven.function.Basic#isNull(short) */ public static boolean isNull( short value ) {return Basic.isNull( value );} + /** @see io.deephaven.function.Basic#last(byte[]) */ - public static byte last( byte[] values ) {return Basic.last( values );} + public static byte last( byte... values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#last(char[]) */ - public static char last( char[] values ) {return Basic.last( values );} + public static char last( char... values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#last(double[]) */ - public static double last( double[] values ) {return Basic.last( values );} + public static double last( double... values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#last(float[]) */ - public static float last( float[] values ) {return Basic.last( values );} + public static float last( float... values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#last(int[]) */ - public static int last( int[] values ) {return Basic.last( values );} + public static int last( int... values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#last(long[]) */ - public static long last( long[] values ) {return Basic.last( values );} + public static long last( long... values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#last(short[]) */ - public static short last( short[] values ) {return Basic.last( values );} + public static short last( short... values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#last(io.deephaven.vector.ByteVector) */ public static byte last( io.deephaven.vector.ByteVector values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#last(io.deephaven.vector.CharVector) */ public static char last( io.deephaven.vector.CharVector values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#last(io.deephaven.vector.DoubleVector) */ public static double last( io.deephaven.vector.DoubleVector values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#last(io.deephaven.vector.FloatVector) */ public static float last( io.deephaven.vector.FloatVector values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#last(io.deephaven.vector.IntVector) */ public static int last( io.deephaven.vector.IntVector values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#last(io.deephaven.vector.LongVector) */ public static long last( io.deephaven.vector.LongVector values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#last(io.deephaven.vector.ShortVector) */ public static short last( io.deephaven.vector.ShortVector values ) {return Basic.last( values );} + /** @see io.deephaven.function.Basic#lastObj(java.lang.Object[]) */ - public static T lastObj( T[] values ) {return Basic.lastObj( values );} + public static T lastObj( T... values ) {return Basic.lastObj( values );} + /** @see io.deephaven.function.Basic#lastObj(io.deephaven.vector.ObjectVector) */ public static T lastObj( io.deephaven.vector.ObjectVector values ) {return Basic.lastObj( values );} + /** @see io.deephaven.function.Basic#len(java.lang.Object[]) */ public static long len( T[] values ) {return Basic.len( values );} + /** @see io.deephaven.function.Basic#len(byte[]) */ public static long len( byte[] values ) {return Basic.len( values );} + /** @see io.deephaven.function.Basic#len(char[]) */ public static long len( char[] values ) {return Basic.len( values );} + /** @see io.deephaven.function.Basic#len(double[]) */ public static long len( double[] values ) {return Basic.len( values );} + /** @see io.deephaven.function.Basic#len(float[]) */ public static long len( float[] values ) {return Basic.len( values );} + /** @see io.deephaven.function.Basic#len(int[]) */ public static long len( int[] values ) {return Basic.len( values );} + /** @see io.deephaven.function.Basic#len(long[]) */ public static long len( long[] values ) {return Basic.len( values );} + /** @see io.deephaven.function.Basic#len(short[]) */ public static long len( short[] values ) {return Basic.len( values );} + /** @see io.deephaven.function.Basic#len(io.deephaven.util.datastructures.LongSizedDataStructure) */ public static long len( io.deephaven.util.datastructures.LongSizedDataStructure values ) {return Basic.len( values );} + /** @see io.deephaven.function.Numeric#log(byte) */ public static double log( byte value ) {return Numeric.log( value );} + /** @see io.deephaven.function.Numeric#log(double) */ public static double log( double value ) {return Numeric.log( value );} + /** @see io.deephaven.function.Numeric#log(float) */ public static double log( float value ) {return Numeric.log( value );} + /** @see io.deephaven.function.Numeric#log(int) */ public static double log( int value ) {return Numeric.log( value );} + /** @see io.deephaven.function.Numeric#log(long) */ public static double log( long value ) {return Numeric.log( value );} + /** @see io.deephaven.function.Numeric#log(short) */ public static double log( short value ) {return Numeric.log( value );} + /** @see io.deephaven.function.Numeric#lowerBin(byte,byte) */ public static byte lowerBin( byte value, byte interval ) {return Numeric.lowerBin( value, interval );} + /** @see io.deephaven.function.Numeric#lowerBin(double,double) */ public static double lowerBin( double value, double interval ) {return Numeric.lowerBin( value, interval );} + /** @see io.deephaven.function.Numeric#lowerBin(float,float) */ public static float lowerBin( float value, float interval ) {return Numeric.lowerBin( value, interval );} + /** @see io.deephaven.function.Numeric#lowerBin(int,int) */ public static int lowerBin( int value, int interval ) {return Numeric.lowerBin( value, interval );} + /** @see io.deephaven.function.Numeric#lowerBin(long,long) */ public static long lowerBin( long value, long interval ) {return Numeric.lowerBin( value, interval );} + /** @see io.deephaven.function.Numeric#lowerBin(short,short) */ public static short lowerBin( short value, short interval ) {return Numeric.lowerBin( value, interval );} + /** @see io.deephaven.function.Numeric#lowerBin(byte,byte,byte) */ public static byte lowerBin( byte value, byte interval, byte offset ) {return Numeric.lowerBin( value, interval, offset );} + /** @see io.deephaven.function.Numeric#lowerBin(double,double,double) */ public static double lowerBin( double value, double interval, double offset ) {return Numeric.lowerBin( value, interval, offset );} + /** @see io.deephaven.function.Numeric#lowerBin(float,float,float) */ public static float lowerBin( float value, float interval, float offset ) {return Numeric.lowerBin( value, interval, offset );} + /** @see io.deephaven.function.Numeric#lowerBin(int,int,int) */ public static int lowerBin( int value, int interval, int offset ) {return Numeric.lowerBin( value, interval, offset );} + /** @see io.deephaven.function.Numeric#lowerBin(long,long,long) */ public static long lowerBin( long value, long interval, long offset ) {return Numeric.lowerBin( value, interval, offset );} + /** @see io.deephaven.function.Numeric#lowerBin(short,short,short) */ public static short lowerBin( short value, short interval, short offset ) {return Numeric.lowerBin( value, interval, offset );} + /** @see io.deephaven.function.Numeric#max(byte[]) */ - public static byte max( byte[] values ) {return Numeric.max( values );} + public static byte max( byte... values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(double[]) */ - public static double max( double[] values ) {return Numeric.max( values );} + public static double max( double... values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(float[]) */ - public static float max( float[] values ) {return Numeric.max( values );} + public static float max( float... values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(int[]) */ - public static int max( int[] values ) {return Numeric.max( values );} + public static int max( int... values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(long[]) */ - public static long max( long[] values ) {return Numeric.max( values );} + public static long max( long... values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(java.lang.Byte[]) */ public static byte max( java.lang.Byte[] values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(java.lang.Double[]) */ public static double max( java.lang.Double[] values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(java.lang.Float[]) */ public static float max( java.lang.Float[] values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(java.lang.Integer[]) */ public static int max( java.lang.Integer[] values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(java.lang.Long[]) */ public static long max( java.lang.Long[] values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(java.lang.Short[]) */ public static short max( java.lang.Short[] values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(short[]) */ - public static short max( short[] values ) {return Numeric.max( values );} + public static short max( short... values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(io.deephaven.vector.ByteVector) */ public static byte max( io.deephaven.vector.ByteVector values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(io.deephaven.vector.DoubleVector) */ public static double max( io.deephaven.vector.DoubleVector values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(io.deephaven.vector.FloatVector) */ public static float max( io.deephaven.vector.FloatVector values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(io.deephaven.vector.IntVector) */ public static int max( io.deephaven.vector.IntVector values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(io.deephaven.vector.LongVector) */ public static long max( io.deephaven.vector.LongVector values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#max(io.deephaven.vector.ShortVector) */ public static short max( io.deephaven.vector.ShortVector values ) {return Numeric.max( values );} + /** @see io.deephaven.function.Numeric#maxObj(java.lang.Comparable[]) */ - public static > T maxObj( T[] values ) {return Numeric.maxObj( values );} + public static > T maxObj( T... values ) {return Numeric.maxObj( values );} + /** @see io.deephaven.function.Numeric#maxObj(io.deephaven.vector.ObjectVector) */ public static > T maxObj( io.deephaven.vector.ObjectVector values ) {return Numeric.maxObj( values );} + /** @see io.deephaven.function.Numeric#median(byte[]) */ - public static double median( byte[] values ) {return Numeric.median( values );} + public static double median( byte... values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(double[]) */ - public static double median( double[] values ) {return Numeric.median( values );} + public static double median( double... values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(float[]) */ - public static double median( float[] values ) {return Numeric.median( values );} + public static double median( float... values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(int[]) */ - public static double median( int[] values ) {return Numeric.median( values );} + public static double median( int... values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(long[]) */ - public static double median( long[] values ) {return Numeric.median( values );} + public static double median( long... values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(java.lang.Byte[]) */ public static double median( java.lang.Byte[] values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(java.lang.Double[]) */ public static double median( java.lang.Double[] values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(java.lang.Float[]) */ public static double median( java.lang.Float[] values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(java.lang.Integer[]) */ public static double median( java.lang.Integer[] values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(java.lang.Long[]) */ public static double median( java.lang.Long[] values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(java.lang.Short[]) */ public static double median( java.lang.Short[] values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(short[]) */ - public static double median( short[] values ) {return Numeric.median( values );} + public static double median( short... values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(io.deephaven.vector.ByteVector) */ public static double median( io.deephaven.vector.ByteVector values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(io.deephaven.vector.DoubleVector) */ public static double median( io.deephaven.vector.DoubleVector values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(io.deephaven.vector.FloatVector) */ public static double median( io.deephaven.vector.FloatVector values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(io.deephaven.vector.IntVector) */ public static double median( io.deephaven.vector.IntVector values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(io.deephaven.vector.LongVector) */ public static double median( io.deephaven.vector.LongVector values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#median(io.deephaven.vector.ShortVector) */ public static double median( io.deephaven.vector.ShortVector values ) {return Numeric.median( values );} + /** @see io.deephaven.function.Numeric#min(byte[]) */ - public static byte min( byte[] values ) {return Numeric.min( values );} + public static byte min( byte... values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(double[]) */ - public static double min( double[] values ) {return Numeric.min( values );} + public static double min( double... values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(float[]) */ - public static float min( float[] values ) {return Numeric.min( values );} + public static float min( float... values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(int[]) */ - public static int min( int[] values ) {return Numeric.min( values );} + public static int min( int... values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(long[]) */ - public static long min( long[] values ) {return Numeric.min( values );} + public static long min( long... values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(java.lang.Byte[]) */ public static byte min( java.lang.Byte[] values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(java.lang.Double[]) */ public static double min( java.lang.Double[] values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(java.lang.Float[]) */ public static float min( java.lang.Float[] values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(java.lang.Integer[]) */ public static int min( java.lang.Integer[] values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(java.lang.Long[]) */ public static long min( java.lang.Long[] values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(java.lang.Short[]) */ public static short min( java.lang.Short[] values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(short[]) */ - public static short min( short[] values ) {return Numeric.min( values );} + public static short min( short... values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(io.deephaven.vector.ByteVector) */ public static byte min( io.deephaven.vector.ByteVector values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(io.deephaven.vector.DoubleVector) */ public static double min( io.deephaven.vector.DoubleVector values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(io.deephaven.vector.FloatVector) */ public static float min( io.deephaven.vector.FloatVector values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(io.deephaven.vector.IntVector) */ public static int min( io.deephaven.vector.IntVector values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(io.deephaven.vector.LongVector) */ public static long min( io.deephaven.vector.LongVector values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#min(io.deephaven.vector.ShortVector) */ public static short min( io.deephaven.vector.ShortVector values ) {return Numeric.min( values );} + /** @see io.deephaven.function.Numeric#minObj(java.lang.Comparable[]) */ - public static > T minObj( T[] values ) {return Numeric.minObj( values );} + public static > T minObj( T... values ) {return Numeric.minObj( values );} + /** @see io.deephaven.function.Numeric#minObj(io.deephaven.vector.ObjectVector) */ public static > T minObj( io.deephaven.vector.ObjectVector values ) {return Numeric.minObj( values );} + /** @see io.deephaven.function.Logic#not(java.lang.Boolean[]) */ - public static java.lang.Boolean[] not( java.lang.Boolean[] values ) {return Logic.not( values );} + public static java.lang.Boolean[] not( java.lang.Boolean... values ) {return Logic.not( values );} + /** @see io.deephaven.function.Logic#not(boolean[]) */ - public static java.lang.Boolean[] not( boolean[] values ) {return Logic.not( values );} + public static java.lang.Boolean[] not( boolean... values ) {return Logic.not( values );} + /** @see io.deephaven.function.Basic#nth(long,byte[]) */ - public static byte nth( long index, byte[] values ) {return Basic.nth( index, values );} + public static byte nth( long index, byte... values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nth(long,char[]) */ - public static char nth( long index, char[] values ) {return Basic.nth( index, values );} + public static char nth( long index, char... values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nth(long,double[]) */ - public static double nth( long index, double[] values ) {return Basic.nth( index, values );} + public static double nth( long index, double... values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nth(long,float[]) */ - public static float nth( long index, float[] values ) {return Basic.nth( index, values );} + public static float nth( long index, float... values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nth(long,int[]) */ - public static int nth( long index, int[] values ) {return Basic.nth( index, values );} + public static int nth( long index, int... values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nth(long,long[]) */ - public static long nth( long index, long[] values ) {return Basic.nth( index, values );} + public static long nth( long index, long... values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nth(long,short[]) */ - public static short nth( long index, short[] values ) {return Basic.nth( index, values );} + public static short nth( long index, short... values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nth(long,io.deephaven.vector.ByteVector) */ public static byte nth( long index, io.deephaven.vector.ByteVector values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nth(long,io.deephaven.vector.CharVector) */ public static char nth( long index, io.deephaven.vector.CharVector values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nth(long,io.deephaven.vector.DoubleVector) */ public static double nth( long index, io.deephaven.vector.DoubleVector values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nth(long,io.deephaven.vector.FloatVector) */ public static float nth( long index, io.deephaven.vector.FloatVector values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nth(long,io.deephaven.vector.IntVector) */ public static int nth( long index, io.deephaven.vector.IntVector values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nth(long,io.deephaven.vector.LongVector) */ public static long nth( long index, io.deephaven.vector.LongVector values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nth(long,io.deephaven.vector.ShortVector) */ public static short nth( long index, io.deephaven.vector.ShortVector values ) {return Basic.nth( index, values );} + /** @see io.deephaven.function.Basic#nthObj(long,java.lang.Object[]) */ - public static T nthObj( long index, T[] values ) {return Basic.nthObj( index, values );} + public static T nthObj( long index, T... values ) {return Basic.nthObj( index, values );} + /** @see io.deephaven.function.Basic#nthObj(long,io.deephaven.vector.ObjectVector) */ public static T nthObj( long index, io.deephaven.vector.ObjectVector values ) {return Basic.nthObj( index, values );} + /** @see io.deephaven.function.Basic#nullValueFor(java.lang.Class) */ public static T nullValueFor( java.lang.Class clazz ) {return Basic.nullValueFor( clazz );} + /** @see io.deephaven.function.Logic#or(java.lang.Boolean[]) */ - public static java.lang.Boolean or( java.lang.Boolean[] values ) {return Logic.or( values );} + public static java.lang.Boolean or( java.lang.Boolean... values ) {return Logic.or( values );} + /** @see io.deephaven.function.Logic#or(boolean[]) */ - public static java.lang.Boolean or( boolean[] values ) {return Logic.or( values );} + public static java.lang.Boolean or( boolean... values ) {return Logic.or( values );} + /** @see io.deephaven.function.Logic#or(java.lang.Boolean[],java.lang.Boolean) */ public static java.lang.Boolean or( java.lang.Boolean[] values, java.lang.Boolean nullValue ) {return Logic.or( values, nullValue );} + /** @see io.deephaven.function.Parse#parseBoolean(java.lang.String) */ public static java.lang.Boolean parseBoolean( java.lang.String s ) {return Parse.parseBoolean( s );} + /** @see io.deephaven.function.Parse#parseByte(java.lang.String) */ public static byte parseByte( java.lang.String s ) {return Parse.parseByte( s );} + /** @see io.deephaven.function.Parse#parseByte(java.lang.String,int) */ public static byte parseByte( java.lang.String s, int radix ) {return Parse.parseByte( s, radix );} + /** @see io.deephaven.function.Parse#parseDouble(java.lang.String) */ public static double parseDouble( java.lang.String s ) {return Parse.parseDouble( s );} + /** @see io.deephaven.function.Parse#parseFloat(java.lang.String) */ public static float parseFloat( java.lang.String s ) {return Parse.parseFloat( s );} + /** @see io.deephaven.function.Parse#parseInt(java.lang.String) */ public static int parseInt( java.lang.String s ) {return Parse.parseInt( s );} + /** @see io.deephaven.function.Parse#parseInt(java.lang.String,int) */ public static int parseInt( java.lang.String s, int radix ) {return Parse.parseInt( s, radix );} + /** @see io.deephaven.function.Parse#parseLong(java.lang.String) */ public static long parseLong( java.lang.String s ) {return Parse.parseLong( s );} + /** @see io.deephaven.function.Parse#parseLong(java.lang.String,int) */ public static long parseLong( java.lang.String s, int radix ) {return Parse.parseLong( s, radix );} + /** @see io.deephaven.function.Parse#parseShort(java.lang.String) */ public static short parseShort( java.lang.String s ) {return Parse.parseShort( s );} + /** @see io.deephaven.function.Parse#parseShort(java.lang.String,int) */ public static short parseShort( java.lang.String s, int radix ) {return Parse.parseShort( s, radix );} + /** @see io.deephaven.function.Parse#parseUnsignedInt(java.lang.String) */ public static int parseUnsignedInt( java.lang.String s ) {return Parse.parseUnsignedInt( s );} + /** @see io.deephaven.function.Parse#parseUnsignedInt(java.lang.String,int) */ public static int parseUnsignedInt( java.lang.String s, int radix ) {return Parse.parseUnsignedInt( s, radix );} + /** @see io.deephaven.function.Parse#parseUnsignedLong(java.lang.String) */ public static long parseUnsignedLong( java.lang.String s ) {return Parse.parseUnsignedLong( s );} + /** @see io.deephaven.function.Parse#parseUnsignedLong(java.lang.String,int) */ public static long parseUnsignedLong( java.lang.String s, int radix ) {return Parse.parseUnsignedLong( s, radix );} + /** @see io.deephaven.function.Numeric#percentile(double,byte[]) */ - public static double percentile( double percentile, byte[] values ) {return Numeric.percentile( percentile, values );} + public static double percentile( double percentile, byte... values ) {return Numeric.percentile( percentile, values );} + /** @see io.deephaven.function.Numeric#percentile(double,double[]) */ - public static double percentile( double percentile, double[] values ) {return Numeric.percentile( percentile, values );} + public static double percentile( double percentile, double... values ) {return Numeric.percentile( percentile, values );} + /** @see io.deephaven.function.Numeric#percentile(double,float[]) */ - public static double percentile( double percentile, float[] values ) {return Numeric.percentile( percentile, values );} + public static double percentile( double percentile, float... values ) {return Numeric.percentile( percentile, values );} + /** @see io.deephaven.function.Numeric#percentile(double,int[]) */ - public static double percentile( double percentile, int[] values ) {return Numeric.percentile( percentile, values );} + public static double percentile( double percentile, int... values ) {return Numeric.percentile( percentile, values );} + /** @see io.deephaven.function.Numeric#percentile(double,long[]) */ - public static double percentile( double percentile, long[] values ) {return Numeric.percentile( percentile, values );} + public static double percentile( double percentile, long... values ) {return Numeric.percentile( percentile, values );} + /** @see io.deephaven.function.Numeric#percentile(double,short[]) */ - public static double percentile( double percentile, short[] values ) {return Numeric.percentile( percentile, values );} + public static double percentile( double percentile, short... values ) {return Numeric.percentile( percentile, values );} + /** @see io.deephaven.function.Numeric#percentile(double,io.deephaven.vector.ByteVector) */ public static double percentile( double percentile, io.deephaven.vector.ByteVector values ) {return Numeric.percentile( percentile, values );} + /** @see io.deephaven.function.Numeric#percentile(double,io.deephaven.vector.DoubleVector) */ public static double percentile( double percentile, io.deephaven.vector.DoubleVector values ) {return Numeric.percentile( percentile, values );} + /** @see io.deephaven.function.Numeric#percentile(double,io.deephaven.vector.FloatVector) */ public static double percentile( double percentile, io.deephaven.vector.FloatVector values ) {return Numeric.percentile( percentile, values );} + /** @see io.deephaven.function.Numeric#percentile(double,io.deephaven.vector.IntVector) */ public static double percentile( double percentile, io.deephaven.vector.IntVector values ) {return Numeric.percentile( percentile, values );} + /** @see io.deephaven.function.Numeric#percentile(double,io.deephaven.vector.LongVector) */ public static double percentile( double percentile, io.deephaven.vector.LongVector values ) {return Numeric.percentile( percentile, values );} + /** @see io.deephaven.function.Numeric#percentile(double,io.deephaven.vector.ShortVector) */ public static double percentile( double percentile, io.deephaven.vector.ShortVector values ) {return Numeric.percentile( percentile, values );} + /** @see io.deephaven.function.Numeric#pow(byte,byte) */ public static double pow( byte a, byte b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(byte,double) */ public static double pow( byte a, double b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(byte,float) */ public static double pow( byte a, float b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(byte,int) */ public static double pow( byte a, int b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(byte,long) */ public static double pow( byte a, long b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(byte,short) */ public static double pow( byte a, short b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(double,byte) */ public static double pow( double a, byte b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(double,double) */ public static double pow( double a, double b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(double,float) */ public static double pow( double a, float b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(double,int) */ public static double pow( double a, int b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(double,long) */ public static double pow( double a, long b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(double,short) */ public static double pow( double a, short b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(float,byte) */ public static double pow( float a, byte b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(float,double) */ public static double pow( float a, double b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(float,float) */ public static double pow( float a, float b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(float,int) */ public static double pow( float a, int b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(float,long) */ public static double pow( float a, long b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(float,short) */ public static double pow( float a, short b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(int,byte) */ public static double pow( int a, byte b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(int,double) */ public static double pow( int a, double b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(int,float) */ public static double pow( int a, float b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(int,int) */ public static double pow( int a, int b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(int,long) */ public static double pow( int a, long b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(int,short) */ public static double pow( int a, short b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(long,byte) */ public static double pow( long a, byte b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(long,double) */ public static double pow( long a, double b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(long,float) */ public static double pow( long a, float b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(long,int) */ public static double pow( long a, int b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(long,long) */ public static double pow( long a, long b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(long,short) */ public static double pow( long a, short b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(short,byte) */ public static double pow( short a, byte b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(short,double) */ public static double pow( short a, double b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(short,float) */ public static double pow( short a, float b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(short,int) */ public static double pow( short a, int b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(short,long) */ public static double pow( short a, long b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#pow(short,short) */ public static double pow( short a, short b ) {return Numeric.pow( a, b );} + /** @see io.deephaven.function.Numeric#product(byte[]) */ - public static byte product( byte[] values ) {return Numeric.product( values );} + public static byte product( byte... values ) {return Numeric.product( values );} + /** @see io.deephaven.function.Numeric#product(double[]) */ - public static double product( double[] values ) {return Numeric.product( values );} + public static double product( double... values ) {return Numeric.product( values );} + /** @see io.deephaven.function.Numeric#product(float[]) */ - public static float product( float[] values ) {return Numeric.product( values );} + public static float product( float... values ) {return Numeric.product( values );} + /** @see io.deephaven.function.Numeric#product(int[]) */ - public static int product( int[] values ) {return Numeric.product( values );} + public static int product( int... values ) {return Numeric.product( values );} + /** @see io.deephaven.function.Numeric#product(long[]) */ - public static long product( long[] values ) {return Numeric.product( values );} + public static long product( long... values ) {return Numeric.product( values );} + /** @see io.deephaven.function.Numeric#product(short[]) */ - public static short product( short[] values ) {return Numeric.product( values );} + public static short product( short... values ) {return Numeric.product( values );} + /** @see io.deephaven.function.Numeric#product(io.deephaven.vector.ByteVector) */ public static byte product( io.deephaven.vector.ByteVector values ) {return Numeric.product( values );} + /** @see io.deephaven.function.Numeric#product(io.deephaven.vector.DoubleVector) */ public static double product( io.deephaven.vector.DoubleVector values ) {return Numeric.product( values );} + /** @see io.deephaven.function.Numeric#product(io.deephaven.vector.FloatVector) */ public static float product( io.deephaven.vector.FloatVector values ) {return Numeric.product( values );} + /** @see io.deephaven.function.Numeric#product(io.deephaven.vector.IntVector) */ public static int product( io.deephaven.vector.IntVector values ) {return Numeric.product( values );} + /** @see io.deephaven.function.Numeric#product(io.deephaven.vector.LongVector) */ public static long product( io.deephaven.vector.LongVector values ) {return Numeric.product( values );} + /** @see io.deephaven.function.Numeric#product(io.deephaven.vector.ShortVector) */ public static short product( io.deephaven.vector.ShortVector values ) {return Numeric.product( values );} + /** @see io.deephaven.function.Random#random() */ public static double random( ) {return Random.random( );} + /** @see io.deephaven.function.Random#randomBool() */ public static boolean randomBool( ) {return Random.randomBool( );} + /** @see io.deephaven.function.Random#randomBool(int) */ public static boolean[] randomBool( int size ) {return Random.randomBool( size );} + /** @see io.deephaven.function.Random#randomDouble(double,double) */ public static double randomDouble( double min, double max ) {return Random.randomDouble( min, max );} + /** @see io.deephaven.function.Random#randomDouble(double,double,int) */ public static double[] randomDouble( double min, double max, int size ) {return Random.randomDouble( min, max, size );} + /** @see io.deephaven.function.Random#randomFloat(float,float) */ public static float randomFloat( float min, float max ) {return Random.randomFloat( min, max );} + /** @see io.deephaven.function.Random#randomFloat(float,float,int) */ public static float[] randomFloat( float min, float max, int size ) {return Random.randomFloat( min, max, size );} + /** @see io.deephaven.function.Random#randomGaussian(double,double) */ public static double randomGaussian( double mean, double std ) {return Random.randomGaussian( mean, std );} + /** @see io.deephaven.function.Random#randomGaussian(double,double,int) */ public static double[] randomGaussian( double mean, double std, int size ) {return Random.randomGaussian( mean, std, size );} + /** @see io.deephaven.function.Random#randomInt(int,int) */ public static int randomInt( int min, int max ) {return Random.randomInt( min, max );} + /** @see io.deephaven.function.Random#randomInt(int,int,int) */ public static int[] randomInt( int min, int max, int size ) {return Random.randomInt( min, max, size );} + /** @see io.deephaven.function.Random#randomLong(long,long) */ public static long randomLong( long min, long max ) {return Random.randomLong( min, max );} + /** @see io.deephaven.function.Random#randomLong(long,long,int) */ public static long[] randomLong( long min, long max, int size ) {return Random.randomLong( min, max, size );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(java.lang.Comparable[],java.lang.Comparable,io.deephaven.function.BinSearchAlgo) */ public static > int rawBinSearchIndex( T[] values, T key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(byte[],byte,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( byte[] values, byte key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(char[],char,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( char[] values, char key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(double[],double,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( double[] values, double key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(float[],float,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( float[] values, float key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(int[],int,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( int[] values, int key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(long[],long,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( long[] values, long key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(short[],short,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( short[] values, short key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(io.deephaven.vector.ByteVector,byte,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( io.deephaven.vector.ByteVector values, byte key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(io.deephaven.vector.CharVector,char,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( io.deephaven.vector.CharVector values, char key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(io.deephaven.vector.DoubleVector,double,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( io.deephaven.vector.DoubleVector values, double key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(io.deephaven.vector.FloatVector,float,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( io.deephaven.vector.FloatVector values, float key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(io.deephaven.vector.IntVector,int,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( io.deephaven.vector.IntVector values, int key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(io.deephaven.vector.LongVector,long,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( io.deephaven.vector.LongVector values, long key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(io.deephaven.vector.ShortVector,short,io.deephaven.function.BinSearchAlgo) */ public static int rawBinSearchIndex( io.deephaven.vector.ShortVector values, short key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.BinSearch#rawBinSearchIndex(io.deephaven.vector.ObjectVector,java.lang.Comparable,io.deephaven.function.BinSearchAlgo) */ public static > int rawBinSearchIndex( io.deephaven.vector.ObjectVector values, T key, io.deephaven.function.BinSearchAlgo choiceWhenEquals ) {return BinSearch.rawBinSearchIndex( values, key, choiceWhenEquals );} + /** @see io.deephaven.function.Basic#repeat(java.lang.Object,int) */ public static T[] repeat( T value, int size ) {return Basic.repeat( value, size );} + /** @see io.deephaven.function.Basic#repeat(byte,int) */ public static byte[] repeat( byte value, int size ) {return Basic.repeat( value, size );} + /** @see io.deephaven.function.Basic#repeat(char,int) */ public static char[] repeat( char value, int size ) {return Basic.repeat( value, size );} + /** @see io.deephaven.function.Basic#repeat(double,int) */ public static double[] repeat( double value, int size ) {return Basic.repeat( value, size );} + /** @see io.deephaven.function.Basic#repeat(float,int) */ public static float[] repeat( float value, int size ) {return Basic.repeat( value, size );} + /** @see io.deephaven.function.Basic#repeat(int,int) */ public static int[] repeat( int value, int size ) {return Basic.repeat( value, size );} + /** @see io.deephaven.function.Basic#repeat(long,int) */ public static long[] repeat( long value, int size ) {return Basic.repeat( value, size );} + /** @see io.deephaven.function.Basic#repeat(short,int) */ public static short[] repeat( short value, int size ) {return Basic.repeat( value, size );} + /** @see io.deephaven.function.Numeric#replaceIfNaN(double[],double) */ public static double[] replaceIfNaN( double[] values, double replacement ) {return Numeric.replaceIfNaN( values, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNaN(float[],float) */ public static float[] replaceIfNaN( float[] values, float replacement ) {return Numeric.replaceIfNaN( values, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNaN(double,double) */ public static double replaceIfNaN( double value, double replacement ) {return Numeric.replaceIfNaN( value, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNaN(float,float) */ public static float replaceIfNaN( float value, float replacement ) {return Numeric.replaceIfNaN( value, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNaN(io.deephaven.vector.DoubleVector,double) */ public static double[] replaceIfNaN( io.deephaven.vector.DoubleVector values, double replacement ) {return Numeric.replaceIfNaN( values, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNaN(io.deephaven.vector.FloatVector,float) */ public static float[] replaceIfNaN( io.deephaven.vector.FloatVector values, float replacement ) {return Numeric.replaceIfNaN( values, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNonFinite(double[],double) */ public static double[] replaceIfNonFinite( double[] values, double replacement ) {return Numeric.replaceIfNonFinite( values, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNonFinite(float[],float) */ public static float[] replaceIfNonFinite( float[] values, float replacement ) {return Numeric.replaceIfNonFinite( values, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNonFinite(double,double) */ public static double replaceIfNonFinite( double value, double replacement ) {return Numeric.replaceIfNonFinite( value, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNonFinite(float,float) */ public static float replaceIfNonFinite( float value, float replacement ) {return Numeric.replaceIfNonFinite( value, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNonFinite(io.deephaven.vector.DoubleVector,double) */ public static double[] replaceIfNonFinite( io.deephaven.vector.DoubleVector values, double replacement ) {return Numeric.replaceIfNonFinite( values, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNonFinite(io.deephaven.vector.FloatVector,float) */ public static float[] replaceIfNonFinite( io.deephaven.vector.FloatVector values, float replacement ) {return Numeric.replaceIfNonFinite( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(java.lang.Object,java.lang.Object) */ public static T replaceIfNull( T value, T replacement ) {return Basic.replaceIfNull( value, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(java.lang.Object[],java.lang.Object) */ public static T[] replaceIfNull( T[] values, T replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(byte,byte) */ public static byte replaceIfNull( byte value, byte replacement ) {return Basic.replaceIfNull( value, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(char,char) */ public static char replaceIfNull( char value, char replacement ) {return Basic.replaceIfNull( value, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(byte[],byte) */ public static byte[] replaceIfNull( byte[] values, byte replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(char[],char) */ public static char[] replaceIfNull( char[] values, char replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(double[],double) */ public static double[] replaceIfNull( double[] values, double replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(float[],float) */ public static float[] replaceIfNull( float[] values, float replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(int[],int) */ public static int[] replaceIfNull( int[] values, int replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(long[],long) */ public static long[] replaceIfNull( long[] values, long replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(short[],short) */ public static short[] replaceIfNull( short[] values, short replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(double,double) */ public static double replaceIfNull( double value, double replacement ) {return Basic.replaceIfNull( value, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(float,float) */ public static float replaceIfNull( float value, float replacement ) {return Basic.replaceIfNull( value, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(int,int) */ public static int replaceIfNull( int value, int replacement ) {return Basic.replaceIfNull( value, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(io.deephaven.vector.ByteVector,byte) */ public static byte[] replaceIfNull( io.deephaven.vector.ByteVector values, byte replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(io.deephaven.vector.CharVector,char) */ public static char[] replaceIfNull( io.deephaven.vector.CharVector values, char replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(io.deephaven.vector.DoubleVector,double) */ public static double[] replaceIfNull( io.deephaven.vector.DoubleVector values, double replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(io.deephaven.vector.FloatVector,float) */ public static float[] replaceIfNull( io.deephaven.vector.FloatVector values, float replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(io.deephaven.vector.IntVector,int) */ public static int[] replaceIfNull( io.deephaven.vector.IntVector values, int replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(io.deephaven.vector.LongVector,long) */ public static long[] replaceIfNull( io.deephaven.vector.LongVector values, long replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(io.deephaven.vector.ShortVector,short) */ public static short[] replaceIfNull( io.deephaven.vector.ShortVector values, short replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(io.deephaven.vector.ObjectVector,java.lang.Object) */ public static T[] replaceIfNull( io.deephaven.vector.ObjectVector values, T replacement ) {return Basic.replaceIfNull( values, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(long,long) */ public static long replaceIfNull( long value, long replacement ) {return Basic.replaceIfNull( value, replacement );} + /** @see io.deephaven.function.Basic#replaceIfNull(short,short) */ public static short replaceIfNull( short value, short replacement ) {return Basic.replaceIfNull( value, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNullNaN(double[],double) */ public static double[] replaceIfNullNaN( double[] values, double replacement ) {return Numeric.replaceIfNullNaN( values, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNullNaN(float[],float) */ public static float[] replaceIfNullNaN( float[] values, float replacement ) {return Numeric.replaceIfNullNaN( values, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNullNaN(double,double) */ public static double replaceIfNullNaN( double value, double replacement ) {return Numeric.replaceIfNullNaN( value, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNullNaN(float,float) */ public static float replaceIfNullNaN( float value, float replacement ) {return Numeric.replaceIfNullNaN( value, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNullNaN(io.deephaven.vector.DoubleVector,double) */ public static double[] replaceIfNullNaN( io.deephaven.vector.DoubleVector values, double replacement ) {return Numeric.replaceIfNullNaN( values, replacement );} + /** @see io.deephaven.function.Numeric#replaceIfNullNaN(io.deephaven.vector.FloatVector,float) */ public static float[] replaceIfNullNaN( io.deephaven.vector.FloatVector values, float replacement ) {return Numeric.replaceIfNullNaN( values, replacement );} + /** @see io.deephaven.function.Basic#reverse(byte[]) */ - public static byte[] reverse( byte[] values ) {return Basic.reverse( values );} + public static byte[] reverse( byte... values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverse(char[]) */ - public static char[] reverse( char[] values ) {return Basic.reverse( values );} + public static char[] reverse( char... values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverse(double[]) */ - public static double[] reverse( double[] values ) {return Basic.reverse( values );} + public static double[] reverse( double... values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverse(float[]) */ - public static float[] reverse( float[] values ) {return Basic.reverse( values );} + public static float[] reverse( float... values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverse(int[]) */ - public static int[] reverse( int[] values ) {return Basic.reverse( values );} + public static int[] reverse( int... values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverse(long[]) */ - public static long[] reverse( long[] values ) {return Basic.reverse( values );} + public static long[] reverse( long... values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverse(short[]) */ - public static short[] reverse( short[] values ) {return Basic.reverse( values );} + public static short[] reverse( short... values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverse(io.deephaven.vector.ByteVector) */ public static byte[] reverse( io.deephaven.vector.ByteVector values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverse(io.deephaven.vector.CharVector) */ public static char[] reverse( io.deephaven.vector.CharVector values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverse(io.deephaven.vector.DoubleVector) */ public static double[] reverse( io.deephaven.vector.DoubleVector values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverse(io.deephaven.vector.FloatVector) */ public static float[] reverse( io.deephaven.vector.FloatVector values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverse(io.deephaven.vector.IntVector) */ public static int[] reverse( io.deephaven.vector.IntVector values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverse(io.deephaven.vector.LongVector) */ public static long[] reverse( io.deephaven.vector.LongVector values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverse(io.deephaven.vector.ShortVector) */ public static short[] reverse( io.deephaven.vector.ShortVector values ) {return Basic.reverse( values );} + /** @see io.deephaven.function.Basic#reverseObj(java.lang.Object[]) */ - public static T[] reverseObj( T[] values ) {return Basic.reverseObj( values );} + public static T[] reverseObj( T... values ) {return Basic.reverseObj( values );} + /** @see io.deephaven.function.Basic#reverseObj(io.deephaven.vector.ObjectVector) */ public static T[] reverseObj( io.deephaven.vector.ObjectVector values ) {return Basic.reverseObj( values );} + /** @see io.deephaven.function.Numeric#rint(byte) */ public static double rint( byte value ) {return Numeric.rint( value );} + /** @see io.deephaven.function.Numeric#rint(double) */ public static double rint( double value ) {return Numeric.rint( value );} + /** @see io.deephaven.function.Numeric#rint(float) */ public static double rint( float value ) {return Numeric.rint( value );} + /** @see io.deephaven.function.Numeric#rint(int) */ public static double rint( int value ) {return Numeric.rint( value );} + /** @see io.deephaven.function.Numeric#rint(long) */ public static double rint( long value ) {return Numeric.rint( value );} + /** @see io.deephaven.function.Numeric#rint(short) */ public static double rint( short value ) {return Numeric.rint( value );} + /** @see io.deephaven.function.Numeric#round(byte) */ public static long round( byte value ) {return Numeric.round( value );} + /** @see io.deephaven.function.Numeric#round(double) */ public static long round( double value ) {return Numeric.round( value );} + /** @see io.deephaven.function.Numeric#round(float) */ public static long round( float value ) {return Numeric.round( value );} + /** @see io.deephaven.function.Numeric#round(int) */ public static long round( int value ) {return Numeric.round( value );} + /** @see io.deephaven.function.Numeric#round(long) */ public static long round( long value ) {return Numeric.round( value );} + /** @see io.deephaven.function.Numeric#round(short) */ public static long round( short value ) {return Numeric.round( value );} + /** @see io.deephaven.function.Numeric#sequence(byte,byte,byte) */ public static byte[] sequence( byte start, byte end, byte step ) {return Numeric.sequence( start, end, step );} + /** @see io.deephaven.function.Numeric#sequence(double,double,double) */ public static double[] sequence( double start, double end, double step ) {return Numeric.sequence( start, end, step );} + /** @see io.deephaven.function.Numeric#sequence(float,float,float) */ public static float[] sequence( float start, float end, float step ) {return Numeric.sequence( start, end, step );} + /** @see io.deephaven.function.Numeric#sequence(int,int,int) */ public static int[] sequence( int start, int end, int step ) {return Numeric.sequence( start, end, step );} + /** @see io.deephaven.function.Numeric#sequence(long,long,long) */ public static long[] sequence( long start, long end, long step ) {return Numeric.sequence( start, end, step );} + /** @see io.deephaven.function.Numeric#sequence(short,short,short) */ public static short[] sequence( short start, short end, short step ) {return Numeric.sequence( start, end, step );} + /** @see io.deephaven.function.Numeric#signum(byte) */ public static int signum( byte value ) {return Numeric.signum( value );} + /** @see io.deephaven.function.Numeric#signum(double) */ public static int signum( double value ) {return Numeric.signum( value );} + /** @see io.deephaven.function.Numeric#signum(float) */ public static int signum( float value ) {return Numeric.signum( value );} + /** @see io.deephaven.function.Numeric#signum(int) */ public static int signum( int value ) {return Numeric.signum( value );} + /** @see io.deephaven.function.Numeric#signum(long) */ public static int signum( long value ) {return Numeric.signum( value );} + /** @see io.deephaven.function.Numeric#signum(short) */ public static int signum( short value ) {return Numeric.signum( value );} + /** @see io.deephaven.function.Numeric#sin(byte) */ public static double sin( byte value ) {return Numeric.sin( value );} + /** @see io.deephaven.function.Numeric#sin(double) */ public static double sin( double value ) {return Numeric.sin( value );} + /** @see io.deephaven.function.Numeric#sin(float) */ public static double sin( float value ) {return Numeric.sin( value );} + /** @see io.deephaven.function.Numeric#sin(int) */ public static double sin( int value ) {return Numeric.sin( value );} + /** @see io.deephaven.function.Numeric#sin(long) */ public static double sin( long value ) {return Numeric.sin( value );} + /** @see io.deephaven.function.Numeric#sin(short) */ public static double sin( short value ) {return Numeric.sin( value );} + /** @see io.deephaven.function.Sort#sort(byte[]) */ - public static byte[] sort( byte[] values ) {return Sort.sort( values );} + public static byte[] sort( byte... values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(double[]) */ - public static double[] sort( double[] values ) {return Sort.sort( values );} + public static double[] sort( double... values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(float[]) */ - public static float[] sort( float[] values ) {return Sort.sort( values );} + public static float[] sort( float... values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(int[]) */ - public static int[] sort( int[] values ) {return Sort.sort( values );} + public static int[] sort( int... values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(long[]) */ - public static long[] sort( long[] values ) {return Sort.sort( values );} + public static long[] sort( long... values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(java.lang.Byte[]) */ public static byte[] sort( java.lang.Byte[] values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(java.lang.Double[]) */ public static double[] sort( java.lang.Double[] values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(java.lang.Float[]) */ public static float[] sort( java.lang.Float[] values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(java.lang.Integer[]) */ public static int[] sort( java.lang.Integer[] values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(java.lang.Long[]) */ public static long[] sort( java.lang.Long[] values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(java.lang.Short[]) */ public static short[] sort( java.lang.Short[] values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(short[]) */ - public static short[] sort( short[] values ) {return Sort.sort( values );} + public static short[] sort( short... values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(io.deephaven.vector.ByteVector) */ public static byte[] sort( io.deephaven.vector.ByteVector values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(io.deephaven.vector.DoubleVector) */ public static double[] sort( io.deephaven.vector.DoubleVector values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(io.deephaven.vector.FloatVector) */ public static float[] sort( io.deephaven.vector.FloatVector values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(io.deephaven.vector.IntVector) */ public static int[] sort( io.deephaven.vector.IntVector values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(io.deephaven.vector.LongVector) */ public static long[] sort( io.deephaven.vector.LongVector values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sort(io.deephaven.vector.ShortVector) */ public static short[] sort( io.deephaven.vector.ShortVector values ) {return Sort.sort( values );} + /** @see io.deephaven.function.Sort#sortDescending(byte[]) */ - public static byte[] sortDescending( byte[] values ) {return Sort.sortDescending( values );} + public static byte[] sortDescending( byte... values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(double[]) */ - public static double[] sortDescending( double[] values ) {return Sort.sortDescending( values );} + public static double[] sortDescending( double... values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(float[]) */ - public static float[] sortDescending( float[] values ) {return Sort.sortDescending( values );} + public static float[] sortDescending( float... values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(int[]) */ - public static int[] sortDescending( int[] values ) {return Sort.sortDescending( values );} + public static int[] sortDescending( int... values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(long[]) */ - public static long[] sortDescending( long[] values ) {return Sort.sortDescending( values );} + public static long[] sortDescending( long... values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(java.lang.Byte[]) */ public static byte[] sortDescending( java.lang.Byte[] values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(java.lang.Double[]) */ public static double[] sortDescending( java.lang.Double[] values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(java.lang.Float[]) */ public static float[] sortDescending( java.lang.Float[] values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(java.lang.Integer[]) */ public static int[] sortDescending( java.lang.Integer[] values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(java.lang.Long[]) */ public static long[] sortDescending( java.lang.Long[] values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(java.lang.Short[]) */ public static short[] sortDescending( java.lang.Short[] values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(short[]) */ - public static short[] sortDescending( short[] values ) {return Sort.sortDescending( values );} + public static short[] sortDescending( short... values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(io.deephaven.vector.ByteVector) */ public static byte[] sortDescending( io.deephaven.vector.ByteVector values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(io.deephaven.vector.DoubleVector) */ public static double[] sortDescending( io.deephaven.vector.DoubleVector values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(io.deephaven.vector.FloatVector) */ public static float[] sortDescending( io.deephaven.vector.FloatVector values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(io.deephaven.vector.IntVector) */ public static int[] sortDescending( io.deephaven.vector.IntVector values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(io.deephaven.vector.LongVector) */ public static long[] sortDescending( io.deephaven.vector.LongVector values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescending(io.deephaven.vector.ShortVector) */ public static short[] sortDescending( io.deephaven.vector.ShortVector values ) {return Sort.sortDescending( values );} + /** @see io.deephaven.function.Sort#sortDescendingObj(java.lang.Comparable[]) */ - public static > T[] sortDescendingObj( T[] values ) {return Sort.sortDescendingObj( values );} + public static > T[] sortDescendingObj( T... values ) {return Sort.sortDescendingObj( values );} + /** @see io.deephaven.function.Sort#sortDescendingObj(io.deephaven.vector.ObjectVector) */ public static > T[] sortDescendingObj( io.deephaven.vector.ObjectVector values ) {return Sort.sortDescendingObj( values );} + /** @see io.deephaven.function.Sort#sortDescendingObj(java.lang.Comparable[],java.util.Comparator) */ public static > T[] sortDescendingObj( T[] values, java.util.Comparator comparator ) {return Sort.sortDescendingObj( values, comparator );} + /** @see io.deephaven.function.Sort#sortDescendingObj(io.deephaven.vector.ObjectVector,java.util.Comparator) */ public static > T[] sortDescendingObj( io.deephaven.vector.ObjectVector values, java.util.Comparator comparator ) {return Sort.sortDescendingObj( values, comparator );} + /** @see io.deephaven.function.Sort#sortObj(java.lang.Comparable[]) */ - public static > T[] sortObj( T[] values ) {return Sort.sortObj( values );} + public static > T[] sortObj( T... values ) {return Sort.sortObj( values );} + /** @see io.deephaven.function.Sort#sortObj(io.deephaven.vector.ObjectVector) */ public static > T[] sortObj( io.deephaven.vector.ObjectVector values ) {return Sort.sortObj( values );} + /** @see io.deephaven.function.Sort#sortObj(java.lang.Comparable[],java.util.Comparator) */ public static > T[] sortObj( T[] values, java.util.Comparator comparator ) {return Sort.sortObj( values, comparator );} + /** @see io.deephaven.function.Sort#sortObj(io.deephaven.vector.ObjectVector,java.util.Comparator) */ public static > T[] sortObj( io.deephaven.vector.ObjectVector values, java.util.Comparator comparator ) {return Sort.sortObj( values, comparator );} + /** @see io.deephaven.function.Numeric#sqrt(byte) */ public static double sqrt( byte value ) {return Numeric.sqrt( value );} + /** @see io.deephaven.function.Numeric#sqrt(double) */ public static double sqrt( double value ) {return Numeric.sqrt( value );} + /** @see io.deephaven.function.Numeric#sqrt(float) */ public static double sqrt( float value ) {return Numeric.sqrt( value );} + /** @see io.deephaven.function.Numeric#sqrt(int) */ public static double sqrt( int value ) {return Numeric.sqrt( value );} + /** @see io.deephaven.function.Numeric#sqrt(long) */ public static double sqrt( long value ) {return Numeric.sqrt( value );} + /** @see io.deephaven.function.Numeric#sqrt(short) */ public static double sqrt( short value ) {return Numeric.sqrt( value );} + /** @see io.deephaven.function.Numeric#std(byte[]) */ - public static double std( byte[] values ) {return Numeric.std( values );} + public static double std( byte... values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(double[]) */ - public static double std( double[] values ) {return Numeric.std( values );} + public static double std( double... values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(float[]) */ - public static double std( float[] values ) {return Numeric.std( values );} + public static double std( float... values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(int[]) */ - public static double std( int[] values ) {return Numeric.std( values );} + public static double std( int... values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(long[]) */ - public static double std( long[] values ) {return Numeric.std( values );} + public static double std( long... values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(java.lang.Byte[]) */ public static double std( java.lang.Byte[] values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(java.lang.Double[]) */ public static double std( java.lang.Double[] values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(java.lang.Float[]) */ public static double std( java.lang.Float[] values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(java.lang.Integer[]) */ public static double std( java.lang.Integer[] values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(java.lang.Long[]) */ public static double std( java.lang.Long[] values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(java.lang.Short[]) */ public static double std( java.lang.Short[] values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(short[]) */ - public static double std( short[] values ) {return Numeric.std( values );} + public static double std( short... values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(io.deephaven.vector.ByteVector) */ public static double std( io.deephaven.vector.ByteVector values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(io.deephaven.vector.DoubleVector) */ public static double std( io.deephaven.vector.DoubleVector values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(io.deephaven.vector.FloatVector) */ public static double std( io.deephaven.vector.FloatVector values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(io.deephaven.vector.IntVector) */ public static double std( io.deephaven.vector.IntVector values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(io.deephaven.vector.LongVector) */ public static double std( io.deephaven.vector.LongVector values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#std(io.deephaven.vector.ShortVector) */ public static double std( io.deephaven.vector.ShortVector values ) {return Numeric.std( values );} + /** @see io.deephaven.function.Numeric#ste(byte[]) */ - public static double ste( byte[] values ) {return Numeric.ste( values );} + public static double ste( byte... values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(double[]) */ - public static double ste( double[] values ) {return Numeric.ste( values );} + public static double ste( double... values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(float[]) */ - public static double ste( float[] values ) {return Numeric.ste( values );} + public static double ste( float... values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(int[]) */ - public static double ste( int[] values ) {return Numeric.ste( values );} + public static double ste( int... values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(long[]) */ - public static double ste( long[] values ) {return Numeric.ste( values );} + public static double ste( long... values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(java.lang.Byte[]) */ public static double ste( java.lang.Byte[] values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(java.lang.Double[]) */ public static double ste( java.lang.Double[] values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(java.lang.Float[]) */ public static double ste( java.lang.Float[] values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(java.lang.Integer[]) */ public static double ste( java.lang.Integer[] values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(java.lang.Long[]) */ public static double ste( java.lang.Long[] values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(java.lang.Short[]) */ public static double ste( java.lang.Short[] values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(short[]) */ - public static double ste( short[] values ) {return Numeric.ste( values );} + public static double ste( short... values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(io.deephaven.vector.ByteVector) */ public static double ste( io.deephaven.vector.ByteVector values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(io.deephaven.vector.DoubleVector) */ public static double ste( io.deephaven.vector.DoubleVector values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(io.deephaven.vector.FloatVector) */ public static double ste( io.deephaven.vector.FloatVector values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(io.deephaven.vector.IntVector) */ public static double ste( io.deephaven.vector.IntVector values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(io.deephaven.vector.LongVector) */ public static double ste( io.deephaven.vector.LongVector values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#ste(io.deephaven.vector.ShortVector) */ public static double ste( io.deephaven.vector.ShortVector values ) {return Numeric.ste( values );} + /** @see io.deephaven.function.Numeric#sum(byte[]) */ - public static byte sum( byte[] values ) {return Numeric.sum( values );} + public static byte sum( byte... values ) {return Numeric.sum( values );} + /** @see io.deephaven.function.Numeric#sum(double[]) */ - public static double sum( double[] values ) {return Numeric.sum( values );} + public static double sum( double... values ) {return Numeric.sum( values );} + /** @see io.deephaven.function.Numeric#sum(float[]) */ - public static float sum( float[] values ) {return Numeric.sum( values );} + public static float sum( float... values ) {return Numeric.sum( values );} + /** @see io.deephaven.function.Numeric#sum(int[]) */ - public static int sum( int[] values ) {return Numeric.sum( values );} + public static int sum( int... values ) {return Numeric.sum( values );} + /** @see io.deephaven.function.Numeric#sum(long[]) */ - public static long sum( long[] values ) {return Numeric.sum( values );} + public static long sum( long... values ) {return Numeric.sum( values );} + /** @see io.deephaven.function.Numeric#sum(short[]) */ - public static short sum( short[] values ) {return Numeric.sum( values );} + public static short sum( short... values ) {return Numeric.sum( values );} + /** @see io.deephaven.function.Numeric#sum(io.deephaven.vector.ByteVector) */ public static byte sum( io.deephaven.vector.ByteVector values ) {return Numeric.sum( values );} + /** @see io.deephaven.function.Numeric#sum(io.deephaven.vector.DoubleVector) */ public static double sum( io.deephaven.vector.DoubleVector values ) {return Numeric.sum( values );} + /** @see io.deephaven.function.Numeric#sum(io.deephaven.vector.FloatVector) */ public static float sum( io.deephaven.vector.FloatVector values ) {return Numeric.sum( values );} + /** @see io.deephaven.function.Numeric#sum(io.deephaven.vector.IntVector) */ public static int sum( io.deephaven.vector.IntVector values ) {return Numeric.sum( values );} + /** @see io.deephaven.function.Numeric#sum(io.deephaven.vector.LongVector) */ public static long sum( io.deephaven.vector.LongVector values ) {return Numeric.sum( values );} + /** @see io.deephaven.function.Numeric#sum(io.deephaven.vector.ShortVector) */ public static short sum( io.deephaven.vector.ShortVector values ) {return Numeric.sum( values );} + /** @see io.deephaven.function.Numeric#tan(byte) */ public static double tan( byte value ) {return Numeric.tan( value );} + /** @see io.deephaven.function.Numeric#tan(double) */ public static double tan( double value ) {return Numeric.tan( value );} + /** @see io.deephaven.function.Numeric#tan(float) */ public static double tan( float value ) {return Numeric.tan( value );} + /** @see io.deephaven.function.Numeric#tan(int) */ public static double tan( int value ) {return Numeric.tan( value );} + /** @see io.deephaven.function.Numeric#tan(long) */ public static double tan( long value ) {return Numeric.tan( value );} + /** @see io.deephaven.function.Numeric#tan(short) */ public static double tan( short value ) {return Numeric.tan( value );} + /** @see io.deephaven.function.Numeric#tstat(byte[]) */ - public static double tstat( byte[] values ) {return Numeric.tstat( values );} + public static double tstat( byte... values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(double[]) */ - public static double tstat( double[] values ) {return Numeric.tstat( values );} + public static double tstat( double... values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(float[]) */ - public static double tstat( float[] values ) {return Numeric.tstat( values );} + public static double tstat( float... values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(int[]) */ - public static double tstat( int[] values ) {return Numeric.tstat( values );} + public static double tstat( int... values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(long[]) */ - public static double tstat( long[] values ) {return Numeric.tstat( values );} + public static double tstat( long... values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(java.lang.Byte[]) */ public static double tstat( java.lang.Byte[] values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(java.lang.Double[]) */ public static double tstat( java.lang.Double[] values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(java.lang.Float[]) */ public static double tstat( java.lang.Float[] values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(java.lang.Integer[]) */ public static double tstat( java.lang.Integer[] values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(java.lang.Long[]) */ public static double tstat( java.lang.Long[] values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(java.lang.Short[]) */ public static double tstat( java.lang.Short[] values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(short[]) */ - public static double tstat( short[] values ) {return Numeric.tstat( values );} + public static double tstat( short... values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(io.deephaven.vector.ByteVector) */ public static double tstat( io.deephaven.vector.ByteVector values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(io.deephaven.vector.DoubleVector) */ public static double tstat( io.deephaven.vector.DoubleVector values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(io.deephaven.vector.FloatVector) */ public static double tstat( io.deephaven.vector.FloatVector values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(io.deephaven.vector.IntVector) */ public static double tstat( io.deephaven.vector.IntVector values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(io.deephaven.vector.LongVector) */ public static double tstat( io.deephaven.vector.LongVector values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Numeric#tstat(io.deephaven.vector.ShortVector) */ public static double tstat( io.deephaven.vector.ShortVector values ) {return Numeric.tstat( values );} + /** @see io.deephaven.function.Basic#unbox(java.lang.Byte[]) */ - public static byte[] unbox( java.lang.Byte[] values ) {return Basic.unbox( values );} + public static byte[] unbox( java.lang.Byte... values ) {return Basic.unbox( values );} + /** @see io.deephaven.function.Basic#unbox(java.lang.Character[]) */ - public static char[] unbox( java.lang.Character[] values ) {return Basic.unbox( values );} + public static char[] unbox( java.lang.Character... values ) {return Basic.unbox( values );} + /** @see io.deephaven.function.Basic#unbox(java.lang.Double[]) */ - public static double[] unbox( java.lang.Double[] values ) {return Basic.unbox( values );} + public static double[] unbox( java.lang.Double... values ) {return Basic.unbox( values );} + /** @see io.deephaven.function.Basic#unbox(java.lang.Float[]) */ - public static float[] unbox( java.lang.Float[] values ) {return Basic.unbox( values );} + public static float[] unbox( java.lang.Float... values ) {return Basic.unbox( values );} + /** @see io.deephaven.function.Basic#unbox(java.lang.Integer[]) */ - public static int[] unbox( java.lang.Integer[] values ) {return Basic.unbox( values );} + public static int[] unbox( java.lang.Integer... values ) {return Basic.unbox( values );} + /** @see io.deephaven.function.Basic#unbox(java.lang.Long[]) */ - public static long[] unbox( java.lang.Long[] values ) {return Basic.unbox( values );} + public static long[] unbox( java.lang.Long... values ) {return Basic.unbox( values );} + /** @see io.deephaven.function.Basic#unbox(java.lang.Short[]) */ - public static short[] unbox( java.lang.Short[] values ) {return Basic.unbox( values );} + public static short[] unbox( java.lang.Short... values ) {return Basic.unbox( values );} + /** @see io.deephaven.function.Numeric#upperBin(byte,byte) */ public static byte upperBin( byte value, byte interval ) {return Numeric.upperBin( value, interval );} + /** @see io.deephaven.function.Numeric#upperBin(double,double) */ public static double upperBin( double value, double interval ) {return Numeric.upperBin( value, interval );} + /** @see io.deephaven.function.Numeric#upperBin(float,float) */ public static float upperBin( float value, float interval ) {return Numeric.upperBin( value, interval );} + /** @see io.deephaven.function.Numeric#upperBin(int,int) */ public static int upperBin( int value, int interval ) {return Numeric.upperBin( value, interval );} + /** @see io.deephaven.function.Numeric#upperBin(long,long) */ public static long upperBin( long value, long interval ) {return Numeric.upperBin( value, interval );} + /** @see io.deephaven.function.Numeric#upperBin(short,short) */ public static short upperBin( short value, short interval ) {return Numeric.upperBin( value, interval );} + /** @see io.deephaven.function.Numeric#upperBin(byte,byte,byte) */ public static byte upperBin( byte value, byte interval, byte offset ) {return Numeric.upperBin( value, interval, offset );} + /** @see io.deephaven.function.Numeric#upperBin(double,double,double) */ public static double upperBin( double value, double interval, double offset ) {return Numeric.upperBin( value, interval, offset );} + /** @see io.deephaven.function.Numeric#upperBin(float,float,float) */ public static float upperBin( float value, float interval, float offset ) {return Numeric.upperBin( value, interval, offset );} + /** @see io.deephaven.function.Numeric#upperBin(int,int,int) */ public static int upperBin( int value, int interval, int offset ) {return Numeric.upperBin( value, interval, offset );} + /** @see io.deephaven.function.Numeric#upperBin(long,long,long) */ public static long upperBin( long value, long interval, long offset ) {return Numeric.upperBin( value, interval, offset );} + /** @see io.deephaven.function.Numeric#upperBin(short,short,short) */ public static short upperBin( short value, short interval, short offset ) {return Numeric.upperBin( value, interval, offset );} + /** @see io.deephaven.function.Numeric#var(byte[]) */ - public static double var( byte[] values ) {return Numeric.var( values );} + public static double var( byte... values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(double[]) */ - public static double var( double[] values ) {return Numeric.var( values );} + public static double var( double... values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(float[]) */ - public static double var( float[] values ) {return Numeric.var( values );} + public static double var( float... values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(int[]) */ - public static double var( int[] values ) {return Numeric.var( values );} + public static double var( int... values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(long[]) */ - public static double var( long[] values ) {return Numeric.var( values );} + public static double var( long... values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(java.lang.Byte[]) */ public static double var( java.lang.Byte[] values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(java.lang.Double[]) */ public static double var( java.lang.Double[] values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(java.lang.Float[]) */ public static double var( java.lang.Float[] values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(java.lang.Integer[]) */ public static double var( java.lang.Integer[] values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(java.lang.Long[]) */ public static double var( java.lang.Long[] values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(java.lang.Short[]) */ public static double var( java.lang.Short[] values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(short[]) */ - public static double var( short[] values ) {return Numeric.var( values );} + public static double var( short... values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(io.deephaven.vector.ByteVector) */ public static double var( io.deephaven.vector.ByteVector values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(io.deephaven.vector.DoubleVector) */ public static double var( io.deephaven.vector.DoubleVector values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(io.deephaven.vector.FloatVector) */ public static double var( io.deephaven.vector.FloatVector values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(io.deephaven.vector.IntVector) */ public static double var( io.deephaven.vector.IntVector values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(io.deephaven.vector.LongVector) */ public static double var( io.deephaven.vector.LongVector values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Numeric#var(io.deephaven.vector.ShortVector) */ public static double var( io.deephaven.vector.ShortVector values ) {return Numeric.var( values );} + /** @see io.deephaven.function.Basic#vec(byte[]) */ - public static io.deephaven.vector.ByteVector vec( byte[] values ) {return Basic.vec( values );} + public static io.deephaven.vector.ByteVector vec( byte... values ) {return Basic.vec( values );} + /** @see io.deephaven.function.Basic#vec(char[]) */ - public static io.deephaven.vector.CharVector vec( char[] values ) {return Basic.vec( values );} + public static io.deephaven.vector.CharVector vec( char... values ) {return Basic.vec( values );} + /** @see io.deephaven.function.Basic#vec(double[]) */ - public static io.deephaven.vector.DoubleVector vec( double[] values ) {return Basic.vec( values );} + public static io.deephaven.vector.DoubleVector vec( double... values ) {return Basic.vec( values );} + /** @see io.deephaven.function.Basic#vec(float[]) */ - public static io.deephaven.vector.FloatVector vec( float[] values ) {return Basic.vec( values );} + public static io.deephaven.vector.FloatVector vec( float... values ) {return Basic.vec( values );} + /** @see io.deephaven.function.Basic#vec(int[]) */ - public static io.deephaven.vector.IntVector vec( int[] values ) {return Basic.vec( values );} + public static io.deephaven.vector.IntVector vec( int... values ) {return Basic.vec( values );} + /** @see io.deephaven.function.Basic#vec(long[]) */ - public static io.deephaven.vector.LongVector vec( long[] values ) {return Basic.vec( values );} + public static io.deephaven.vector.LongVector vec( long... values ) {return Basic.vec( values );} + /** @see io.deephaven.function.Basic#vec(short[]) */ - public static io.deephaven.vector.ShortVector vec( short[] values ) {return Basic.vec( values );} + public static io.deephaven.vector.ShortVector vec( short... values ) {return Basic.vec( values );} + /** @see io.deephaven.function.Basic#vecObj(java.lang.Object[]) */ - public static io.deephaven.vector.ObjectVector vecObj( T[] values ) {return Basic.vecObj( values );} + public static io.deephaven.vector.ObjectVector vecObj( T... values ) {return Basic.vecObj( values );} + /** @see io.deephaven.function.Numeric#wavg(byte[],byte[]) */ public static double wavg( byte[] values, byte[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(byte[],double[]) */ public static double wavg( byte[] values, double[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(byte[],float[]) */ public static double wavg( byte[] values, float[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(byte[],int[]) */ public static double wavg( byte[] values, int[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(byte[],long[]) */ public static double wavg( byte[] values, long[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(byte[],short[]) */ public static double wavg( byte[] values, short[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(byte[],io.deephaven.vector.ByteVector) */ public static double wavg( byte[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(byte[],io.deephaven.vector.DoubleVector) */ public static double wavg( byte[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(byte[],io.deephaven.vector.FloatVector) */ public static double wavg( byte[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(byte[],io.deephaven.vector.IntVector) */ public static double wavg( byte[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(byte[],io.deephaven.vector.LongVector) */ public static double wavg( byte[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(byte[],io.deephaven.vector.ShortVector) */ public static double wavg( byte[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(double[],byte[]) */ public static double wavg( double[] values, byte[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(double[],double[]) */ public static double wavg( double[] values, double[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(double[],float[]) */ public static double wavg( double[] values, float[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(double[],int[]) */ public static double wavg( double[] values, int[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(double[],long[]) */ public static double wavg( double[] values, long[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(double[],short[]) */ public static double wavg( double[] values, short[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(double[],io.deephaven.vector.ByteVector) */ public static double wavg( double[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(double[],io.deephaven.vector.DoubleVector) */ public static double wavg( double[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(double[],io.deephaven.vector.FloatVector) */ public static double wavg( double[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(double[],io.deephaven.vector.IntVector) */ public static double wavg( double[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(double[],io.deephaven.vector.LongVector) */ public static double wavg( double[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(double[],io.deephaven.vector.ShortVector) */ public static double wavg( double[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(float[],byte[]) */ public static double wavg( float[] values, byte[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(float[],double[]) */ public static double wavg( float[] values, double[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(float[],float[]) */ public static double wavg( float[] values, float[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(float[],int[]) */ public static double wavg( float[] values, int[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(float[],long[]) */ public static double wavg( float[] values, long[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(float[],short[]) */ public static double wavg( float[] values, short[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(float[],io.deephaven.vector.ByteVector) */ public static double wavg( float[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(float[],io.deephaven.vector.DoubleVector) */ public static double wavg( float[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(float[],io.deephaven.vector.FloatVector) */ public static double wavg( float[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(float[],io.deephaven.vector.IntVector) */ public static double wavg( float[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(float[],io.deephaven.vector.LongVector) */ public static double wavg( float[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(float[],io.deephaven.vector.ShortVector) */ public static double wavg( float[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(int[],byte[]) */ public static double wavg( int[] values, byte[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(int[],double[]) */ public static double wavg( int[] values, double[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(int[],float[]) */ public static double wavg( int[] values, float[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(int[],int[]) */ public static double wavg( int[] values, int[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(int[],long[]) */ public static double wavg( int[] values, long[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(int[],short[]) */ public static double wavg( int[] values, short[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(int[],io.deephaven.vector.ByteVector) */ public static double wavg( int[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(int[],io.deephaven.vector.DoubleVector) */ public static double wavg( int[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(int[],io.deephaven.vector.FloatVector) */ public static double wavg( int[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(int[],io.deephaven.vector.IntVector) */ public static double wavg( int[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(int[],io.deephaven.vector.LongVector) */ public static double wavg( int[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(int[],io.deephaven.vector.ShortVector) */ public static double wavg( int[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(long[],byte[]) */ public static double wavg( long[] values, byte[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(long[],double[]) */ public static double wavg( long[] values, double[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(long[],float[]) */ public static double wavg( long[] values, float[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(long[],int[]) */ public static double wavg( long[] values, int[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(long[],long[]) */ public static double wavg( long[] values, long[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(long[],short[]) */ public static double wavg( long[] values, short[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(long[],io.deephaven.vector.ByteVector) */ public static double wavg( long[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(long[],io.deephaven.vector.DoubleVector) */ public static double wavg( long[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(long[],io.deephaven.vector.FloatVector) */ public static double wavg( long[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(long[],io.deephaven.vector.IntVector) */ public static double wavg( long[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(long[],io.deephaven.vector.LongVector) */ public static double wavg( long[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(long[],io.deephaven.vector.ShortVector) */ public static double wavg( long[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(short[],byte[]) */ public static double wavg( short[] values, byte[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(short[],double[]) */ public static double wavg( short[] values, double[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(short[],float[]) */ public static double wavg( short[] values, float[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(short[],int[]) */ public static double wavg( short[] values, int[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(short[],long[]) */ public static double wavg( short[] values, long[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(short[],short[]) */ public static double wavg( short[] values, short[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(short[],io.deephaven.vector.ByteVector) */ public static double wavg( short[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(short[],io.deephaven.vector.DoubleVector) */ public static double wavg( short[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(short[],io.deephaven.vector.FloatVector) */ public static double wavg( short[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(short[],io.deephaven.vector.IntVector) */ public static double wavg( short[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(short[],io.deephaven.vector.LongVector) */ public static double wavg( short[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(short[],io.deephaven.vector.ShortVector) */ public static double wavg( short[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ByteVector,byte[]) */ public static double wavg( io.deephaven.vector.ByteVector values, byte[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ByteVector,double[]) */ public static double wavg( io.deephaven.vector.ByteVector values, double[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ByteVector,float[]) */ public static double wavg( io.deephaven.vector.ByteVector values, float[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ByteVector,int[]) */ public static double wavg( io.deephaven.vector.ByteVector values, int[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ByteVector,long[]) */ public static double wavg( io.deephaven.vector.ByteVector values, long[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ByteVector,short[]) */ public static double wavg( io.deephaven.vector.ByteVector values, short[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ByteVector,io.deephaven.vector.ByteVector) */ public static double wavg( io.deephaven.vector.ByteVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ByteVector,io.deephaven.vector.DoubleVector) */ public static double wavg( io.deephaven.vector.ByteVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ByteVector,io.deephaven.vector.FloatVector) */ public static double wavg( io.deephaven.vector.ByteVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ByteVector,io.deephaven.vector.IntVector) */ public static double wavg( io.deephaven.vector.ByteVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ByteVector,io.deephaven.vector.LongVector) */ public static double wavg( io.deephaven.vector.ByteVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ByteVector,io.deephaven.vector.ShortVector) */ public static double wavg( io.deephaven.vector.ByteVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.DoubleVector,byte[]) */ public static double wavg( io.deephaven.vector.DoubleVector values, byte[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.DoubleVector,double[]) */ public static double wavg( io.deephaven.vector.DoubleVector values, double[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.DoubleVector,float[]) */ public static double wavg( io.deephaven.vector.DoubleVector values, float[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.DoubleVector,int[]) */ public static double wavg( io.deephaven.vector.DoubleVector values, int[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.DoubleVector,long[]) */ public static double wavg( io.deephaven.vector.DoubleVector values, long[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.DoubleVector,short[]) */ public static double wavg( io.deephaven.vector.DoubleVector values, short[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.DoubleVector,io.deephaven.vector.ByteVector) */ public static double wavg( io.deephaven.vector.DoubleVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.DoubleVector,io.deephaven.vector.DoubleVector) */ public static double wavg( io.deephaven.vector.DoubleVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.DoubleVector,io.deephaven.vector.FloatVector) */ public static double wavg( io.deephaven.vector.DoubleVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.DoubleVector,io.deephaven.vector.IntVector) */ public static double wavg( io.deephaven.vector.DoubleVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.DoubleVector,io.deephaven.vector.LongVector) */ public static double wavg( io.deephaven.vector.DoubleVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.DoubleVector,io.deephaven.vector.ShortVector) */ public static double wavg( io.deephaven.vector.DoubleVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.FloatVector,byte[]) */ public static double wavg( io.deephaven.vector.FloatVector values, byte[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.FloatVector,double[]) */ public static double wavg( io.deephaven.vector.FloatVector values, double[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.FloatVector,float[]) */ public static double wavg( io.deephaven.vector.FloatVector values, float[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.FloatVector,int[]) */ public static double wavg( io.deephaven.vector.FloatVector values, int[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.FloatVector,long[]) */ public static double wavg( io.deephaven.vector.FloatVector values, long[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.FloatVector,short[]) */ public static double wavg( io.deephaven.vector.FloatVector values, short[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.FloatVector,io.deephaven.vector.ByteVector) */ public static double wavg( io.deephaven.vector.FloatVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.FloatVector,io.deephaven.vector.DoubleVector) */ public static double wavg( io.deephaven.vector.FloatVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.FloatVector,io.deephaven.vector.FloatVector) */ public static double wavg( io.deephaven.vector.FloatVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.FloatVector,io.deephaven.vector.IntVector) */ public static double wavg( io.deephaven.vector.FloatVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.FloatVector,io.deephaven.vector.LongVector) */ public static double wavg( io.deephaven.vector.FloatVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.FloatVector,io.deephaven.vector.ShortVector) */ public static double wavg( io.deephaven.vector.FloatVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.IntVector,byte[]) */ public static double wavg( io.deephaven.vector.IntVector values, byte[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.IntVector,double[]) */ public static double wavg( io.deephaven.vector.IntVector values, double[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.IntVector,float[]) */ public static double wavg( io.deephaven.vector.IntVector values, float[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.IntVector,int[]) */ public static double wavg( io.deephaven.vector.IntVector values, int[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.IntVector,long[]) */ public static double wavg( io.deephaven.vector.IntVector values, long[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.IntVector,short[]) */ public static double wavg( io.deephaven.vector.IntVector values, short[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.IntVector,io.deephaven.vector.ByteVector) */ public static double wavg( io.deephaven.vector.IntVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.IntVector,io.deephaven.vector.DoubleVector) */ public static double wavg( io.deephaven.vector.IntVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.IntVector,io.deephaven.vector.FloatVector) */ public static double wavg( io.deephaven.vector.IntVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.IntVector,io.deephaven.vector.IntVector) */ public static double wavg( io.deephaven.vector.IntVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.IntVector,io.deephaven.vector.LongVector) */ public static double wavg( io.deephaven.vector.IntVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.IntVector,io.deephaven.vector.ShortVector) */ public static double wavg( io.deephaven.vector.IntVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.LongVector,byte[]) */ public static double wavg( io.deephaven.vector.LongVector values, byte[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.LongVector,double[]) */ public static double wavg( io.deephaven.vector.LongVector values, double[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.LongVector,float[]) */ public static double wavg( io.deephaven.vector.LongVector values, float[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.LongVector,int[]) */ public static double wavg( io.deephaven.vector.LongVector values, int[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.LongVector,long[]) */ public static double wavg( io.deephaven.vector.LongVector values, long[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.LongVector,short[]) */ public static double wavg( io.deephaven.vector.LongVector values, short[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.LongVector,io.deephaven.vector.ByteVector) */ public static double wavg( io.deephaven.vector.LongVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.LongVector,io.deephaven.vector.DoubleVector) */ public static double wavg( io.deephaven.vector.LongVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.LongVector,io.deephaven.vector.FloatVector) */ public static double wavg( io.deephaven.vector.LongVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.LongVector,io.deephaven.vector.IntVector) */ public static double wavg( io.deephaven.vector.LongVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.LongVector,io.deephaven.vector.LongVector) */ public static double wavg( io.deephaven.vector.LongVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.LongVector,io.deephaven.vector.ShortVector) */ public static double wavg( io.deephaven.vector.LongVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ShortVector,byte[]) */ public static double wavg( io.deephaven.vector.ShortVector values, byte[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ShortVector,double[]) */ public static double wavg( io.deephaven.vector.ShortVector values, double[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ShortVector,float[]) */ public static double wavg( io.deephaven.vector.ShortVector values, float[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ShortVector,int[]) */ public static double wavg( io.deephaven.vector.ShortVector values, int[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ShortVector,long[]) */ public static double wavg( io.deephaven.vector.ShortVector values, long[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ShortVector,short[]) */ public static double wavg( io.deephaven.vector.ShortVector values, short[] weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ShortVector,io.deephaven.vector.ByteVector) */ public static double wavg( io.deephaven.vector.ShortVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ShortVector,io.deephaven.vector.DoubleVector) */ public static double wavg( io.deephaven.vector.ShortVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ShortVector,io.deephaven.vector.FloatVector) */ public static double wavg( io.deephaven.vector.ShortVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ShortVector,io.deephaven.vector.IntVector) */ public static double wavg( io.deephaven.vector.ShortVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ShortVector,io.deephaven.vector.LongVector) */ public static double wavg( io.deephaven.vector.ShortVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wavg(io.deephaven.vector.ShortVector,io.deephaven.vector.ShortVector) */ public static double wavg( io.deephaven.vector.ShortVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wavg( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(byte[],byte[]) */ public static double wstd( byte[] values, byte[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(byte[],double[]) */ public static double wstd( byte[] values, double[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(byte[],float[]) */ public static double wstd( byte[] values, float[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(byte[],int[]) */ public static double wstd( byte[] values, int[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(byte[],long[]) */ public static double wstd( byte[] values, long[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(byte[],short[]) */ public static double wstd( byte[] values, short[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(byte[],io.deephaven.vector.ByteVector) */ public static double wstd( byte[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(byte[],io.deephaven.vector.DoubleVector) */ public static double wstd( byte[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(byte[],io.deephaven.vector.FloatVector) */ public static double wstd( byte[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(byte[],io.deephaven.vector.IntVector) */ public static double wstd( byte[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(byte[],io.deephaven.vector.LongVector) */ public static double wstd( byte[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(byte[],io.deephaven.vector.ShortVector) */ public static double wstd( byte[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(double[],byte[]) */ public static double wstd( double[] values, byte[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(double[],double[]) */ public static double wstd( double[] values, double[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(double[],float[]) */ public static double wstd( double[] values, float[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(double[],int[]) */ public static double wstd( double[] values, int[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(double[],long[]) */ public static double wstd( double[] values, long[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(double[],short[]) */ public static double wstd( double[] values, short[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(double[],io.deephaven.vector.ByteVector) */ public static double wstd( double[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(double[],io.deephaven.vector.DoubleVector) */ public static double wstd( double[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(double[],io.deephaven.vector.FloatVector) */ public static double wstd( double[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(double[],io.deephaven.vector.IntVector) */ public static double wstd( double[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(double[],io.deephaven.vector.LongVector) */ public static double wstd( double[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(double[],io.deephaven.vector.ShortVector) */ public static double wstd( double[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(float[],byte[]) */ public static double wstd( float[] values, byte[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(float[],double[]) */ public static double wstd( float[] values, double[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(float[],float[]) */ public static double wstd( float[] values, float[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(float[],int[]) */ public static double wstd( float[] values, int[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(float[],long[]) */ public static double wstd( float[] values, long[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(float[],short[]) */ public static double wstd( float[] values, short[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(float[],io.deephaven.vector.ByteVector) */ public static double wstd( float[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(float[],io.deephaven.vector.DoubleVector) */ public static double wstd( float[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(float[],io.deephaven.vector.FloatVector) */ public static double wstd( float[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(float[],io.deephaven.vector.IntVector) */ public static double wstd( float[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(float[],io.deephaven.vector.LongVector) */ public static double wstd( float[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(float[],io.deephaven.vector.ShortVector) */ public static double wstd( float[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(int[],byte[]) */ public static double wstd( int[] values, byte[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(int[],double[]) */ public static double wstd( int[] values, double[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(int[],float[]) */ public static double wstd( int[] values, float[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(int[],int[]) */ public static double wstd( int[] values, int[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(int[],long[]) */ public static double wstd( int[] values, long[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(int[],short[]) */ public static double wstd( int[] values, short[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(int[],io.deephaven.vector.ByteVector) */ public static double wstd( int[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(int[],io.deephaven.vector.DoubleVector) */ public static double wstd( int[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(int[],io.deephaven.vector.FloatVector) */ public static double wstd( int[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(int[],io.deephaven.vector.IntVector) */ public static double wstd( int[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(int[],io.deephaven.vector.LongVector) */ public static double wstd( int[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(int[],io.deephaven.vector.ShortVector) */ public static double wstd( int[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(long[],byte[]) */ public static double wstd( long[] values, byte[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(long[],double[]) */ public static double wstd( long[] values, double[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(long[],float[]) */ public static double wstd( long[] values, float[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(long[],int[]) */ public static double wstd( long[] values, int[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(long[],long[]) */ public static double wstd( long[] values, long[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(long[],short[]) */ public static double wstd( long[] values, short[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(long[],io.deephaven.vector.ByteVector) */ public static double wstd( long[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(long[],io.deephaven.vector.DoubleVector) */ public static double wstd( long[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(long[],io.deephaven.vector.FloatVector) */ public static double wstd( long[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(long[],io.deephaven.vector.IntVector) */ public static double wstd( long[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(long[],io.deephaven.vector.LongVector) */ public static double wstd( long[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(long[],io.deephaven.vector.ShortVector) */ public static double wstd( long[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(short[],byte[]) */ public static double wstd( short[] values, byte[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(short[],double[]) */ public static double wstd( short[] values, double[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(short[],float[]) */ public static double wstd( short[] values, float[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(short[],int[]) */ public static double wstd( short[] values, int[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(short[],long[]) */ public static double wstd( short[] values, long[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(short[],short[]) */ public static double wstd( short[] values, short[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(short[],io.deephaven.vector.ByteVector) */ public static double wstd( short[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(short[],io.deephaven.vector.DoubleVector) */ public static double wstd( short[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(short[],io.deephaven.vector.FloatVector) */ public static double wstd( short[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(short[],io.deephaven.vector.IntVector) */ public static double wstd( short[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(short[],io.deephaven.vector.LongVector) */ public static double wstd( short[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(short[],io.deephaven.vector.ShortVector) */ public static double wstd( short[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ByteVector,byte[]) */ public static double wstd( io.deephaven.vector.ByteVector values, byte[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ByteVector,double[]) */ public static double wstd( io.deephaven.vector.ByteVector values, double[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ByteVector,float[]) */ public static double wstd( io.deephaven.vector.ByteVector values, float[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ByteVector,int[]) */ public static double wstd( io.deephaven.vector.ByteVector values, int[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ByteVector,long[]) */ public static double wstd( io.deephaven.vector.ByteVector values, long[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ByteVector,short[]) */ public static double wstd( io.deephaven.vector.ByteVector values, short[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ByteVector,io.deephaven.vector.ByteVector) */ public static double wstd( io.deephaven.vector.ByteVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ByteVector,io.deephaven.vector.DoubleVector) */ public static double wstd( io.deephaven.vector.ByteVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ByteVector,io.deephaven.vector.FloatVector) */ public static double wstd( io.deephaven.vector.ByteVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ByteVector,io.deephaven.vector.IntVector) */ public static double wstd( io.deephaven.vector.ByteVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ByteVector,io.deephaven.vector.LongVector) */ public static double wstd( io.deephaven.vector.ByteVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ByteVector,io.deephaven.vector.ShortVector) */ public static double wstd( io.deephaven.vector.ByteVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.DoubleVector,byte[]) */ public static double wstd( io.deephaven.vector.DoubleVector values, byte[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.DoubleVector,double[]) */ public static double wstd( io.deephaven.vector.DoubleVector values, double[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.DoubleVector,float[]) */ public static double wstd( io.deephaven.vector.DoubleVector values, float[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.DoubleVector,int[]) */ public static double wstd( io.deephaven.vector.DoubleVector values, int[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.DoubleVector,long[]) */ public static double wstd( io.deephaven.vector.DoubleVector values, long[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.DoubleVector,short[]) */ public static double wstd( io.deephaven.vector.DoubleVector values, short[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.DoubleVector,io.deephaven.vector.ByteVector) */ public static double wstd( io.deephaven.vector.DoubleVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.DoubleVector,io.deephaven.vector.DoubleVector) */ public static double wstd( io.deephaven.vector.DoubleVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.DoubleVector,io.deephaven.vector.FloatVector) */ public static double wstd( io.deephaven.vector.DoubleVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.DoubleVector,io.deephaven.vector.IntVector) */ public static double wstd( io.deephaven.vector.DoubleVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.DoubleVector,io.deephaven.vector.LongVector) */ public static double wstd( io.deephaven.vector.DoubleVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.DoubleVector,io.deephaven.vector.ShortVector) */ public static double wstd( io.deephaven.vector.DoubleVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.FloatVector,byte[]) */ public static double wstd( io.deephaven.vector.FloatVector values, byte[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.FloatVector,double[]) */ public static double wstd( io.deephaven.vector.FloatVector values, double[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.FloatVector,float[]) */ public static double wstd( io.deephaven.vector.FloatVector values, float[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.FloatVector,int[]) */ public static double wstd( io.deephaven.vector.FloatVector values, int[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.FloatVector,long[]) */ public static double wstd( io.deephaven.vector.FloatVector values, long[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.FloatVector,short[]) */ public static double wstd( io.deephaven.vector.FloatVector values, short[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.FloatVector,io.deephaven.vector.ByteVector) */ public static double wstd( io.deephaven.vector.FloatVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.FloatVector,io.deephaven.vector.DoubleVector) */ public static double wstd( io.deephaven.vector.FloatVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.FloatVector,io.deephaven.vector.FloatVector) */ public static double wstd( io.deephaven.vector.FloatVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.FloatVector,io.deephaven.vector.IntVector) */ public static double wstd( io.deephaven.vector.FloatVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.FloatVector,io.deephaven.vector.LongVector) */ public static double wstd( io.deephaven.vector.FloatVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.FloatVector,io.deephaven.vector.ShortVector) */ public static double wstd( io.deephaven.vector.FloatVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.IntVector,byte[]) */ public static double wstd( io.deephaven.vector.IntVector values, byte[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.IntVector,double[]) */ public static double wstd( io.deephaven.vector.IntVector values, double[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.IntVector,float[]) */ public static double wstd( io.deephaven.vector.IntVector values, float[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.IntVector,int[]) */ public static double wstd( io.deephaven.vector.IntVector values, int[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.IntVector,long[]) */ public static double wstd( io.deephaven.vector.IntVector values, long[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.IntVector,short[]) */ public static double wstd( io.deephaven.vector.IntVector values, short[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.IntVector,io.deephaven.vector.ByteVector) */ public static double wstd( io.deephaven.vector.IntVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.IntVector,io.deephaven.vector.DoubleVector) */ public static double wstd( io.deephaven.vector.IntVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.IntVector,io.deephaven.vector.FloatVector) */ public static double wstd( io.deephaven.vector.IntVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.IntVector,io.deephaven.vector.IntVector) */ public static double wstd( io.deephaven.vector.IntVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.IntVector,io.deephaven.vector.LongVector) */ public static double wstd( io.deephaven.vector.IntVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.IntVector,io.deephaven.vector.ShortVector) */ public static double wstd( io.deephaven.vector.IntVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.LongVector,byte[]) */ public static double wstd( io.deephaven.vector.LongVector values, byte[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.LongVector,double[]) */ public static double wstd( io.deephaven.vector.LongVector values, double[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.LongVector,float[]) */ public static double wstd( io.deephaven.vector.LongVector values, float[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.LongVector,int[]) */ public static double wstd( io.deephaven.vector.LongVector values, int[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.LongVector,long[]) */ public static double wstd( io.deephaven.vector.LongVector values, long[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.LongVector,short[]) */ public static double wstd( io.deephaven.vector.LongVector values, short[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.LongVector,io.deephaven.vector.ByteVector) */ public static double wstd( io.deephaven.vector.LongVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.LongVector,io.deephaven.vector.DoubleVector) */ public static double wstd( io.deephaven.vector.LongVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.LongVector,io.deephaven.vector.FloatVector) */ public static double wstd( io.deephaven.vector.LongVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.LongVector,io.deephaven.vector.IntVector) */ public static double wstd( io.deephaven.vector.LongVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.LongVector,io.deephaven.vector.LongVector) */ public static double wstd( io.deephaven.vector.LongVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.LongVector,io.deephaven.vector.ShortVector) */ public static double wstd( io.deephaven.vector.LongVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ShortVector,byte[]) */ public static double wstd( io.deephaven.vector.ShortVector values, byte[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ShortVector,double[]) */ public static double wstd( io.deephaven.vector.ShortVector values, double[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ShortVector,float[]) */ public static double wstd( io.deephaven.vector.ShortVector values, float[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ShortVector,int[]) */ public static double wstd( io.deephaven.vector.ShortVector values, int[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ShortVector,long[]) */ public static double wstd( io.deephaven.vector.ShortVector values, long[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ShortVector,short[]) */ public static double wstd( io.deephaven.vector.ShortVector values, short[] weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ShortVector,io.deephaven.vector.ByteVector) */ public static double wstd( io.deephaven.vector.ShortVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ShortVector,io.deephaven.vector.DoubleVector) */ public static double wstd( io.deephaven.vector.ShortVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ShortVector,io.deephaven.vector.FloatVector) */ public static double wstd( io.deephaven.vector.ShortVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ShortVector,io.deephaven.vector.IntVector) */ public static double wstd( io.deephaven.vector.ShortVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ShortVector,io.deephaven.vector.LongVector) */ public static double wstd( io.deephaven.vector.ShortVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wstd(io.deephaven.vector.ShortVector,io.deephaven.vector.ShortVector) */ public static double wstd( io.deephaven.vector.ShortVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wstd( values, weights );} + /** @see io.deephaven.function.Numeric#wste(byte[],byte[]) */ public static double wste( byte[] values, byte[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(byte[],double[]) */ public static double wste( byte[] values, double[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(byte[],float[]) */ public static double wste( byte[] values, float[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(byte[],int[]) */ public static double wste( byte[] values, int[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(byte[],long[]) */ public static double wste( byte[] values, long[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(byte[],short[]) */ public static double wste( byte[] values, short[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(byte[],io.deephaven.vector.ByteVector) */ public static double wste( byte[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(byte[],io.deephaven.vector.DoubleVector) */ public static double wste( byte[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(byte[],io.deephaven.vector.FloatVector) */ public static double wste( byte[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(byte[],io.deephaven.vector.IntVector) */ public static double wste( byte[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(byte[],io.deephaven.vector.LongVector) */ public static double wste( byte[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(byte[],io.deephaven.vector.ShortVector) */ public static double wste( byte[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(double[],byte[]) */ public static double wste( double[] values, byte[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(double[],double[]) */ public static double wste( double[] values, double[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(double[],float[]) */ public static double wste( double[] values, float[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(double[],int[]) */ public static double wste( double[] values, int[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(double[],long[]) */ public static double wste( double[] values, long[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(double[],short[]) */ public static double wste( double[] values, short[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(double[],io.deephaven.vector.ByteVector) */ public static double wste( double[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(double[],io.deephaven.vector.DoubleVector) */ public static double wste( double[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(double[],io.deephaven.vector.FloatVector) */ public static double wste( double[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(double[],io.deephaven.vector.IntVector) */ public static double wste( double[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(double[],io.deephaven.vector.LongVector) */ public static double wste( double[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(double[],io.deephaven.vector.ShortVector) */ public static double wste( double[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(float[],byte[]) */ public static double wste( float[] values, byte[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(float[],double[]) */ public static double wste( float[] values, double[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(float[],float[]) */ public static double wste( float[] values, float[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(float[],int[]) */ public static double wste( float[] values, int[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(float[],long[]) */ public static double wste( float[] values, long[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(float[],short[]) */ public static double wste( float[] values, short[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(float[],io.deephaven.vector.ByteVector) */ public static double wste( float[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(float[],io.deephaven.vector.DoubleVector) */ public static double wste( float[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(float[],io.deephaven.vector.FloatVector) */ public static double wste( float[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(float[],io.deephaven.vector.IntVector) */ public static double wste( float[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(float[],io.deephaven.vector.LongVector) */ public static double wste( float[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(float[],io.deephaven.vector.ShortVector) */ public static double wste( float[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(int[],byte[]) */ public static double wste( int[] values, byte[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(int[],double[]) */ public static double wste( int[] values, double[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(int[],float[]) */ public static double wste( int[] values, float[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(int[],int[]) */ public static double wste( int[] values, int[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(int[],long[]) */ public static double wste( int[] values, long[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(int[],short[]) */ public static double wste( int[] values, short[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(int[],io.deephaven.vector.ByteVector) */ public static double wste( int[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(int[],io.deephaven.vector.DoubleVector) */ public static double wste( int[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(int[],io.deephaven.vector.FloatVector) */ public static double wste( int[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(int[],io.deephaven.vector.IntVector) */ public static double wste( int[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(int[],io.deephaven.vector.LongVector) */ public static double wste( int[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(int[],io.deephaven.vector.ShortVector) */ public static double wste( int[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(long[],byte[]) */ public static double wste( long[] values, byte[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(long[],double[]) */ public static double wste( long[] values, double[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(long[],float[]) */ public static double wste( long[] values, float[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(long[],int[]) */ public static double wste( long[] values, int[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(long[],long[]) */ public static double wste( long[] values, long[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(long[],short[]) */ public static double wste( long[] values, short[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(long[],io.deephaven.vector.ByteVector) */ public static double wste( long[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(long[],io.deephaven.vector.DoubleVector) */ public static double wste( long[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(long[],io.deephaven.vector.FloatVector) */ public static double wste( long[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(long[],io.deephaven.vector.IntVector) */ public static double wste( long[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(long[],io.deephaven.vector.LongVector) */ public static double wste( long[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(long[],io.deephaven.vector.ShortVector) */ public static double wste( long[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(short[],byte[]) */ public static double wste( short[] values, byte[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(short[],double[]) */ public static double wste( short[] values, double[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(short[],float[]) */ public static double wste( short[] values, float[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(short[],int[]) */ public static double wste( short[] values, int[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(short[],long[]) */ public static double wste( short[] values, long[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(short[],short[]) */ public static double wste( short[] values, short[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(short[],io.deephaven.vector.ByteVector) */ public static double wste( short[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(short[],io.deephaven.vector.DoubleVector) */ public static double wste( short[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(short[],io.deephaven.vector.FloatVector) */ public static double wste( short[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(short[],io.deephaven.vector.IntVector) */ public static double wste( short[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(short[],io.deephaven.vector.LongVector) */ public static double wste( short[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(short[],io.deephaven.vector.ShortVector) */ public static double wste( short[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ByteVector,byte[]) */ public static double wste( io.deephaven.vector.ByteVector values, byte[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ByteVector,double[]) */ public static double wste( io.deephaven.vector.ByteVector values, double[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ByteVector,float[]) */ public static double wste( io.deephaven.vector.ByteVector values, float[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ByteVector,int[]) */ public static double wste( io.deephaven.vector.ByteVector values, int[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ByteVector,long[]) */ public static double wste( io.deephaven.vector.ByteVector values, long[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ByteVector,short[]) */ public static double wste( io.deephaven.vector.ByteVector values, short[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ByteVector,io.deephaven.vector.ByteVector) */ public static double wste( io.deephaven.vector.ByteVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ByteVector,io.deephaven.vector.DoubleVector) */ public static double wste( io.deephaven.vector.ByteVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ByteVector,io.deephaven.vector.FloatVector) */ public static double wste( io.deephaven.vector.ByteVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ByteVector,io.deephaven.vector.IntVector) */ public static double wste( io.deephaven.vector.ByteVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ByteVector,io.deephaven.vector.LongVector) */ public static double wste( io.deephaven.vector.ByteVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ByteVector,io.deephaven.vector.ShortVector) */ public static double wste( io.deephaven.vector.ByteVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.DoubleVector,byte[]) */ public static double wste( io.deephaven.vector.DoubleVector values, byte[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.DoubleVector,double[]) */ public static double wste( io.deephaven.vector.DoubleVector values, double[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.DoubleVector,float[]) */ public static double wste( io.deephaven.vector.DoubleVector values, float[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.DoubleVector,int[]) */ public static double wste( io.deephaven.vector.DoubleVector values, int[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.DoubleVector,long[]) */ public static double wste( io.deephaven.vector.DoubleVector values, long[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.DoubleVector,short[]) */ public static double wste( io.deephaven.vector.DoubleVector values, short[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.DoubleVector,io.deephaven.vector.ByteVector) */ public static double wste( io.deephaven.vector.DoubleVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.DoubleVector,io.deephaven.vector.DoubleVector) */ public static double wste( io.deephaven.vector.DoubleVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.DoubleVector,io.deephaven.vector.FloatVector) */ public static double wste( io.deephaven.vector.DoubleVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.DoubleVector,io.deephaven.vector.IntVector) */ public static double wste( io.deephaven.vector.DoubleVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.DoubleVector,io.deephaven.vector.LongVector) */ public static double wste( io.deephaven.vector.DoubleVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.DoubleVector,io.deephaven.vector.ShortVector) */ public static double wste( io.deephaven.vector.DoubleVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.FloatVector,byte[]) */ public static double wste( io.deephaven.vector.FloatVector values, byte[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.FloatVector,double[]) */ public static double wste( io.deephaven.vector.FloatVector values, double[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.FloatVector,float[]) */ public static double wste( io.deephaven.vector.FloatVector values, float[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.FloatVector,int[]) */ public static double wste( io.deephaven.vector.FloatVector values, int[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.FloatVector,long[]) */ public static double wste( io.deephaven.vector.FloatVector values, long[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.FloatVector,short[]) */ public static double wste( io.deephaven.vector.FloatVector values, short[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.FloatVector,io.deephaven.vector.ByteVector) */ public static double wste( io.deephaven.vector.FloatVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.FloatVector,io.deephaven.vector.DoubleVector) */ public static double wste( io.deephaven.vector.FloatVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.FloatVector,io.deephaven.vector.FloatVector) */ public static double wste( io.deephaven.vector.FloatVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.FloatVector,io.deephaven.vector.IntVector) */ public static double wste( io.deephaven.vector.FloatVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.FloatVector,io.deephaven.vector.LongVector) */ public static double wste( io.deephaven.vector.FloatVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.FloatVector,io.deephaven.vector.ShortVector) */ public static double wste( io.deephaven.vector.FloatVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.IntVector,byte[]) */ public static double wste( io.deephaven.vector.IntVector values, byte[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.IntVector,double[]) */ public static double wste( io.deephaven.vector.IntVector values, double[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.IntVector,float[]) */ public static double wste( io.deephaven.vector.IntVector values, float[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.IntVector,int[]) */ public static double wste( io.deephaven.vector.IntVector values, int[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.IntVector,long[]) */ public static double wste( io.deephaven.vector.IntVector values, long[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.IntVector,short[]) */ public static double wste( io.deephaven.vector.IntVector values, short[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.IntVector,io.deephaven.vector.ByteVector) */ public static double wste( io.deephaven.vector.IntVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.IntVector,io.deephaven.vector.DoubleVector) */ public static double wste( io.deephaven.vector.IntVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.IntVector,io.deephaven.vector.FloatVector) */ public static double wste( io.deephaven.vector.IntVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.IntVector,io.deephaven.vector.IntVector) */ public static double wste( io.deephaven.vector.IntVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.IntVector,io.deephaven.vector.LongVector) */ public static double wste( io.deephaven.vector.IntVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.IntVector,io.deephaven.vector.ShortVector) */ public static double wste( io.deephaven.vector.IntVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.LongVector,byte[]) */ public static double wste( io.deephaven.vector.LongVector values, byte[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.LongVector,double[]) */ public static double wste( io.deephaven.vector.LongVector values, double[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.LongVector,float[]) */ public static double wste( io.deephaven.vector.LongVector values, float[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.LongVector,int[]) */ public static double wste( io.deephaven.vector.LongVector values, int[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.LongVector,long[]) */ public static double wste( io.deephaven.vector.LongVector values, long[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.LongVector,short[]) */ public static double wste( io.deephaven.vector.LongVector values, short[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.LongVector,io.deephaven.vector.ByteVector) */ public static double wste( io.deephaven.vector.LongVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.LongVector,io.deephaven.vector.DoubleVector) */ public static double wste( io.deephaven.vector.LongVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.LongVector,io.deephaven.vector.FloatVector) */ public static double wste( io.deephaven.vector.LongVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.LongVector,io.deephaven.vector.IntVector) */ public static double wste( io.deephaven.vector.LongVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.LongVector,io.deephaven.vector.LongVector) */ public static double wste( io.deephaven.vector.LongVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.LongVector,io.deephaven.vector.ShortVector) */ public static double wste( io.deephaven.vector.LongVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ShortVector,byte[]) */ public static double wste( io.deephaven.vector.ShortVector values, byte[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ShortVector,double[]) */ public static double wste( io.deephaven.vector.ShortVector values, double[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ShortVector,float[]) */ public static double wste( io.deephaven.vector.ShortVector values, float[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ShortVector,int[]) */ public static double wste( io.deephaven.vector.ShortVector values, int[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ShortVector,long[]) */ public static double wste( io.deephaven.vector.ShortVector values, long[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ShortVector,short[]) */ public static double wste( io.deephaven.vector.ShortVector values, short[] weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ShortVector,io.deephaven.vector.ByteVector) */ public static double wste( io.deephaven.vector.ShortVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ShortVector,io.deephaven.vector.DoubleVector) */ public static double wste( io.deephaven.vector.ShortVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ShortVector,io.deephaven.vector.FloatVector) */ public static double wste( io.deephaven.vector.ShortVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ShortVector,io.deephaven.vector.IntVector) */ public static double wste( io.deephaven.vector.ShortVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ShortVector,io.deephaven.vector.LongVector) */ public static double wste( io.deephaven.vector.ShortVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wste(io.deephaven.vector.ShortVector,io.deephaven.vector.ShortVector) */ public static double wste( io.deephaven.vector.ShortVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wste( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(byte[],byte[]) */ public static double wsum( byte[] values, byte[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(byte[],double[]) */ public static double wsum( byte[] values, double[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(byte[],float[]) */ public static double wsum( byte[] values, float[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(byte[],int[]) */ public static double wsum( byte[] values, int[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(byte[],long[]) */ public static double wsum( byte[] values, long[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(byte[],short[]) */ public static double wsum( byte[] values, short[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(byte[],io.deephaven.vector.ByteVector) */ public static double wsum( byte[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(byte[],io.deephaven.vector.DoubleVector) */ public static double wsum( byte[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(byte[],io.deephaven.vector.FloatVector) */ public static double wsum( byte[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(byte[],io.deephaven.vector.IntVector) */ public static double wsum( byte[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(byte[],io.deephaven.vector.LongVector) */ public static double wsum( byte[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(byte[],io.deephaven.vector.ShortVector) */ public static double wsum( byte[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(double[],byte[]) */ public static double wsum( double[] values, byte[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(double[],double[]) */ public static double wsum( double[] values, double[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(double[],float[]) */ public static double wsum( double[] values, float[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(double[],int[]) */ public static double wsum( double[] values, int[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(double[],long[]) */ public static double wsum( double[] values, long[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(double[],short[]) */ public static double wsum( double[] values, short[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(double[],io.deephaven.vector.ByteVector) */ public static double wsum( double[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(double[],io.deephaven.vector.DoubleVector) */ public static double wsum( double[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(double[],io.deephaven.vector.FloatVector) */ public static double wsum( double[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(double[],io.deephaven.vector.IntVector) */ public static double wsum( double[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(double[],io.deephaven.vector.LongVector) */ public static double wsum( double[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(double[],io.deephaven.vector.ShortVector) */ public static double wsum( double[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(float[],byte[]) */ public static double wsum( float[] values, byte[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(float[],double[]) */ public static double wsum( float[] values, double[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(float[],float[]) */ public static double wsum( float[] values, float[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(float[],int[]) */ public static double wsum( float[] values, int[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(float[],long[]) */ public static double wsum( float[] values, long[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(float[],short[]) */ public static double wsum( float[] values, short[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(float[],io.deephaven.vector.ByteVector) */ public static double wsum( float[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(float[],io.deephaven.vector.DoubleVector) */ public static double wsum( float[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(float[],io.deephaven.vector.FloatVector) */ public static double wsum( float[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(float[],io.deephaven.vector.IntVector) */ public static double wsum( float[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(float[],io.deephaven.vector.LongVector) */ public static double wsum( float[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(float[],io.deephaven.vector.ShortVector) */ public static double wsum( float[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(int[],byte[]) */ public static double wsum( int[] values, byte[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(int[],double[]) */ public static double wsum( int[] values, double[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(int[],float[]) */ public static double wsum( int[] values, float[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(int[],int[]) */ public static double wsum( int[] values, int[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(int[],long[]) */ public static double wsum( int[] values, long[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(int[],short[]) */ public static double wsum( int[] values, short[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(int[],io.deephaven.vector.ByteVector) */ public static double wsum( int[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(int[],io.deephaven.vector.DoubleVector) */ public static double wsum( int[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(int[],io.deephaven.vector.FloatVector) */ public static double wsum( int[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(int[],io.deephaven.vector.IntVector) */ public static double wsum( int[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(int[],io.deephaven.vector.LongVector) */ public static double wsum( int[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(int[],io.deephaven.vector.ShortVector) */ public static double wsum( int[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(long[],byte[]) */ public static double wsum( long[] values, byte[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(long[],double[]) */ public static double wsum( long[] values, double[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(long[],float[]) */ public static double wsum( long[] values, float[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(long[],int[]) */ public static double wsum( long[] values, int[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(long[],long[]) */ public static double wsum( long[] values, long[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(long[],short[]) */ public static double wsum( long[] values, short[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(long[],io.deephaven.vector.ByteVector) */ public static double wsum( long[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(long[],io.deephaven.vector.DoubleVector) */ public static double wsum( long[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(long[],io.deephaven.vector.FloatVector) */ public static double wsum( long[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(long[],io.deephaven.vector.IntVector) */ public static double wsum( long[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(long[],io.deephaven.vector.LongVector) */ public static double wsum( long[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(long[],io.deephaven.vector.ShortVector) */ public static double wsum( long[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(short[],byte[]) */ public static double wsum( short[] values, byte[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(short[],double[]) */ public static double wsum( short[] values, double[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(short[],float[]) */ public static double wsum( short[] values, float[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(short[],int[]) */ public static double wsum( short[] values, int[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(short[],long[]) */ public static double wsum( short[] values, long[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(short[],short[]) */ public static double wsum( short[] values, short[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(short[],io.deephaven.vector.ByteVector) */ public static double wsum( short[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(short[],io.deephaven.vector.DoubleVector) */ public static double wsum( short[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(short[],io.deephaven.vector.FloatVector) */ public static double wsum( short[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(short[],io.deephaven.vector.IntVector) */ public static double wsum( short[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(short[],io.deephaven.vector.LongVector) */ public static double wsum( short[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(short[],io.deephaven.vector.ShortVector) */ public static double wsum( short[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ByteVector,byte[]) */ public static double wsum( io.deephaven.vector.ByteVector values, byte[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ByteVector,double[]) */ public static double wsum( io.deephaven.vector.ByteVector values, double[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ByteVector,float[]) */ public static double wsum( io.deephaven.vector.ByteVector values, float[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ByteVector,int[]) */ public static double wsum( io.deephaven.vector.ByteVector values, int[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ByteVector,long[]) */ public static double wsum( io.deephaven.vector.ByteVector values, long[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ByteVector,short[]) */ public static double wsum( io.deephaven.vector.ByteVector values, short[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ByteVector,io.deephaven.vector.ByteVector) */ public static double wsum( io.deephaven.vector.ByteVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ByteVector,io.deephaven.vector.DoubleVector) */ public static double wsum( io.deephaven.vector.ByteVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ByteVector,io.deephaven.vector.FloatVector) */ public static double wsum( io.deephaven.vector.ByteVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ByteVector,io.deephaven.vector.IntVector) */ public static double wsum( io.deephaven.vector.ByteVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ByteVector,io.deephaven.vector.LongVector) */ public static double wsum( io.deephaven.vector.ByteVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ByteVector,io.deephaven.vector.ShortVector) */ public static double wsum( io.deephaven.vector.ByteVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.DoubleVector,byte[]) */ public static double wsum( io.deephaven.vector.DoubleVector values, byte[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.DoubleVector,double[]) */ public static double wsum( io.deephaven.vector.DoubleVector values, double[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.DoubleVector,float[]) */ public static double wsum( io.deephaven.vector.DoubleVector values, float[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.DoubleVector,int[]) */ public static double wsum( io.deephaven.vector.DoubleVector values, int[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.DoubleVector,long[]) */ public static double wsum( io.deephaven.vector.DoubleVector values, long[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.DoubleVector,short[]) */ public static double wsum( io.deephaven.vector.DoubleVector values, short[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.DoubleVector,io.deephaven.vector.ByteVector) */ public static double wsum( io.deephaven.vector.DoubleVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.DoubleVector,io.deephaven.vector.DoubleVector) */ public static double wsum( io.deephaven.vector.DoubleVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.DoubleVector,io.deephaven.vector.FloatVector) */ public static double wsum( io.deephaven.vector.DoubleVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.DoubleVector,io.deephaven.vector.IntVector) */ public static double wsum( io.deephaven.vector.DoubleVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.DoubleVector,io.deephaven.vector.LongVector) */ public static double wsum( io.deephaven.vector.DoubleVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.DoubleVector,io.deephaven.vector.ShortVector) */ public static double wsum( io.deephaven.vector.DoubleVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.FloatVector,byte[]) */ public static double wsum( io.deephaven.vector.FloatVector values, byte[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.FloatVector,double[]) */ public static double wsum( io.deephaven.vector.FloatVector values, double[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.FloatVector,float[]) */ public static double wsum( io.deephaven.vector.FloatVector values, float[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.FloatVector,int[]) */ public static double wsum( io.deephaven.vector.FloatVector values, int[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.FloatVector,long[]) */ public static double wsum( io.deephaven.vector.FloatVector values, long[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.FloatVector,short[]) */ public static double wsum( io.deephaven.vector.FloatVector values, short[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.FloatVector,io.deephaven.vector.ByteVector) */ public static double wsum( io.deephaven.vector.FloatVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.FloatVector,io.deephaven.vector.DoubleVector) */ public static double wsum( io.deephaven.vector.FloatVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.FloatVector,io.deephaven.vector.FloatVector) */ public static double wsum( io.deephaven.vector.FloatVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.FloatVector,io.deephaven.vector.IntVector) */ public static double wsum( io.deephaven.vector.FloatVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.FloatVector,io.deephaven.vector.LongVector) */ public static double wsum( io.deephaven.vector.FloatVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.FloatVector,io.deephaven.vector.ShortVector) */ public static double wsum( io.deephaven.vector.FloatVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.IntVector,byte[]) */ public static double wsum( io.deephaven.vector.IntVector values, byte[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.IntVector,double[]) */ public static double wsum( io.deephaven.vector.IntVector values, double[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.IntVector,float[]) */ public static double wsum( io.deephaven.vector.IntVector values, float[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.IntVector,int[]) */ public static double wsum( io.deephaven.vector.IntVector values, int[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.IntVector,long[]) */ public static double wsum( io.deephaven.vector.IntVector values, long[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.IntVector,short[]) */ public static double wsum( io.deephaven.vector.IntVector values, short[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.IntVector,io.deephaven.vector.ByteVector) */ public static double wsum( io.deephaven.vector.IntVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.IntVector,io.deephaven.vector.DoubleVector) */ public static double wsum( io.deephaven.vector.IntVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.IntVector,io.deephaven.vector.FloatVector) */ public static double wsum( io.deephaven.vector.IntVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.IntVector,io.deephaven.vector.IntVector) */ public static double wsum( io.deephaven.vector.IntVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.IntVector,io.deephaven.vector.LongVector) */ public static double wsum( io.deephaven.vector.IntVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.IntVector,io.deephaven.vector.ShortVector) */ public static double wsum( io.deephaven.vector.IntVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.LongVector,byte[]) */ public static double wsum( io.deephaven.vector.LongVector values, byte[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.LongVector,double[]) */ public static double wsum( io.deephaven.vector.LongVector values, double[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.LongVector,float[]) */ public static double wsum( io.deephaven.vector.LongVector values, float[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.LongVector,int[]) */ public static double wsum( io.deephaven.vector.LongVector values, int[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.LongVector,long[]) */ public static double wsum( io.deephaven.vector.LongVector values, long[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.LongVector,short[]) */ public static double wsum( io.deephaven.vector.LongVector values, short[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.LongVector,io.deephaven.vector.ByteVector) */ public static double wsum( io.deephaven.vector.LongVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.LongVector,io.deephaven.vector.DoubleVector) */ public static double wsum( io.deephaven.vector.LongVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.LongVector,io.deephaven.vector.FloatVector) */ public static double wsum( io.deephaven.vector.LongVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.LongVector,io.deephaven.vector.IntVector) */ public static double wsum( io.deephaven.vector.LongVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.LongVector,io.deephaven.vector.LongVector) */ public static double wsum( io.deephaven.vector.LongVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.LongVector,io.deephaven.vector.ShortVector) */ public static double wsum( io.deephaven.vector.LongVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ShortVector,byte[]) */ public static double wsum( io.deephaven.vector.ShortVector values, byte[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ShortVector,double[]) */ public static double wsum( io.deephaven.vector.ShortVector values, double[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ShortVector,float[]) */ public static double wsum( io.deephaven.vector.ShortVector values, float[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ShortVector,int[]) */ public static double wsum( io.deephaven.vector.ShortVector values, int[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ShortVector,long[]) */ public static double wsum( io.deephaven.vector.ShortVector values, long[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ShortVector,short[]) */ public static double wsum( io.deephaven.vector.ShortVector values, short[] weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ShortVector,io.deephaven.vector.ByteVector) */ public static double wsum( io.deephaven.vector.ShortVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ShortVector,io.deephaven.vector.DoubleVector) */ public static double wsum( io.deephaven.vector.ShortVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ShortVector,io.deephaven.vector.FloatVector) */ public static double wsum( io.deephaven.vector.ShortVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ShortVector,io.deephaven.vector.IntVector) */ public static double wsum( io.deephaven.vector.ShortVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ShortVector,io.deephaven.vector.LongVector) */ public static double wsum( io.deephaven.vector.ShortVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wsum(io.deephaven.vector.ShortVector,io.deephaven.vector.ShortVector) */ public static double wsum( io.deephaven.vector.ShortVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wsum( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(byte[],byte[]) */ public static double wtstat( byte[] values, byte[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(byte[],double[]) */ public static double wtstat( byte[] values, double[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(byte[],float[]) */ public static double wtstat( byte[] values, float[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(byte[],int[]) */ public static double wtstat( byte[] values, int[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(byte[],long[]) */ public static double wtstat( byte[] values, long[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(byte[],short[]) */ public static double wtstat( byte[] values, short[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(byte[],io.deephaven.vector.ByteVector) */ public static double wtstat( byte[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(byte[],io.deephaven.vector.DoubleVector) */ public static double wtstat( byte[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(byte[],io.deephaven.vector.FloatVector) */ public static double wtstat( byte[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(byte[],io.deephaven.vector.IntVector) */ public static double wtstat( byte[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(byte[],io.deephaven.vector.LongVector) */ public static double wtstat( byte[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(byte[],io.deephaven.vector.ShortVector) */ public static double wtstat( byte[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(double[],byte[]) */ public static double wtstat( double[] values, byte[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(double[],double[]) */ public static double wtstat( double[] values, double[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(double[],float[]) */ public static double wtstat( double[] values, float[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(double[],int[]) */ public static double wtstat( double[] values, int[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(double[],long[]) */ public static double wtstat( double[] values, long[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(double[],short[]) */ public static double wtstat( double[] values, short[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(double[],io.deephaven.vector.ByteVector) */ public static double wtstat( double[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(double[],io.deephaven.vector.DoubleVector) */ public static double wtstat( double[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(double[],io.deephaven.vector.FloatVector) */ public static double wtstat( double[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(double[],io.deephaven.vector.IntVector) */ public static double wtstat( double[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(double[],io.deephaven.vector.LongVector) */ public static double wtstat( double[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(double[],io.deephaven.vector.ShortVector) */ public static double wtstat( double[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(float[],byte[]) */ public static double wtstat( float[] values, byte[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(float[],double[]) */ public static double wtstat( float[] values, double[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(float[],float[]) */ public static double wtstat( float[] values, float[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(float[],int[]) */ public static double wtstat( float[] values, int[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(float[],long[]) */ public static double wtstat( float[] values, long[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(float[],short[]) */ public static double wtstat( float[] values, short[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(float[],io.deephaven.vector.ByteVector) */ public static double wtstat( float[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(float[],io.deephaven.vector.DoubleVector) */ public static double wtstat( float[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(float[],io.deephaven.vector.FloatVector) */ public static double wtstat( float[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(float[],io.deephaven.vector.IntVector) */ public static double wtstat( float[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(float[],io.deephaven.vector.LongVector) */ public static double wtstat( float[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(float[],io.deephaven.vector.ShortVector) */ public static double wtstat( float[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(int[],byte[]) */ public static double wtstat( int[] values, byte[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(int[],double[]) */ public static double wtstat( int[] values, double[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(int[],float[]) */ public static double wtstat( int[] values, float[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(int[],int[]) */ public static double wtstat( int[] values, int[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(int[],long[]) */ public static double wtstat( int[] values, long[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(int[],short[]) */ public static double wtstat( int[] values, short[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(int[],io.deephaven.vector.ByteVector) */ public static double wtstat( int[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(int[],io.deephaven.vector.DoubleVector) */ public static double wtstat( int[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(int[],io.deephaven.vector.FloatVector) */ public static double wtstat( int[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(int[],io.deephaven.vector.IntVector) */ public static double wtstat( int[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(int[],io.deephaven.vector.LongVector) */ public static double wtstat( int[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(int[],io.deephaven.vector.ShortVector) */ public static double wtstat( int[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(long[],byte[]) */ public static double wtstat( long[] values, byte[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(long[],double[]) */ public static double wtstat( long[] values, double[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(long[],float[]) */ public static double wtstat( long[] values, float[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(long[],int[]) */ public static double wtstat( long[] values, int[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(long[],long[]) */ public static double wtstat( long[] values, long[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(long[],short[]) */ public static double wtstat( long[] values, short[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(long[],io.deephaven.vector.ByteVector) */ public static double wtstat( long[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(long[],io.deephaven.vector.DoubleVector) */ public static double wtstat( long[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(long[],io.deephaven.vector.FloatVector) */ public static double wtstat( long[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(long[],io.deephaven.vector.IntVector) */ public static double wtstat( long[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(long[],io.deephaven.vector.LongVector) */ public static double wtstat( long[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(long[],io.deephaven.vector.ShortVector) */ public static double wtstat( long[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(short[],byte[]) */ public static double wtstat( short[] values, byte[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(short[],double[]) */ public static double wtstat( short[] values, double[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(short[],float[]) */ public static double wtstat( short[] values, float[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(short[],int[]) */ public static double wtstat( short[] values, int[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(short[],long[]) */ public static double wtstat( short[] values, long[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(short[],short[]) */ public static double wtstat( short[] values, short[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(short[],io.deephaven.vector.ByteVector) */ public static double wtstat( short[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(short[],io.deephaven.vector.DoubleVector) */ public static double wtstat( short[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(short[],io.deephaven.vector.FloatVector) */ public static double wtstat( short[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(short[],io.deephaven.vector.IntVector) */ public static double wtstat( short[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(short[],io.deephaven.vector.LongVector) */ public static double wtstat( short[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(short[],io.deephaven.vector.ShortVector) */ public static double wtstat( short[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ByteVector,byte[]) */ public static double wtstat( io.deephaven.vector.ByteVector values, byte[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ByteVector,double[]) */ public static double wtstat( io.deephaven.vector.ByteVector values, double[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ByteVector,float[]) */ public static double wtstat( io.deephaven.vector.ByteVector values, float[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ByteVector,int[]) */ public static double wtstat( io.deephaven.vector.ByteVector values, int[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ByteVector,long[]) */ public static double wtstat( io.deephaven.vector.ByteVector values, long[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ByteVector,short[]) */ public static double wtstat( io.deephaven.vector.ByteVector values, short[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ByteVector,io.deephaven.vector.ByteVector) */ public static double wtstat( io.deephaven.vector.ByteVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ByteVector,io.deephaven.vector.DoubleVector) */ public static double wtstat( io.deephaven.vector.ByteVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ByteVector,io.deephaven.vector.FloatVector) */ public static double wtstat( io.deephaven.vector.ByteVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ByteVector,io.deephaven.vector.IntVector) */ public static double wtstat( io.deephaven.vector.ByteVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ByteVector,io.deephaven.vector.LongVector) */ public static double wtstat( io.deephaven.vector.ByteVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ByteVector,io.deephaven.vector.ShortVector) */ public static double wtstat( io.deephaven.vector.ByteVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.DoubleVector,byte[]) */ public static double wtstat( io.deephaven.vector.DoubleVector values, byte[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.DoubleVector,double[]) */ public static double wtstat( io.deephaven.vector.DoubleVector values, double[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.DoubleVector,float[]) */ public static double wtstat( io.deephaven.vector.DoubleVector values, float[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.DoubleVector,int[]) */ public static double wtstat( io.deephaven.vector.DoubleVector values, int[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.DoubleVector,long[]) */ public static double wtstat( io.deephaven.vector.DoubleVector values, long[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.DoubleVector,short[]) */ public static double wtstat( io.deephaven.vector.DoubleVector values, short[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.DoubleVector,io.deephaven.vector.ByteVector) */ public static double wtstat( io.deephaven.vector.DoubleVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.DoubleVector,io.deephaven.vector.DoubleVector) */ public static double wtstat( io.deephaven.vector.DoubleVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.DoubleVector,io.deephaven.vector.FloatVector) */ public static double wtstat( io.deephaven.vector.DoubleVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.DoubleVector,io.deephaven.vector.IntVector) */ public static double wtstat( io.deephaven.vector.DoubleVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.DoubleVector,io.deephaven.vector.LongVector) */ public static double wtstat( io.deephaven.vector.DoubleVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.DoubleVector,io.deephaven.vector.ShortVector) */ public static double wtstat( io.deephaven.vector.DoubleVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.FloatVector,byte[]) */ public static double wtstat( io.deephaven.vector.FloatVector values, byte[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.FloatVector,double[]) */ public static double wtstat( io.deephaven.vector.FloatVector values, double[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.FloatVector,float[]) */ public static double wtstat( io.deephaven.vector.FloatVector values, float[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.FloatVector,int[]) */ public static double wtstat( io.deephaven.vector.FloatVector values, int[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.FloatVector,long[]) */ public static double wtstat( io.deephaven.vector.FloatVector values, long[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.FloatVector,short[]) */ public static double wtstat( io.deephaven.vector.FloatVector values, short[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.FloatVector,io.deephaven.vector.ByteVector) */ public static double wtstat( io.deephaven.vector.FloatVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.FloatVector,io.deephaven.vector.DoubleVector) */ public static double wtstat( io.deephaven.vector.FloatVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.FloatVector,io.deephaven.vector.FloatVector) */ public static double wtstat( io.deephaven.vector.FloatVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.FloatVector,io.deephaven.vector.IntVector) */ public static double wtstat( io.deephaven.vector.FloatVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.FloatVector,io.deephaven.vector.LongVector) */ public static double wtstat( io.deephaven.vector.FloatVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.FloatVector,io.deephaven.vector.ShortVector) */ public static double wtstat( io.deephaven.vector.FloatVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.IntVector,byte[]) */ public static double wtstat( io.deephaven.vector.IntVector values, byte[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.IntVector,double[]) */ public static double wtstat( io.deephaven.vector.IntVector values, double[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.IntVector,float[]) */ public static double wtstat( io.deephaven.vector.IntVector values, float[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.IntVector,int[]) */ public static double wtstat( io.deephaven.vector.IntVector values, int[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.IntVector,long[]) */ public static double wtstat( io.deephaven.vector.IntVector values, long[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.IntVector,short[]) */ public static double wtstat( io.deephaven.vector.IntVector values, short[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.IntVector,io.deephaven.vector.ByteVector) */ public static double wtstat( io.deephaven.vector.IntVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.IntVector,io.deephaven.vector.DoubleVector) */ public static double wtstat( io.deephaven.vector.IntVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.IntVector,io.deephaven.vector.FloatVector) */ public static double wtstat( io.deephaven.vector.IntVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.IntVector,io.deephaven.vector.IntVector) */ public static double wtstat( io.deephaven.vector.IntVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.IntVector,io.deephaven.vector.LongVector) */ public static double wtstat( io.deephaven.vector.IntVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.IntVector,io.deephaven.vector.ShortVector) */ public static double wtstat( io.deephaven.vector.IntVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.LongVector,byte[]) */ public static double wtstat( io.deephaven.vector.LongVector values, byte[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.LongVector,double[]) */ public static double wtstat( io.deephaven.vector.LongVector values, double[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.LongVector,float[]) */ public static double wtstat( io.deephaven.vector.LongVector values, float[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.LongVector,int[]) */ public static double wtstat( io.deephaven.vector.LongVector values, int[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.LongVector,long[]) */ public static double wtstat( io.deephaven.vector.LongVector values, long[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.LongVector,short[]) */ public static double wtstat( io.deephaven.vector.LongVector values, short[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.LongVector,io.deephaven.vector.ByteVector) */ public static double wtstat( io.deephaven.vector.LongVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.LongVector,io.deephaven.vector.DoubleVector) */ public static double wtstat( io.deephaven.vector.LongVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.LongVector,io.deephaven.vector.FloatVector) */ public static double wtstat( io.deephaven.vector.LongVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.LongVector,io.deephaven.vector.IntVector) */ public static double wtstat( io.deephaven.vector.LongVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.LongVector,io.deephaven.vector.LongVector) */ public static double wtstat( io.deephaven.vector.LongVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.LongVector,io.deephaven.vector.ShortVector) */ public static double wtstat( io.deephaven.vector.LongVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ShortVector,byte[]) */ public static double wtstat( io.deephaven.vector.ShortVector values, byte[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ShortVector,double[]) */ public static double wtstat( io.deephaven.vector.ShortVector values, double[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ShortVector,float[]) */ public static double wtstat( io.deephaven.vector.ShortVector values, float[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ShortVector,int[]) */ public static double wtstat( io.deephaven.vector.ShortVector values, int[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ShortVector,long[]) */ public static double wtstat( io.deephaven.vector.ShortVector values, long[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ShortVector,short[]) */ public static double wtstat( io.deephaven.vector.ShortVector values, short[] weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ShortVector,io.deephaven.vector.ByteVector) */ public static double wtstat( io.deephaven.vector.ShortVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ShortVector,io.deephaven.vector.DoubleVector) */ public static double wtstat( io.deephaven.vector.ShortVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ShortVector,io.deephaven.vector.FloatVector) */ public static double wtstat( io.deephaven.vector.ShortVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ShortVector,io.deephaven.vector.IntVector) */ public static double wtstat( io.deephaven.vector.ShortVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ShortVector,io.deephaven.vector.LongVector) */ public static double wtstat( io.deephaven.vector.ShortVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wtstat(io.deephaven.vector.ShortVector,io.deephaven.vector.ShortVector) */ public static double wtstat( io.deephaven.vector.ShortVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wtstat( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(byte[],byte[]) */ public static double wvar( byte[] values, byte[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(byte[],double[]) */ public static double wvar( byte[] values, double[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(byte[],float[]) */ public static double wvar( byte[] values, float[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(byte[],int[]) */ public static double wvar( byte[] values, int[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(byte[],long[]) */ public static double wvar( byte[] values, long[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(byte[],short[]) */ public static double wvar( byte[] values, short[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(byte[],io.deephaven.vector.ByteVector) */ public static double wvar( byte[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(byte[],io.deephaven.vector.DoubleVector) */ public static double wvar( byte[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(byte[],io.deephaven.vector.FloatVector) */ public static double wvar( byte[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(byte[],io.deephaven.vector.IntVector) */ public static double wvar( byte[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(byte[],io.deephaven.vector.LongVector) */ public static double wvar( byte[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(byte[],io.deephaven.vector.ShortVector) */ public static double wvar( byte[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(double[],byte[]) */ public static double wvar( double[] values, byte[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(double[],double[]) */ public static double wvar( double[] values, double[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(double[],float[]) */ public static double wvar( double[] values, float[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(double[],int[]) */ public static double wvar( double[] values, int[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(double[],long[]) */ public static double wvar( double[] values, long[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(double[],short[]) */ public static double wvar( double[] values, short[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(double[],io.deephaven.vector.ByteVector) */ public static double wvar( double[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(double[],io.deephaven.vector.DoubleVector) */ public static double wvar( double[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(double[],io.deephaven.vector.FloatVector) */ public static double wvar( double[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(double[],io.deephaven.vector.IntVector) */ public static double wvar( double[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(double[],io.deephaven.vector.LongVector) */ public static double wvar( double[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(double[],io.deephaven.vector.ShortVector) */ public static double wvar( double[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(float[],byte[]) */ public static double wvar( float[] values, byte[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(float[],double[]) */ public static double wvar( float[] values, double[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(float[],float[]) */ public static double wvar( float[] values, float[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(float[],int[]) */ public static double wvar( float[] values, int[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(float[],long[]) */ public static double wvar( float[] values, long[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(float[],short[]) */ public static double wvar( float[] values, short[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(float[],io.deephaven.vector.ByteVector) */ public static double wvar( float[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(float[],io.deephaven.vector.DoubleVector) */ public static double wvar( float[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(float[],io.deephaven.vector.FloatVector) */ public static double wvar( float[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(float[],io.deephaven.vector.IntVector) */ public static double wvar( float[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(float[],io.deephaven.vector.LongVector) */ public static double wvar( float[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(float[],io.deephaven.vector.ShortVector) */ public static double wvar( float[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(int[],byte[]) */ public static double wvar( int[] values, byte[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(int[],double[]) */ public static double wvar( int[] values, double[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(int[],float[]) */ public static double wvar( int[] values, float[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(int[],int[]) */ public static double wvar( int[] values, int[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(int[],long[]) */ public static double wvar( int[] values, long[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(int[],short[]) */ public static double wvar( int[] values, short[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(int[],io.deephaven.vector.ByteVector) */ public static double wvar( int[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(int[],io.deephaven.vector.DoubleVector) */ public static double wvar( int[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(int[],io.deephaven.vector.FloatVector) */ public static double wvar( int[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(int[],io.deephaven.vector.IntVector) */ public static double wvar( int[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(int[],io.deephaven.vector.LongVector) */ public static double wvar( int[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(int[],io.deephaven.vector.ShortVector) */ public static double wvar( int[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(long[],byte[]) */ public static double wvar( long[] values, byte[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(long[],double[]) */ public static double wvar( long[] values, double[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(long[],float[]) */ public static double wvar( long[] values, float[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(long[],int[]) */ public static double wvar( long[] values, int[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(long[],long[]) */ public static double wvar( long[] values, long[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(long[],short[]) */ public static double wvar( long[] values, short[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(long[],io.deephaven.vector.ByteVector) */ public static double wvar( long[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(long[],io.deephaven.vector.DoubleVector) */ public static double wvar( long[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(long[],io.deephaven.vector.FloatVector) */ public static double wvar( long[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(long[],io.deephaven.vector.IntVector) */ public static double wvar( long[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(long[],io.deephaven.vector.LongVector) */ public static double wvar( long[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(long[],io.deephaven.vector.ShortVector) */ public static double wvar( long[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(short[],byte[]) */ public static double wvar( short[] values, byte[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(short[],double[]) */ public static double wvar( short[] values, double[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(short[],float[]) */ public static double wvar( short[] values, float[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(short[],int[]) */ public static double wvar( short[] values, int[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(short[],long[]) */ public static double wvar( short[] values, long[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(short[],short[]) */ public static double wvar( short[] values, short[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(short[],io.deephaven.vector.ByteVector) */ public static double wvar( short[] values, io.deephaven.vector.ByteVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(short[],io.deephaven.vector.DoubleVector) */ public static double wvar( short[] values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(short[],io.deephaven.vector.FloatVector) */ public static double wvar( short[] values, io.deephaven.vector.FloatVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(short[],io.deephaven.vector.IntVector) */ public static double wvar( short[] values, io.deephaven.vector.IntVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(short[],io.deephaven.vector.LongVector) */ public static double wvar( short[] values, io.deephaven.vector.LongVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(short[],io.deephaven.vector.ShortVector) */ public static double wvar( short[] values, io.deephaven.vector.ShortVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ByteVector,byte[]) */ public static double wvar( io.deephaven.vector.ByteVector values, byte[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ByteVector,double[]) */ public static double wvar( io.deephaven.vector.ByteVector values, double[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ByteVector,float[]) */ public static double wvar( io.deephaven.vector.ByteVector values, float[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ByteVector,int[]) */ public static double wvar( io.deephaven.vector.ByteVector values, int[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ByteVector,long[]) */ public static double wvar( io.deephaven.vector.ByteVector values, long[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ByteVector,short[]) */ public static double wvar( io.deephaven.vector.ByteVector values, short[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ByteVector,io.deephaven.vector.ByteVector) */ public static double wvar( io.deephaven.vector.ByteVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ByteVector,io.deephaven.vector.DoubleVector) */ public static double wvar( io.deephaven.vector.ByteVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ByteVector,io.deephaven.vector.FloatVector) */ public static double wvar( io.deephaven.vector.ByteVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ByteVector,io.deephaven.vector.IntVector) */ public static double wvar( io.deephaven.vector.ByteVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ByteVector,io.deephaven.vector.LongVector) */ public static double wvar( io.deephaven.vector.ByteVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ByteVector,io.deephaven.vector.ShortVector) */ public static double wvar( io.deephaven.vector.ByteVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.DoubleVector,byte[]) */ public static double wvar( io.deephaven.vector.DoubleVector values, byte[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.DoubleVector,double[]) */ public static double wvar( io.deephaven.vector.DoubleVector values, double[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.DoubleVector,float[]) */ public static double wvar( io.deephaven.vector.DoubleVector values, float[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.DoubleVector,int[]) */ public static double wvar( io.deephaven.vector.DoubleVector values, int[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.DoubleVector,long[]) */ public static double wvar( io.deephaven.vector.DoubleVector values, long[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.DoubleVector,short[]) */ public static double wvar( io.deephaven.vector.DoubleVector values, short[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.DoubleVector,io.deephaven.vector.ByteVector) */ public static double wvar( io.deephaven.vector.DoubleVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.DoubleVector,io.deephaven.vector.DoubleVector) */ public static double wvar( io.deephaven.vector.DoubleVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.DoubleVector,io.deephaven.vector.FloatVector) */ public static double wvar( io.deephaven.vector.DoubleVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.DoubleVector,io.deephaven.vector.IntVector) */ public static double wvar( io.deephaven.vector.DoubleVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.DoubleVector,io.deephaven.vector.LongVector) */ public static double wvar( io.deephaven.vector.DoubleVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.DoubleVector,io.deephaven.vector.ShortVector) */ public static double wvar( io.deephaven.vector.DoubleVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.FloatVector,byte[]) */ public static double wvar( io.deephaven.vector.FloatVector values, byte[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.FloatVector,double[]) */ public static double wvar( io.deephaven.vector.FloatVector values, double[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.FloatVector,float[]) */ public static double wvar( io.deephaven.vector.FloatVector values, float[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.FloatVector,int[]) */ public static double wvar( io.deephaven.vector.FloatVector values, int[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.FloatVector,long[]) */ public static double wvar( io.deephaven.vector.FloatVector values, long[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.FloatVector,short[]) */ public static double wvar( io.deephaven.vector.FloatVector values, short[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.FloatVector,io.deephaven.vector.ByteVector) */ public static double wvar( io.deephaven.vector.FloatVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.FloatVector,io.deephaven.vector.DoubleVector) */ public static double wvar( io.deephaven.vector.FloatVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.FloatVector,io.deephaven.vector.FloatVector) */ public static double wvar( io.deephaven.vector.FloatVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.FloatVector,io.deephaven.vector.IntVector) */ public static double wvar( io.deephaven.vector.FloatVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.FloatVector,io.deephaven.vector.LongVector) */ public static double wvar( io.deephaven.vector.FloatVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.FloatVector,io.deephaven.vector.ShortVector) */ public static double wvar( io.deephaven.vector.FloatVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.IntVector,byte[]) */ public static double wvar( io.deephaven.vector.IntVector values, byte[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.IntVector,double[]) */ public static double wvar( io.deephaven.vector.IntVector values, double[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.IntVector,float[]) */ public static double wvar( io.deephaven.vector.IntVector values, float[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.IntVector,int[]) */ public static double wvar( io.deephaven.vector.IntVector values, int[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.IntVector,long[]) */ public static double wvar( io.deephaven.vector.IntVector values, long[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.IntVector,short[]) */ public static double wvar( io.deephaven.vector.IntVector values, short[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.IntVector,io.deephaven.vector.ByteVector) */ public static double wvar( io.deephaven.vector.IntVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.IntVector,io.deephaven.vector.DoubleVector) */ public static double wvar( io.deephaven.vector.IntVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.IntVector,io.deephaven.vector.FloatVector) */ public static double wvar( io.deephaven.vector.IntVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.IntVector,io.deephaven.vector.IntVector) */ public static double wvar( io.deephaven.vector.IntVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.IntVector,io.deephaven.vector.LongVector) */ public static double wvar( io.deephaven.vector.IntVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.IntVector,io.deephaven.vector.ShortVector) */ public static double wvar( io.deephaven.vector.IntVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.LongVector,byte[]) */ public static double wvar( io.deephaven.vector.LongVector values, byte[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.LongVector,double[]) */ public static double wvar( io.deephaven.vector.LongVector values, double[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.LongVector,float[]) */ public static double wvar( io.deephaven.vector.LongVector values, float[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.LongVector,int[]) */ public static double wvar( io.deephaven.vector.LongVector values, int[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.LongVector,long[]) */ public static double wvar( io.deephaven.vector.LongVector values, long[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.LongVector,short[]) */ public static double wvar( io.deephaven.vector.LongVector values, short[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.LongVector,io.deephaven.vector.ByteVector) */ public static double wvar( io.deephaven.vector.LongVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.LongVector,io.deephaven.vector.DoubleVector) */ public static double wvar( io.deephaven.vector.LongVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.LongVector,io.deephaven.vector.FloatVector) */ public static double wvar( io.deephaven.vector.LongVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.LongVector,io.deephaven.vector.IntVector) */ public static double wvar( io.deephaven.vector.LongVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.LongVector,io.deephaven.vector.LongVector) */ public static double wvar( io.deephaven.vector.LongVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.LongVector,io.deephaven.vector.ShortVector) */ public static double wvar( io.deephaven.vector.LongVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ShortVector,byte[]) */ public static double wvar( io.deephaven.vector.ShortVector values, byte[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ShortVector,double[]) */ public static double wvar( io.deephaven.vector.ShortVector values, double[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ShortVector,float[]) */ public static double wvar( io.deephaven.vector.ShortVector values, float[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ShortVector,int[]) */ public static double wvar( io.deephaven.vector.ShortVector values, int[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ShortVector,long[]) */ public static double wvar( io.deephaven.vector.ShortVector values, long[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ShortVector,short[]) */ public static double wvar( io.deephaven.vector.ShortVector values, short[] weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ShortVector,io.deephaven.vector.ByteVector) */ public static double wvar( io.deephaven.vector.ShortVector values, io.deephaven.vector.ByteVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ShortVector,io.deephaven.vector.DoubleVector) */ public static double wvar( io.deephaven.vector.ShortVector values, io.deephaven.vector.DoubleVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ShortVector,io.deephaven.vector.FloatVector) */ public static double wvar( io.deephaven.vector.ShortVector values, io.deephaven.vector.FloatVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ShortVector,io.deephaven.vector.IntVector) */ public static double wvar( io.deephaven.vector.ShortVector values, io.deephaven.vector.IntVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ShortVector,io.deephaven.vector.LongVector) */ public static double wvar( io.deephaven.vector.ShortVector values, io.deephaven.vector.LongVector weights ) {return Numeric.wvar( values, weights );} + /** @see io.deephaven.function.Numeric#wvar(io.deephaven.vector.ShortVector,io.deephaven.vector.ShortVector) */ public static double wvar( io.deephaven.vector.ShortVector values, io.deephaven.vector.ShortVector weights ) {return Numeric.wvar( values, weights );} + } From 7d915b672033d061bbde896245b09584cd07605e Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Fri, 3 Nov 2023 09:47:43 -0600 Subject: [PATCH 059/150] Refactoring code gen. Not fully working. --- .../java/io/deephaven/plot/util/GenerateFigureImmutable.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java b/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java index 47cc32c8ecf..82b33efc57c 100644 --- a/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java +++ b/Generators/src/main/java/io/deephaven/plot/util/GenerateFigureImmutable.java @@ -651,7 +651,7 @@ private String createFunction(final JavaFunction f) { String funcBody; if (isInterface) { - sigPrefix = "@Override "; + sigPrefix = "@Override"; funcBody = ";\n"; } else { final String callArgs = GenUtils.argString(f, false); From 15fc1f975c35946ce6422390ba0eb934fafbb807 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Fri, 3 Nov 2023 10:06:34 -0600 Subject: [PATCH 060/150] Figure interface --- .../main/java/io/deephaven/plot/Figure.java | 320 +++++++++--------- 1 file changed, 160 insertions(+), 160 deletions(-) diff --git a/Plot/src/main/java/io/deephaven/plot/Figure.java b/Plot/src/main/java/io/deephaven/plot/Figure.java index b88826dc4c9..26184c424b4 100644 --- a/Plot/src/main/java/io/deephaven/plot/Figure.java +++ b/Plot/src/main/java/io/deephaven/plot/Figure.java @@ -963,291 +963,291 @@ public interface Figure extends io.deephaven.plot.BaseFigure, io.deephaven.plot. @Override Figure errorBarColor( int errorBarColor ); - @Override Figure errorBarColor( int errorBarColor, java.lang.Object... multiSeriesKey ); - @Override Figure errorBarColor( io.deephaven.gui.color.Paint errorBarColor ); - @Override Figure errorBarColor( io.deephaven.gui.color.Paint errorBarColor, java.lang.Object... multiSeriesKey ); - @Override Figure errorBarColor( java.lang.String errorBarColor ); - @Override Figure errorBarColor( java.lang.String errorBarColor, java.lang.Object... multiSeriesKey ); + @Override Figure gradientVisible( boolean gradientVisible ); - @Override Figure funcNPoints( int npoints ); + @Override Figure lineColor( int color ); - @Override Figure funcRange( double xmin, double xmax ); + @Override Figure lineColor( io.deephaven.gui.color.Paint color ); - @Override Figure funcRange( double xmin, double xmax, int npoints ); + @Override Figure lineColor( java.lang.String color ); - @Override Figure gradientVisible( boolean gradientVisible ); + @Override Figure lineStyle( io.deephaven.plot.LineStyle lineStyle ); - @Override Figure gradientVisible( boolean gradientVisible, java.lang.Object... multiSeriesKey ); + @Override Figure linesVisible( java.lang.Boolean visible ); - @Override Figure group( int group ); + @Override Figure pointColor( int pointColor ); - @Override Figure group( int group, java.lang.Object... multiSeriesKey ); + @Override Figure pointColor( io.deephaven.gui.color.Paint pointColor ); - @Override Figure lineColor( int color ); + @Override Figure pointColor( java.lang.String pointColor ); - @Override Figure lineColor( int color, java.lang.Object... multiSeriesKey ); + @Override Figure pointLabel( java.lang.Object pointLabel ); - @Override Figure lineColor( io.deephaven.gui.color.Paint color ); + @Override Figure pointLabelFormat( java.lang.String pointLabelFormat ); - @Override Figure lineColor( io.deephaven.gui.color.Paint color, java.lang.Object... multiSeriesKey ); + @Override Figure pointShape( io.deephaven.gui.shape.Shape pointShape ); - @Override Figure lineColor( java.lang.String color ); + @Override Figure pointShape( java.lang.String pointShape ); - @Override Figure lineColor( java.lang.String color, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( double pointSize ); - @Override Figure lineStyle( io.deephaven.plot.LineStyle lineStyle ); + @Override Figure pointSize( int pointSize ); - @Override Figure lineStyle( io.deephaven.plot.LineStyle lineStyle, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( java.lang.Number pointSize ); - @Override Figure linesVisible( java.lang.Boolean visible ); + @Override Figure pointSize( long pointSize ); - @Override Figure linesVisible( java.lang.Boolean visible, java.lang.Object... multiSeriesKey ); + @Override Figure pointsVisible( java.lang.Boolean visible ); - @Override Figure piePercentLabelFormat( java.lang.String pieLabelFormat ); + @Override Figure seriesColor( int color ); - @Override Figure piePercentLabelFormat( java.lang.String pieLabelFormat, java.lang.Object... multiSeriesKey ); + @Override Figure seriesColor( io.deephaven.gui.color.Paint color ); - @Override Figure pointColor( int pointColor ); + @Override Figure seriesColor( java.lang.String color ); - @Override Figure pointColor( int pointColor, java.lang.Object... multiSeriesKey ); + @Override Figure toolTipPattern( java.lang.String toolTipPattern ); - @Override Figure pointColor( int... pointColors ); + @Override Figure xToolTipPattern( java.lang.String xToolTipPattern ); - @Override Figure pointColor( int[] pointColors, java.lang.Object... multiSeriesKey ); + @Override Figure yToolTipPattern( java.lang.String yToolTipPattern ); + + @Override Figure group( int group ); + + @Override Figure piePercentLabelFormat( java.lang.String pieLabelFormat ); @Override Figure pointColor( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointColor ); - @Override Figure pointColor( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointColor, java.lang.Object... multiSeriesKey ); + @Override Figure pointColor( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointColor ); - @Override Figure pointColor( io.deephaven.engine.table.Table t, java.lang.String pointColors ); + @Override Figure pointColor( java.lang.Comparable category, int pointColor ); - @Override Figure pointColor( io.deephaven.engine.table.Table t, java.lang.String pointColors, java.lang.Object... multiSeriesKey ); + @Override Figure pointColor( java.lang.Comparable category, io.deephaven.gui.color.Paint pointColor ); - @Override Figure pointColor( io.deephaven.gui.color.Paint pointColor ); + @Override Figure pointColor( java.lang.Comparable category, java.lang.String pointColor ); - @Override Figure pointColor( io.deephaven.gui.color.Paint pointColor, java.lang.Object... multiSeriesKey ); + @Override Figure pointLabel( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointLabel ); - @Override Figure pointColor( io.deephaven.gui.color.Paint... pointColor ); + @Override Figure pointLabel( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointLabel ); - @Override Figure pointColor( io.deephaven.gui.color.Paint[] pointColor, java.lang.Object... multiSeriesKey ); + @Override Figure pointLabel( java.lang.Comparable category, java.lang.Object pointLabel ); - @Override Figure pointColor( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointColor ); + @Override Figure pointShape( groovy.lang.Closure pointShapes ); - @Override Figure pointColor( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointColor, java.lang.Object... multiSeriesKey ); + @Override Figure pointShape( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointShape ); - @Override Figure pointColor( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointColors ); + @Override Figure pointShape( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointShape ); - @Override Figure pointColor( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointColors, java.lang.Object... multiSeriesKey ); + @Override Figure pointShape( java.lang.Comparable category, io.deephaven.gui.shape.Shape pointShape ); - @Override Figure pointColor( java.lang.Comparable category, int pointColor ); + @Override Figure pointShape( java.lang.Comparable category, java.lang.String pointShape ); - @Override Figure pointColor( java.lang.Comparable category, int pointColor, java.lang.Object... multiSeriesKey ); + @Override Figure pointShape( java.util.function.Function pointShapes ); - @Override Figure pointColor( java.lang.Comparable category, io.deephaven.gui.color.Paint pointColor ); + @Override Figure pointSize( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointSize ); - @Override Figure pointColor( java.lang.Comparable category, io.deephaven.gui.color.Paint pointColor, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointSize ); - @Override Figure pointColor( java.lang.Comparable category, java.lang.String pointColor ); + @Override Figure pointSize( java.lang.Comparable category, double pointSize ); - @Override Figure pointColor( java.lang.Comparable category, java.lang.String pointColor, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( java.lang.Comparable category, int pointSize ); - @Override Figure pointColor( java.lang.Integer... pointColors ); + @Override Figure pointSize( java.lang.Comparable category, java.lang.Number pointSize ); - @Override Figure pointColor( java.lang.Integer[] pointColors, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( java.lang.Comparable category, long pointSize ); - @Override Figure pointColor( java.lang.String pointColor ); + @Override Figure errorBarColor( int errorBarColor, java.lang.Object... multiSeriesKey ); - @Override Figure pointColor( java.lang.String pointColor, java.lang.Object... multiSeriesKey ); + @Override Figure errorBarColor( io.deephaven.gui.color.Paint errorBarColor, java.lang.Object... multiSeriesKey ); - @Override Figure pointColor( java.lang.String... pointColors ); + @Override Figure errorBarColor( java.lang.String errorBarColor, java.lang.Object... multiSeriesKey ); - @Override Figure pointColor( java.lang.String[] pointColors, java.lang.Object... multiSeriesKey ); + @Override Figure gradientVisible( boolean gradientVisible, java.lang.Object... multiSeriesKey ); - @Override Figure pointColorInteger( io.deephaven.plot.datasets.data.IndexableData colors ); + @Override Figure group( int group, java.lang.Object... multiSeriesKey ); - @Override Figure pointColorInteger( io.deephaven.plot.datasets.data.IndexableData colors, java.lang.Object... multiSeriesKey ); + @Override Figure lineColor( int color, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointLabel ); + @Override Figure lineColor( io.deephaven.gui.color.Paint color, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointLabel, java.lang.Object... multiSeriesKey ); + @Override Figure lineColor( java.lang.String color, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( io.deephaven.engine.table.Table t, java.lang.String pointLabel ); + @Override Figure lineStyle( io.deephaven.plot.LineStyle lineStyle, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( io.deephaven.engine.table.Table t, java.lang.String pointLabel, java.lang.Object... multiSeriesKey ); + @Override Figure linesVisible( java.lang.Boolean visible, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( io.deephaven.plot.datasets.data.IndexableData pointLabels ); + @Override Figure piePercentLabelFormat( java.lang.String pieLabelFormat, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( io.deephaven.plot.datasets.data.IndexableData pointLabels, java.lang.Object... multiSeriesKey ); + @Override Figure pointColor( int pointColor, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointLabel ); + @Override Figure pointColor( int[] pointColors, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointLabel, java.lang.Object... multiSeriesKey ); + @Override Figure pointColor( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointColor, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointLabel ); + @Override Figure pointColor( io.deephaven.engine.table.Table t, java.lang.String pointColors, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointLabel, java.lang.Object... multiSeriesKey ); + @Override Figure pointColor( io.deephaven.gui.color.Paint pointColor, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( java.lang.Comparable category, java.lang.Object pointLabel ); + @Override Figure pointColor( io.deephaven.gui.color.Paint[] pointColor, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( java.lang.Comparable category, java.lang.Object pointLabel, java.lang.Object... multiSeriesKey ); + @Override Figure pointColor( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointColor, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( java.lang.Object pointLabel ); + @Override Figure pointColor( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointColors, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( java.lang.Object pointLabel, java.lang.Object... multiSeriesKey ); + @Override Figure pointColor( java.lang.Comparable category, int pointColor, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( java.lang.Object... pointLabels ); + @Override Figure pointColor( java.lang.Comparable category, io.deephaven.gui.color.Paint pointColor, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabel( java.lang.Object[] pointLabels, java.lang.Object... multiSeriesKey ); + @Override Figure pointColor( java.lang.Comparable category, java.lang.String pointColor, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabelFormat( java.lang.String pointLabelFormat ); + @Override Figure pointColor( java.lang.Integer[] pointColors, java.lang.Object... multiSeriesKey ); - @Override Figure pointLabelFormat( java.lang.String pointLabelFormat, java.lang.Object... multiSeriesKey ); + @Override Figure pointColor( java.lang.String pointColor, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( groovy.lang.Closure pointShapes ); + @Override Figure pointColor( java.lang.String[] pointColors, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( groovy.lang.Closure pointShapes, java.lang.Object... multiSeriesKey ); + @Override Figure pointColorInteger( io.deephaven.plot.datasets.data.IndexableData colors, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointShape ); + @Override Figure pointLabel( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointLabel, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointShape, java.lang.Object... multiSeriesKey ); + @Override Figure pointLabel( io.deephaven.engine.table.Table t, java.lang.String pointLabel, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.engine.table.Table t, java.lang.String pointShape ); + @Override Figure pointLabel( io.deephaven.plot.datasets.data.IndexableData pointLabels, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.engine.table.Table t, java.lang.String pointShape, java.lang.Object... multiSeriesKey ); + @Override Figure pointLabel( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointLabel, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.gui.shape.Shape pointShape ); + @Override Figure pointLabel( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointLabel, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.gui.shape.Shape pointShape, java.lang.Object... multiSeriesKey ); + @Override Figure pointLabel( java.lang.Comparable category, java.lang.Object pointLabel, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.gui.shape.Shape... pointShapes ); + @Override Figure pointLabel( java.lang.Object pointLabel, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.gui.shape.Shape[] pointShapes, java.lang.Object... multiSeriesKey ); + @Override Figure pointLabel( java.lang.Object[] pointLabels, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.plot.datasets.data.IndexableData pointShapes ); + @Override Figure pointLabelFormat( java.lang.String pointLabelFormat, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.plot.datasets.data.IndexableData pointShapes, java.lang.Object... multiSeriesKey ); + @Override Figure pointShape( groovy.lang.Closure pointShapes, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointShape ); + @Override Figure pointShape( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointShape, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointShape, java.lang.Object... multiSeriesKey ); + @Override Figure pointShape( io.deephaven.engine.table.Table t, java.lang.String pointShape, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointShape ); + @Override Figure pointShape( io.deephaven.gui.shape.Shape pointShape, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointShape, java.lang.Object... multiSeriesKey ); + @Override Figure pointShape( io.deephaven.gui.shape.Shape[] pointShapes, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( java.lang.Comparable category, io.deephaven.gui.shape.Shape pointShape ); + @Override Figure pointShape( io.deephaven.plot.datasets.data.IndexableData pointShapes, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( java.lang.Comparable category, io.deephaven.gui.shape.Shape pointShape, java.lang.Object... multiSeriesKey ); + @Override Figure pointShape( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointShape, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( java.lang.Comparable category, java.lang.String pointShape ); + @Override Figure pointShape( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointShape, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( java.lang.Comparable category, java.lang.String pointShape, java.lang.Object... multiSeriesKey ); + @Override Figure pointShape( java.lang.Comparable category, io.deephaven.gui.shape.Shape pointShape, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( java.lang.String pointShape ); + @Override Figure pointShape( java.lang.Comparable category, java.lang.String pointShape, java.lang.Object... multiSeriesKey ); @Override Figure pointShape( java.lang.String pointShape, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( java.lang.String... pointShapes ); - @Override Figure pointShape( java.lang.String[] pointShapes, java.lang.Object... multiSeriesKey ); - @Override Figure pointShape( java.util.function.Function pointShapes ); - @Override Figure pointShape( java.util.function.Function pointShapes, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( double pointSize ); + @Override Figure pointSize( double[] pointSizes, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( double... pointSizes ); + @Override Figure pointSize( int[] pointSizes, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( double[] pointSizes, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointSize, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( int pointSize ); + @Override Figure pointSize( io.deephaven.engine.table.Table t, java.lang.String pointSizes, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( int... pointSizes ); + @Override Figure pointSize( io.deephaven.plot.datasets.data.IndexableData pointSizes, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( int[] pointSizes, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointSize, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointSize ); + @Override Figure pointSize( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointSize, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( io.deephaven.engine.table.Table t, java.lang.String category, java.lang.String pointSize, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( java.lang.Comparable category, double pointSize, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( io.deephaven.engine.table.Table t, java.lang.String pointSizes ); + @Override Figure pointSize( java.lang.Comparable category, int pointSize, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( io.deephaven.engine.table.Table t, java.lang.String pointSizes, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( java.lang.Comparable category, java.lang.Number pointSize, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( io.deephaven.plot.datasets.data.IndexableData pointSizes ); + @Override Figure pointSize( java.lang.Comparable category, long pointSize, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( io.deephaven.plot.datasets.data.IndexableData pointSizes, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( java.lang.Number pointSize, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointSize ); + @Override Figure pointSize( long[] pointSizes, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String category, java.lang.String pointSize, java.lang.Object... multiSeriesKey ); + @Override Figure pointsVisible( java.lang.Boolean visible, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointSize ); + @Override Figure seriesColor( int color, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointSize, java.lang.Object... multiSeriesKey ); + @Override Figure seriesColor( io.deephaven.gui.color.Paint color, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( java.lang.Comparable category, double pointSize ); + @Override Figure seriesColor( java.lang.String color, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( java.lang.Comparable category, double pointSize, java.lang.Object... multiSeriesKey ); + @Override Figure seriesNamingFunction( groovy.lang.Closure namingFunction ); - @Override Figure pointSize( java.lang.Comparable category, int pointSize ); + @Override Figure seriesNamingFunction( java.util.function.Function namingFunction ); - @Override Figure pointSize( java.lang.Comparable category, int pointSize, java.lang.Object... multiSeriesKey ); + @Override Figure toolTipPattern( java.lang.String toolTipPattern, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( java.lang.Comparable category, java.lang.Number pointSize ); + @Override Figure xToolTipPattern( java.lang.String xToolTipPattern, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( java.lang.Comparable category, java.lang.Number pointSize, java.lang.Object... multiSeriesKey ); + @Override Figure yToolTipPattern( java.lang.String yToolTipPattern, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( java.lang.Comparable category, long pointSize ); + @Override Figure pointColor( int... pointColors ); - @Override Figure pointSize( java.lang.Comparable category, long pointSize, java.lang.Object... multiSeriesKey ); + @Override Figure pointColor( io.deephaven.engine.table.Table t, java.lang.String pointColors ); - @Override Figure pointSize( java.lang.Number pointSize ); + @Override Figure pointColor( io.deephaven.gui.color.Paint... pointColor ); - @Override Figure pointSize( java.lang.Number pointSize, java.lang.Object... multiSeriesKey ); + @Override Figure pointColor( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointColors ); - @Override Figure pointSize( long pointSize ); + @Override Figure pointColor( java.lang.Integer... pointColors ); - @Override Figure pointSize( long... pointSizes ); + @Override Figure pointColor( java.lang.String... pointColors ); - @Override Figure pointSize( long[] pointSizes, java.lang.Object... multiSeriesKey ); + @Override Figure pointColorInteger( io.deephaven.plot.datasets.data.IndexableData colors ); - @Override Figure pointsVisible( java.lang.Boolean visible ); + @Override Figure pointLabel( io.deephaven.engine.table.Table t, java.lang.String pointLabel ); - @Override Figure pointsVisible( java.lang.Boolean visible, java.lang.Object... multiSeriesKey ); + @Override Figure pointLabel( io.deephaven.plot.datasets.data.IndexableData pointLabels ); - @Override Figure seriesColor( int color ); + @Override Figure pointLabel( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointLabel ); - @Override Figure seriesColor( int color, java.lang.Object... multiSeriesKey ); + @Override Figure pointLabel( java.lang.Object... pointLabels ); - @Override Figure seriesColor( io.deephaven.gui.color.Paint color ); + @Override Figure pointShape( io.deephaven.engine.table.Table t, java.lang.String pointShape ); - @Override Figure seriesColor( io.deephaven.gui.color.Paint color, java.lang.Object... multiSeriesKey ); + @Override Figure pointShape( io.deephaven.gui.shape.Shape... pointShapes ); - @Override Figure seriesColor( java.lang.String color ); + @Override Figure pointShape( io.deephaven.plot.datasets.data.IndexableData pointShapes ); - @Override Figure seriesColor( java.lang.String color, java.lang.Object... multiSeriesKey ); + @Override Figure pointShape( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointShape ); - @Override Figure seriesNamingFunction( groovy.lang.Closure namingFunction ); + @Override Figure pointShape( java.lang.String... pointShapes ); - @Override Figure seriesNamingFunction( java.util.function.Function namingFunction ); + @Override Figure pointSize( double... pointSizes ); - @Override Figure toolTipPattern( java.lang.String toolTipPattern ); + @Override Figure pointSize( int... pointSizes ); - @Override Figure toolTipPattern( java.lang.String toolTipPattern, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( io.deephaven.engine.table.Table t, java.lang.String pointSizes ); - @Override Figure xToolTipPattern( java.lang.String xToolTipPattern ); + @Override Figure pointSize( io.deephaven.plot.datasets.data.IndexableData pointSizes ); - @Override Figure xToolTipPattern( java.lang.String xToolTipPattern, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( io.deephaven.plot.filters.SelectableDataSet sds, java.lang.String pointSize ); - @Override Figure yToolTipPattern( java.lang.String yToolTipPattern ); + @Override Figure pointSize( long... pointSizes ); - @Override Figure yToolTipPattern( java.lang.String yToolTipPattern, java.lang.Object... multiSeriesKey ); + @Override Figure funcNPoints( int npoints ); + + @Override Figure funcRange( double xmin, double xmax ); + + @Override Figure funcRange( double xmin, double xmax, int npoints ); @Override Figure pointColor( java.util.Map pointColor ); @@ -1263,67 +1263,67 @@ public interface Figure extends io.deephaven.plot.BaseFigure, io.deephaven.plot. @Override Figure pointSize( CATEGORY[] categories, NUMBER[] pointSizes ); - @Override Figure pointSize( CATEGORY[] categories, NUMBER[] pointSizes, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( java.util.Map pointSizes ); + @Override Figure pointSize( CATEGORY[] categories, NUMBER[] pointSizes, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( java.util.Map pointSizes, java.lang.Object... multiSeriesKey ); @Override Figure pointShape( java.util.Map pointShapes ); - @Override Figure pointShape( java.util.Map pointShapes, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( CATEGORY[] categories, double[] pointSizes ); - @Override Figure pointSize( CATEGORY[] categories, double[] pointSizes, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( CATEGORY[] categories, int[] pointSizes ); - @Override Figure pointSize( CATEGORY[] categories, int[] pointSizes, java.lang.Object... multiSeriesKey ); - @Override Figure pointSize( CATEGORY[] categories, long[] pointSizes ); + @Override Figure pointShape( java.util.Map pointShapes, java.lang.Object... multiSeriesKey ); + + @Override Figure pointSize( CATEGORY[] categories, double[] pointSizes, java.lang.Object... multiSeriesKey ); + + @Override Figure pointSize( CATEGORY[] categories, int[] pointSizes, java.lang.Object... multiSeriesKey ); + @Override Figure pointSize( CATEGORY[] categories, long[] pointSizes, java.lang.Object... multiSeriesKey ); @Override Figure pointColor( groovy.lang.Closure pointColor ); - @Override Figure pointColor( groovy.lang.Closure pointColor, java.lang.Object... multiSeriesKey ); - @Override Figure pointColor( java.util.function.Function pointColor ); + @Override Figure pointColor( groovy.lang.Closure pointColor, java.lang.Object... multiSeriesKey ); + @Override Figure pointColor( java.util.function.Function pointColor, java.lang.Object... multiSeriesKey ); @Override Figure pointColorInteger( groovy.lang.Closure colors ); - @Override Figure pointColorInteger( groovy.lang.Closure colors, java.lang.Object... multiSeriesKey ); - @Override Figure pointColorInteger( java.util.function.Function colors ); + @Override Figure pointColorInteger( groovy.lang.Closure colors, java.lang.Object... multiSeriesKey ); + @Override Figure pointColorInteger( java.util.function.Function colors, java.lang.Object... multiSeriesKey ); @Override