Skip to content
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
23 changes: 10 additions & 13 deletions forge-core/src/main/java/forge/card/CardEdition.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,13 @@ private CardEdition(ListMultimap<String, EditionEntry> cardMap, ListMultimap<Str
this.cardMap = cardMap;
this.cardsInSet = new ArrayList<>(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;
}
Expand All @@ -343,7 +350,6 @@ private CardEdition(ListMultimap<String, EditionEntry> cardMap, ListMultimap<Str
* it uses the 3-letter codes for the folder no matter the age of the set.
* @param type the set type
* @param name the name of the set
* @param cards the cards in the set
*/
private CardEdition(String date, String code, String code2, Type type, String name, FoilType foil) {
this(ArrayListMultimap.create(), ArrayListMultimap.create(), new HashMap<>());
Expand Down Expand Up @@ -409,25 +415,16 @@ public List<EditionEntry> getAllCardsInSet() {
return cardsInSet;
}

private ListMultimap<String, EditionEntry> cardsInSetLookupMap = null;
private final ListMultimap<String, EditionEntry> cardsInSetLookupMap;

/**
* Get all the CardInSet instances with the input card name.
* @param cardName Name of the Card to look for.
* @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<EditionEntry> getCardInSet(String cardName){
if (cardsInSetLookupMap == null) {
// initialise
cardsInSetLookupMap = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), Lists::newArrayList);
List<EditionEntry> cardsInSet = this.getAllCardsInSet();
for (EditionEntry cis : cardsInSet){
String key = cis.name;
cardsInSetLookupMap.put(key, cis);
}
}
return this.cardsInSetLookupMap.get(cardName);
public List<EditionEntry> getCardInSet(String cardName) {
return cardsInSetLookupMap.get(cardName);
}

public EditionEntry getCardFromCollectorNumber(String collectorNumber) {
Expand Down