Skip to content

Commit

Permalink
Use EnumMap in PatternsHolder.
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Aug 9, 2022
1 parent d120036 commit fa05442
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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<String> seconds;
Expand All @@ -17,7 +18,8 @@ public abstract class PatternsHolder {
private final Collection<String> months;
private final Collection<String> years;

private final Map<ChronoUnit, Map<String, Integer>> specialCases = new LinkedHashMap<>();
private final Map<ChronoUnit, Map<String, Integer>> specialCases =
new EnumMap<>(ChronoUnit.class);

protected PatternsHolder(String wordSeparator, Collection<String> seconds, Collection<String> minutes,
Collection<String> hours, Collection<String> days,
Expand Down Expand Up @@ -81,7 +83,7 @@ protected void putSpecialCase(ChronoUnit unit, String caseText, int caseAmount)
}

public Map<ChronoUnit, Collection<String>> asMap() {
final Map<ChronoUnit, Collection<String>> returnMap = new LinkedHashMap<>();
final Map<ChronoUnit, Collection<String>> returnMap = new EnumMap<>(ChronoUnit.class);
returnMap.put(ChronoUnit.SECONDS, seconds());
returnMap.put(ChronoUnit.MINUTES, minutes());
returnMap.put(ChronoUnit.HOURS, hours());
Expand Down

0 comments on commit fa05442

Please sign in to comment.