From e101d58ae76ba09d48c341235f63767ef1d81969 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Tue, 9 Aug 2022 08:21:39 +0530 Subject: [PATCH] Use EnumMap in PatternsHolder. --- .../newpipe/extractor/timeago/PatternsHolder.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/timeago-parser/src/main/java/org/schabi/newpipe/extractor/timeago/PatternsHolder.java b/timeago-parser/src/main/java/org/schabi/newpipe/extractor/timeago/PatternsHolder.java index f7dc996307..1e87f202df 100644 --- a/timeago-parser/src/main/java/org/schabi/newpipe/extractor/timeago/PatternsHolder.java +++ b/timeago-parser/src/main/java/org/schabi/newpipe/extractor/timeago/PatternsHolder.java @@ -1,12 +1,13 @@ package org.schabi.newpipe.extractor.timeago; +import static java.util.Arrays.asList; + import java.time.temporal.ChronoUnit; import java.util.Collection; +import java.util.EnumMap; import java.util.LinkedHashMap; import java.util.Map; -import static java.util.Arrays.asList; - public abstract class PatternsHolder { private final String wordSeparator; private final Collection seconds; @@ -17,7 +18,8 @@ public abstract class PatternsHolder { private final Collection months; private final Collection years; - private final Map> specialCases = new LinkedHashMap<>(); + private final Map> specialCases = + new EnumMap<>(ChronoUnit.class); protected PatternsHolder(String wordSeparator, Collection seconds, Collection minutes, Collection hours, Collection days, @@ -81,7 +83,7 @@ protected void putSpecialCase(ChronoUnit unit, String caseText, int caseAmount) } public Map> asMap() { - final Map> returnMap = new LinkedHashMap<>(); + final Map> returnMap = new EnumMap<>(ChronoUnit.class); returnMap.put(ChronoUnit.SECONDS, seconds()); returnMap.put(ChronoUnit.MINUTES, minutes()); returnMap.put(ChronoUnit.HOURS, hours());