updated SagaChapter getChapter method

This commit is contained in:
Evan Kranzler 2020-01-12 13:30:18 -05:00
parent 2d2b009c43
commit 595b438faa

View file

@ -1,9 +1,5 @@
package mage.constants;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* @author LevelX2
*/
@ -13,8 +9,6 @@ public enum SagaChapter {
CHAPTER_III(3, "III"),
CHAPTER_IV(4, "IV");
private static final Map<Integer, SagaChapter> chapterMap = new HashMap();
private final String text;
private final int number;
@ -33,14 +27,11 @@ public enum SagaChapter {
}
public static SagaChapter getChapter(int number) {
initMap();
return chapterMap.get(number);
for (SagaChapter sagaChapter : SagaChapter.values()) {
if (sagaChapter.getNumber() == number) {
return sagaChapter;
}
private static void initMap() {
if (!chapterMap.isEmpty()) {
return;
}
Arrays.stream(SagaChapter.values()).forEach(sagaChapter -> chapterMap.put(sagaChapter.getNumber(), sagaChapter));
return null;
}
}