diff --git a/forge-core/src/main/java/forge/card/CardEdition.java b/forge-core/src/main/java/forge/card/CardEdition.java index 872187d0338..f9ce44bff7e 100644 --- a/forge-core/src/main/java/forge/card/CardEdition.java +++ b/forge-core/src/main/java/forge/card/CardEdition.java @@ -328,6 +328,13 @@ private CardEdition(ListMultimap cardMap, ListMultimap(cardMap.values()); Collections.sort(cardsInSet); + this.cardsInSetLookupMap = cardsInSet.stream().collect( + Multimaps.toMultimap( + e -> e.name, + e -> e, + MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).arrayListValues()::build + ) + ); this.tokenMap = tokens; this.customPrintSheetsToParse = customPrintSheetsToParse; } @@ -343,7 +350,6 @@ private CardEdition(ListMultimap cardMap, ListMultimap()); @@ -409,7 +415,7 @@ public List getAllCardsInSet() { return cardsInSet; } - private ListMultimap cardsInSetLookupMap = null; + private final ListMultimap cardsInSetLookupMap; /** * Get all the CardInSet instances with the input card name. @@ -417,17 +423,8 @@ public List getAllCardsInSet() { * @return A List of all the CardInSet instances for a given name. * If not found, an Empty sequence (view) will be returned instead! */ - public List getCardInSet(String cardName){ - if (cardsInSetLookupMap == null) { - // initialise - cardsInSetLookupMap = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), Lists::newArrayList); - List cardsInSet = this.getAllCardsInSet(); - for (EditionEntry cis : cardsInSet){ - String key = cis.name; - cardsInSetLookupMap.put(key, cis); - } - } - return this.cardsInSetLookupMap.get(cardName); + public List getCardInSet(String cardName) { + return cardsInSetLookupMap.get(cardName); } public EditionEntry getCardFromCollectorNumber(String collectorNumber) {