edition cached in deckproxy

This commit is contained in:
Maxmtg
2014-01-25 15:50:56 +00:00
parent 6d34dbc286
commit 2f29cf7755

View File

@@ -48,6 +48,7 @@ public class DeckProxy implements InventoryItem {
private int sbSize = Integer.MIN_VALUE; private int sbSize = Integer.MIN_VALUE;
private final String path; private final String path;
private final Function<IHasName, Deck> fnGetDeck; private final Function<IHasName, Deck> fnGetDeck;
private String edition;
public DeckProxy(Deck deck, GameType type, IStorage<? extends IHasName> storage) { public DeckProxy(Deck deck, GameType type, IStorage<? extends IHasName> storage) {
this(deck, type, "", storage, null); this(deck, type, "", storage, null);
@@ -85,12 +86,13 @@ public class DeckProxy implements InventoryItem {
} }
public String getEdition() { public String getEdition() {
if ( null == edition ) {
if ( deck instanceof PreconDeck ) if ( deck instanceof PreconDeck )
return ((PreconDeck) deck).getEdition(); edition = ((PreconDeck) deck).getEdition();
Deck d = getDeck(); if ( !isGeneratedDeck() )
if ( d != null ) edition = StaticData.instance().getEditions().getEarliestEditionWithAllCards(getDeck().getAllCardsInASinglePool()).getCode();
return StaticData.instance().getEditions().getEarliestEditionWithAllCards(d.getAllCardsInASinglePool()).getCode(); }
return null; return edition;
} }
@Override @Override
@@ -101,6 +103,7 @@ public class DeckProxy implements InventoryItem {
public void invalidateCache() { public void invalidateCache() {
color = null; color = null;
formats = null; formats = null;
edition = null;
mainSize = Integer.MIN_VALUE; mainSize = Integer.MIN_VALUE;
sbSize = Integer.MIN_VALUE; sbSize = Integer.MIN_VALUE;
} }