Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use EnumMap in PatternsHolder. #888

Merged
merged 1 commit into from
Oct 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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