From 7ffeb3896bb88aefc827bb9492f09f7b220c93c1 Mon Sep 17 00:00:00 2001 From: Patrick Hensley Date: Thu, 30 Nov 2023 15:56:19 -0500 Subject: [PATCH] Remove unchecked array code --- .../cldrengine/calendars/CalendarFormatter.java | 9 ++++----- .../java/com/squarespace/cldrengine/utils/ListUtils.java | 4 ---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/squarespace/cldrengine/calendars/CalendarFormatter.java b/src/main/java/com/squarespace/cldrengine/calendars/CalendarFormatter.java index d4d85b5..fec3b97 100644 --- a/src/main/java/com/squarespace/cldrengine/calendars/CalendarFormatter.java +++ b/src/main/java/com/squarespace/cldrengine/calendars/CalendarFormatter.java @@ -1,6 +1,5 @@ package com.squarespace.cldrengine.calendars; -import static com.squarespace.cldrengine.utils.ListUtils.array; import static com.squarespace.cldrengine.utils.StringUtils.isEmpty; import com.squarespace.cldrengine.api.Bundle; @@ -71,7 +70,7 @@ public void format(AbstractValue val, CalendarContext ctx, DateTimePat value = this.cal.eras.get(ctx.bundle, w == 5 ? EraWidthType.NARROW : w == 4 ? EraWidthType.NAMES : EraWidthType.ABBR, Long.toString(ctx.date.era()), - array(ctx.alt.era.get(), EraAltType.NONE)); + new EraAltType[] { ctx.alt.era.get(), EraAltType.NONE }); if (w != 5) { field = w == 4 ? ContextTransformFieldType.ERA_NAME : ContextTransformFieldType.ERA_ABBR; } @@ -207,7 +206,7 @@ public void format(AbstractValue val, CalendarContext ctx, DateTimePat case 'a': type = "dayperiod"; value = this.cal.format.dayPeriods.get(ctx.bundle, widthKey(w), - ctx.date.hourOfDay() < 12 ? "am" : "pm", array(ctx.alt.dayPeriod.get(), DayPeriodAltType.NONE)); + ctx.date.hourOfDay() < 12 ? "am" : "pm", new DayPeriodAltType[] { ctx.alt.dayPeriod.get(), DayPeriodAltType.NONE }); break; // DAY PERIOD EXTENDED @@ -367,7 +366,7 @@ protected String dayPeriodExt(CalendarContext ctx, DateTimeNode node) { key2ext = hour == 0 ? "midnight" : hour == 12 ? "noon" : key2; } Vector3Arrow format = this.cal.format.dayPeriods; - DayPeriodAltType[] alt = array(ctx.alt.dayPeriod.get(), DayPeriodAltType.NONE); + DayPeriodAltType[] alt = new DayPeriodAltType[] { ctx.alt.dayPeriod.get(), DayPeriodAltType.NONE }; // Try extended and if it doesn't exist, fall back to am/pm String result = format.get(ctx.bundle, key1, key2ext, alt); return result.equals("") ? format.get(ctx.bundle, key1, key2, alt) : result; @@ -378,7 +377,7 @@ protected String dayPeriodFlex(CalendarContext ctx, DateTimeNode node) { String key = this.internals.calendars.flexDayPeriod(ctx.bundle, minutes); String res = null; if (key != null) { - DayPeriodAltType[] alt = array(ctx.alt.dayPeriod.get(), DayPeriodAltType.NONE); + DayPeriodAltType[] alt = new DayPeriodAltType[] { ctx.alt.dayPeriod.get(), DayPeriodAltType.NONE }; res = this.cal.format.dayPeriods.get(ctx.bundle, widthKey(node.width), key, alt); } return isEmpty(res) ? this.dayPeriodExt(ctx, node) : res; diff --git a/src/main/java/com/squarespace/cldrengine/utils/ListUtils.java b/src/main/java/com/squarespace/cldrengine/utils/ListUtils.java index a30eb0b..62c67c6 100644 --- a/src/main/java/com/squarespace/cldrengine/utils/ListUtils.java +++ b/src/main/java/com/squarespace/cldrengine/utils/ListUtils.java @@ -13,8 +13,4 @@ public static ArrayList concat(Collection a, Collection b) { result.addAll(b); return result; } - - public static T[] array(@SuppressWarnings("unchecked") T ... args) { - return args; - } }