Skip to content

Commit

Permalink
Remove unchecked array code
Browse files Browse the repository at this point in the history
  • Loading branch information
phensley committed Nov 30, 2023
1 parent 53f1927 commit 7ffeb38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -71,7 +70,7 @@ public <R> void format(AbstractValue<R> val, CalendarContext<T> 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;
}
Expand Down Expand Up @@ -207,7 +206,7 @@ public <R> void format(AbstractValue<R> val, CalendarContext<T> 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
Expand Down Expand Up @@ -367,7 +366,7 @@ protected String dayPeriodExt(CalendarContext<T> ctx, DateTimeNode node) {
key2ext = hour == 0 ? "midnight" : hour == 12 ? "noon" : key2;
}
Vector3Arrow<String, String, DayPeriodAltType> 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;
Expand All @@ -378,7 +377,7 @@ protected String dayPeriodFlex(CalendarContext<T> 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;
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/squarespace/cldrengine/utils/ListUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,4 @@ public static <T> ArrayList<T> concat(Collection<T> a, Collection<T> b) {
result.addAll(b);
return result;
}

public static <T> T[] array(@SuppressWarnings("unchecked") T ... args) {
return args;
}
}

0 comments on commit 7ffeb38

Please sign in to comment.