From edc39e003c036ed9ea76ce1a13a764be34545a71 Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Mon, 6 Nov 2023 14:52:27 -0700 Subject: [PATCH] spotless --- .../java/io/deephaven/time/DateTimeUtils.java | 1 - .../io/deephaven/time/calendar/Calendars.java | 6 ++- .../calendar/TestBusinessCalendarParser.java | 15 ++++--- .../time/calendar/TestCalendars.java | 7 +-- .../calendar/TestStaticCalendarMethods.java | 43 +++++++++++-------- 5 files changed, 41 insertions(+), 31 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 86ae5b9e4f0..5a4b483c452 100644 --- a/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java +++ b/engine/time/src/main/java/io/deephaven/time/DateTimeUtils.java @@ -2942,7 +2942,6 @@ public static ZonedDateTime atMidnight(@Nullable final LocalDate date, @Nullable 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/main/java/io/deephaven/time/calendar/Calendars.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java index 1c8f660b5bb..8bcb8024f23 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 @@ -188,7 +188,8 @@ public synchronized static BusinessCalendar calendar(final String name) { /** * Returns the default business calendar. * - * @return default business calendar. The default is specified by the {@code Calendar.default} property or {@link #setDefaultCalendar(String)}. + * @return default business calendar. The default is specified by the {@code Calendar.default} property or + * {@link #setDefaultCalendar(String)}. */ public synchronized static BusinessCalendar calendar() { return calendar(defaultName); @@ -197,7 +198,8 @@ public synchronized static BusinessCalendar calendar() { /** * Returns the default business calendar name. * - * @return default business calendar name. The default is specified by the {@code Calendar.default} property or {@link #setDefaultCalendar(String)}. + * @return default business calendar name. The default is specified by the {@code Calendar.default} property or + * {@link #setDefaultCalendar(String)}. */ public synchronized static String calendarName() { return defaultName; diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendarParser.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendarParser.java index 285916d4bb8..25b8fc7bd8f 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendarParser.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestBusinessCalendarParser.java @@ -19,22 +19,25 @@ public static void assertParserTestCal(final BusinessCalendar cal) { assertEquals(DateTimeUtils.timeZone("Asia/Tokyo"), cal.timeZone()); assertEquals(LocalDate.of(2000, 1, 2), cal.firstValidDate()); assertEquals(LocalDate.of(2030, 11, 12), cal.lastValidDate()); - assertEquals(2,cal.weekendDays().size()); - assertEquals(LocalTime.of(6,14), cal.standardBusinessSchedule().businessStart()); - assertEquals(LocalTime.of(12,34), cal.standardBusinessSchedule().businessEnd()); + assertEquals(2, cal.weekendDays().size()); + assertEquals(LocalTime.of(6, 14), cal.standardBusinessSchedule().businessStart()); + assertEquals(LocalTime.of(12, 34), cal.standardBusinessSchedule().businessEnd()); assertTrue(cal.weekendDays().contains(DayOfWeek.MONDAY)); assertTrue(cal.weekendDays().contains(DayOfWeek.WEDNESDAY)); assertEquals(2, cal.holidays().size()); assertTrue(cal.holidays().containsKey(LocalDate.of(2015, 1, 1))); assertTrue(cal.holidays().containsKey(LocalDate.of(2015, 4, 6))); - assertEquals(DateTimeUtils.parseInstant("2015-04-06T14:15 Asia/Tokyo"), cal.businessSchedule("2015-04-06").businessStart()); - assertEquals(DateTimeUtils.parseInstant("2015-04-06T16:46 Asia/Tokyo"), cal.businessSchedule("2015-04-06").businessEnd()); + assertEquals(DateTimeUtils.parseInstant("2015-04-06T14:15 Asia/Tokyo"), + cal.businessSchedule("2015-04-06").businessStart()); + assertEquals(DateTimeUtils.parseInstant("2015-04-06T16:46 Asia/Tokyo"), + cal.businessSchedule("2015-04-06").businessEnd()); } public void testLoad() throws URISyntaxException { final String path = Paths - .get(Objects.requireNonNull(TestBusinessCalendarParser.class.getResource("/PARSER-TEST.calendar")).toURI()) + .get(Objects.requireNonNull(TestBusinessCalendarParser.class.getResource("/PARSER-TEST.calendar")) + .toURI()) .toString(); final File f = new File(path); final BusinessCalendar cal = BusinessCalendarParser.loadBusinessCalendar(f); 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 28a39ec7314..f33b3e549b8 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 @@ -46,15 +46,16 @@ public void testCalendar() { public void testAdd() throws URISyntaxException { - try{ + try { final String path = Paths - .get(Objects.requireNonNull(TestBusinessCalendarParser.class.getResource("/PARSER-TEST.calendar")).toURI()) + .get(Objects.requireNonNull(TestBusinessCalendarParser.class.getResource("/PARSER-TEST.calendar")) + .toURI()) .toString(); Calendars.addCalendarFromFile(path); final BusinessCalendar cal = Calendars.calendar("PARSER-TEST-CAL"); TestBusinessCalendarParser.assertParserTestCal(cal); - }finally { + } finally { Calendars.setDefaultCalendar(Configuration.getInstance().getProperty("Calendar.default")); } } diff --git a/engine/time/src/test/java/io/deephaven/time/calendar/TestStaticCalendarMethods.java b/engine/time/src/test/java/io/deephaven/time/calendar/TestStaticCalendarMethods.java index 3589824845a..77d584f1623 100644 --- a/engine/time/src/test/java/io/deephaven/time/calendar/TestStaticCalendarMethods.java +++ b/engine/time/src/test/java/io/deephaven/time/calendar/TestStaticCalendarMethods.java @@ -22,15 +22,19 @@ */ public class TestStaticCalendarMethods extends BaseArrayTestCase { - private final Map,Object[]> data = new HashMap<>(); + private final Map, Object[]> data = new HashMap<>(); { data.put(String.class, new String[] {"2017-08-01", "2017-08-05"}); - data.put(LocalDate.class, new LocalDate[] {DateTimeUtils.parseLocalDate("2017-08-01"), DateTimeUtils.parseLocalDate("2017-08-05")}); - data.put(Instant.class, new Instant[] {DateTimeUtils.parseInstant("2002-01-01T01:00:00.000000000 NY"), DateTimeUtils.parseInstant("2002-01-21T01:00:00.000000000 NY")}); - data.put(ZonedDateTime.class, new ZonedDateTime[] {DateTimeUtils.parseZonedDateTime("2002-01-01T01:00:00.000000000 NY"), DateTimeUtils.parseZonedDateTime("2002-01-21T01:00:00.000000000 NY")}); + data.put(LocalDate.class, new LocalDate[] {DateTimeUtils.parseLocalDate("2017-08-01"), + DateTimeUtils.parseLocalDate("2017-08-05")}); + data.put(Instant.class, new Instant[] {DateTimeUtils.parseInstant("2002-01-01T01:00:00.000000000 NY"), + DateTimeUtils.parseInstant("2002-01-21T01:00:00.000000000 NY")}); + data.put(ZonedDateTime.class, + new ZonedDateTime[] {DateTimeUtils.parseZonedDateTime("2002-01-01T01:00:00.000000000 NY"), + DateTimeUtils.parseZonedDateTime("2002-01-21T01:00:00.000000000 NY")}); data.put(boolean.class, new Boolean[] {true, true}); - data.put(int.class, new Object[]{1, 2}); - data.put(DayOfWeek.class, new Object[]{DayOfWeek.MONDAY, DayOfWeek.TUESDAY}); + data.put(int.class, new Object[] {1, 2}); + data.put(DayOfWeek.class, new Object[] {DayOfWeek.MONDAY, DayOfWeek.TUESDAY}); } private final Map deltas = new HashMap<>(); @@ -40,28 +44,29 @@ public class TestStaticCalendarMethods extends BaseArrayTestCase { } @SuppressWarnings("StringConcatenationInLoop") - private void executeTest(final Method m1, final Method m2) throws InvocationTargetException, IllegalAccessException { + private void executeTest(final Method m1, final Method m2) + throws InvocationTargetException, IllegalAccessException { final ArrayList args = new ArrayList<>(); - final Map,Integer> paramCounter = new HashMap<>(); + final Map, Integer> paramCounter = new HashMap<>(); String description = m1.getName() + "("; boolean isFirst = true; - for(Class t : m1.getParameterTypes()) { + for (Class t : m1.getParameterTypes()) { final int count = paramCounter.getOrDefault(t, 0) + 1; paramCounter.put(t, count); final String name = t.getSimpleName().toLowerCase() + count; final Object[] d = data.get(t); - if(d == null) { + if (d == null) { throw new RuntimeException("No data for " + t); } - final Object val = d[count-1]; + final Object val = d[count - 1]; args.add(val); - if(isFirst){ + if (isFirst) { isFirst = false; } else { description += ", "; @@ -78,9 +83,9 @@ private void executeTest(final Method m1, final Method m2) throws InvocationTarg final Object actual = m2.invoke(null, args.toArray()); final Double delta = deltas.get(description); - if(delta != null){ + if (delta != null) { assertEquals(description, (double) target, (double) actual, delta); - } else if(target instanceof Object[]) { + } else if (target instanceof Object[]) { assertEquals(description, (Object[]) target, (Object[]) actual); } else { assertEquals(description, target, actual); @@ -96,8 +101,8 @@ public void testAll() { excludes.add("firstValidDate"); excludes.add("lastValidDate"); - for(Method m1 : BusinessCalendar.class.getMethods()) { - if(m1.getDeclaringClass() == Object.class || + for (Method m1 : BusinessCalendar.class.getMethods()) { + if (m1.getDeclaringClass() == Object.class || Modifier.isStatic(m1.getModifiers()) || !Modifier.isPublic(m1.getModifiers())) { continue; @@ -106,14 +111,14 @@ public void testAll() { try { String name2 = m1.getName(); - if(excludes.contains(name2)) { + if (excludes.contains(name2)) { System.out.println("Skipping " + name2); continue; } - if(name2.equals("dayOfWeek")) { + if (name2.equals("dayOfWeek")) { name2 = "calendarDayOfWeek"; - } else if(name2.equals("timeZone")) { + } else if (name2.equals("timeZone")) { name2 = "calendarTimeZone"; }