Code cleanup

This commit is contained in:
drdev
2014-01-15 05:07:59 +00:00
parent 726084bc06
commit 03870821c5
8 changed files with 77 additions and 94 deletions

View File

@@ -28,22 +28,21 @@ import com.google.common.collect.Iterables;
import forge.util.IItemReader; import forge.util.IItemReader;
//reads and writeDeck Deck objects
/** /**
* <p> * <p>
* DeckManager class. * StorageBase class.
* </p> * </p>
* *
* @param <T> the generic type * @param <T> the generic type
* @author Forge * @author Forge
* @version $Id: DeckManager.java 13590 2012-01-27 20:46:27Z Max mtg $ * @version $Id: StorageBase.java 13590 2012-01-27 20:46:27Z Max mtg $
*/ */
public class StorageBase<T> implements IStorage<T> { public class StorageBase<T> implements IStorage<T> {
protected final Map<String, T> map; protected final Map<String, T> map;
public final static StorageBase<?> emptyMap = new StorageBase<Object>("Empty", new HashMap<String, Object>()); public final static StorageBase<?> emptyMap = new StorageBase<Object>("Empty", new HashMap<String, Object>());
public final String name; public final String name;
public StorageBase(final String name, final IItemReader<T> io) { public StorageBase(final String name, final IItemReader<T> io) {
this.name = name; this.name = name;
this.map = io.readAll(); this.map = io.readAll();
@@ -52,13 +51,12 @@ public class StorageBase<T> implements IStorage<T> {
public StorageBase(final String name, final Map<String, T> inMap) { public StorageBase(final String name, final Map<String, T> inMap) {
this.name = name; this.name = name;
this.map = inMap; this.map = inMap;
} }
@Override @Override
public T get(final String name) { public T get(final String name) {
return this.map.get(name); return this.map.get(name);
} }
@Override @Override
public final Collection<String> getItemNames() { public final Collection<String> getItemNames() {
@@ -84,16 +82,14 @@ public class StorageBase<T> implements IStorage<T> {
public T find(Predicate<T> condition) { public T find(Predicate<T> condition) {
return Iterables.tryFind(map.values(), condition).orNull(); return Iterables.tryFind(map.values(), condition).orNull();
} }
@Override @Override
public void add(T deck) { public void add(T item) {
throw new UnsupportedOperationException("This is a read-only storage"); throw new UnsupportedOperationException("This is a read-only storage");
} }
@Override @Override
public void delete(String deckName) { public void delete(String itemName) {
throw new UnsupportedOperationException("This is a read-only storage"); throw new UnsupportedOperationException("This is a read-only storage");
} }

View File

@@ -34,10 +34,8 @@ import forge.util.FileUtil;
* the generic type * the generic type
*/ */
public abstract class StorageReaderFile<T> extends StorageReaderBase<T> { public abstract class StorageReaderFile<T> extends StorageReaderBase<T> {
private final File file; private final File file;
/** /**
* Instantiates a new storage reader file. * Instantiates a new storage reader file.
* *

View File

@@ -36,7 +36,6 @@ import forge.util.FileUtil;
* the generic type * the generic type
*/ */
public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T> { public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T> {
private final File file; private final File file;
public StorageReaderFileSections(final String pathname, final Function<? super T, String> keySelector0) { public StorageReaderFileSections(final String pathname, final Function<? super T, String> keySelector0) {
@@ -46,7 +45,6 @@ public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T>
public StorageReaderFileSections(final File file0, final Function<? super T, String> keySelector0) { public StorageReaderFileSections(final File file0, final Function<? super T, String> keySelector0) {
super(keySelector0); super(keySelector0);
this.file = file0; this.file = file0;
} }
protected Map<String, T> createMap() { protected Map<String, T> createMap() {
@@ -136,5 +134,4 @@ public abstract class StorageReaderFileSections<T> extends StorageReaderBase<T>
public String getItemKey(final T item) { public String getItemKey(final T item) {
return this.keySelector.apply(item); return this.keySelector.apply(item);
} }
} }

View File

@@ -38,7 +38,6 @@ import com.google.common.base.Function;
* @param <T> the generic type * @param <T> the generic type
*/ */
public abstract class StorageReaderFolder<T> extends StorageReaderBase<T> { public abstract class StorageReaderFolder<T> extends StorageReaderBase<T> {
/** /**
* @return the directory * @return the directory
*/ */
@@ -46,18 +45,17 @@ public abstract class StorageReaderFolder<T> extends StorageReaderBase<T> {
return directory; return directory;
} }
protected final File directory; protected final File directory;
/** /**
* Instantiates a new storage reader folder. * Instantiates a new storage reader folder.
* *
* @param deckDir0 the deck dir0 * @param itemDir0 the item dir0
*/ */
public StorageReaderFolder(final File deckDir0, Function<? super T, String> keySelector0) { public StorageReaderFolder(final File itemDir0, Function<? super T, String> keySelector0) {
super(keySelector0); super(keySelector0);
this.directory = deckDir0; this.directory = itemDir0;
if (this.directory == null) { if (this.directory == null) {
throw new IllegalArgumentException("No directory specified"); throw new IllegalArgumentException("No directory specified");
@@ -125,7 +123,6 @@ public abstract class StorageReaderFolder<T> extends StorageReaderBase<T> {
public String getItemKey(T item) { public String getItemKey(T item) {
return keySelector.apply(item); return keySelector.apply(item);
} }
// methods handling nested folders are provided. It's up to consumer whether to use these or not. // methods handling nested folders are provided. It's up to consumer whether to use these or not.
@Override @Override

View File

@@ -1,4 +1,4 @@
package forge.gui.deckchooser; package forge.gui.deckchooser;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.StringSelection;
@@ -58,29 +58,32 @@ public class DeckgenUtil {
* @return {@link forge.deck.Deck} * @return {@link forge.deck.Deck}
*/ */
public static Deck buildColorDeck(List<String> selection, boolean forAi) { public static Deck buildColorDeck(List<String> selection, boolean forAi) {
final Deck deck; final Deck deck;
String deckName = null; String deckName = null;
DeckGeneratorBase gen = null; DeckGeneratorBase gen = null;
CardDb cardDb = Singletons.getMagicDb().getCommonCards(); CardDb cardDb = Singletons.getMagicDb().getCommonCards();
if (selection.size() == 1) { if (selection.size() == 1) {
gen = new DeckGeneratorMonoColor(cardDb, selection.get(0)); gen = new DeckGeneratorMonoColor(cardDb, selection.get(0));
} else if (selection.size() == 2) { }
else if (selection.size() == 2) {
gen = new DeckGenerator2Color(cardDb, selection.get(0), selection.get(1)); gen = new DeckGenerator2Color(cardDb, selection.get(0), selection.get(1));
} else if (selection.size() == 3) { }
else if (selection.size() == 3) {
gen = new DeckGenerator3Color(cardDb, selection.get(0), selection.get(1), selection.get(2)); gen = new DeckGenerator3Color(cardDb, selection.get(0), selection.get(1), selection.get(2));
} else { }
else {
gen = new DeckGenerator5Color(cardDb); gen = new DeckGenerator5Color(cardDb);
deckName = "5 colors"; deckName = "5 colors";
} }
gen.setSingleton(Singletons.getModel().getPreferences().getPrefBoolean(FPref.DECKGEN_SINGLETONS)); gen.setSingleton(Singletons.getModel().getPreferences().getPrefBoolean(FPref.DECKGEN_SINGLETONS));
gen.setUseArtifacts(Singletons.getModel().getPreferences().getPrefBoolean(FPref.DECKGEN_ARTIFACTS)); gen.setUseArtifacts(Singletons.getModel().getPreferences().getPrefBoolean(FPref.DECKGEN_ARTIFACTS));
ItemPoolView<PaperCard> cards = gen == null ? null : gen.getDeck(60, forAi); ItemPoolView<PaperCard> cards = gen == null ? null : gen.getDeck(60, forAi);
if(null == deckName) if (null == deckName) {
deckName = Lang.joinHomogenous(Arrays.asList(selection)); deckName = Lang.joinHomogenous(Arrays.asList(selection));
}
// After generating card lists, build deck. // After generating card lists, build deck.
deck = new Deck("Random deck : " + deckName); deck = new Deck("Random deck : " + deckName);
deck.getMain().addAll(cards); deck.getMain().addAll(cards);
@@ -112,30 +115,32 @@ public class DeckgenUtil {
IStorage<Deck> path = Singletons.getModel().getDecks().getConstructed(); IStorage<Deck> path = Singletons.getModel().getDecks().getConstructed();
String name = selection; String name = selection;
int idxSlash = name.indexOf('/'); int idxSlash = name.indexOf('/');
while( idxSlash > 0 && path != null) { while (idxSlash > 0 && path != null) {
String sf = name.substring(0, idxSlash).trim(); String sf = name.substring(0, idxSlash).trim();
path = path.getFolders().get(sf); path = path.getFolders().get(sf);
name = name.substring(idxSlash+1).trim(); name = name.substring(idxSlash+1).trim();
idxSlash = name.indexOf('/'); idxSlash = name.indexOf('/');
}; };
if ( path == null ) if (path == null) {
throw new IllegalArgumentException("Path not found - " + selection); throw new IllegalArgumentException("Path not found - " + selection);
}
return path.get(name); return path.get(name);
} }
public static Deck getPreconDeck(String selection) { public static Deck getPreconDeck(String selection) {
return QuestController.getPrecons().get(selection).getDeck(); return QuestController.getPrecons().get(selection).getDeck();
} }
public static QuestEvent getQuestEvent(final String name) { public static QuestEvent getQuestEvent(final String name) {
QuestController qCtrl = Singletons.getModel().getQuest(); QuestController qCtrl = Singletons.getModel().getQuest();
for(QuestEventChallenge challenge : qCtrl.getChallenges()) { for (QuestEventChallenge challenge : qCtrl.getChallenges()) {
if( challenge.getTitle().equals(name) ) if (challenge.getTitle().equals(name)) {
return challenge; return challenge;
}
} }
QuestEventDuel duel = Iterables.find(qCtrl.getDuelsManager().getAllDuels(), new Predicate<QuestEventDuel>() { QuestEventDuel duel = Iterables.find(qCtrl.getDuelsManager().getAllDuels(), new Predicate<QuestEventDuel>() {
@Override public boolean apply(QuestEventDuel in) { return in.getName().equals(name); } @Override public boolean apply(QuestEventDuel in) { return in.getName().equals(name); }
}); });
return duel; return duel;
} }
@@ -167,13 +172,12 @@ public class DeckgenUtil {
final String name = allDecks.getItemNames().toArray(new String[0])[rand]; final String name = allDecks.getItemNames().toArray(new String[0])[rand];
return allDecks.get(name); return allDecks.get(name);
} }
/** @return {@link forge.deck.Deck} */ /** @return {@link forge.deck.Deck} */
public static Deck getRandomQuestDeck() { public static Deck getRandomQuestDeck() {
final List<Deck> allQuestDecks = new ArrayList<Deck>(); final List<Deck> allQuestDecks = new ArrayList<Deck>();
QuestController qCtrl = Singletons.getModel().getQuest(); QuestController qCtrl = Singletons.getModel().getQuest();
for (final QuestEvent e : qCtrl.getDuelsManager().getAllDuels()) { for (final QuestEvent e : qCtrl.getDuelsManager().getAllDuels()) {
allQuestDecks.add(e.getEventDeck()); allQuestDecks.add(e.getEventDeck());
} }
@@ -189,20 +193,22 @@ public class DeckgenUtil {
public static int[] randomSelectColors(int maxColors) { public static int[] randomSelectColors(int maxColors) {
int nColors = MyRandom.getRandom().nextInt(3) + 1; int nColors = MyRandom.getRandom().nextInt(3) + 1;
int[] result = new int[nColors]; int[] result = new int[nColors];
for(int i = 0; i < nColors; i++) { for (int i = 0; i < nColors; i++) {
int next = MyRandom.getRandom().nextInt(maxColors); int next = MyRandom.getRandom().nextInt(maxColors);
boolean isUnique = true; boolean isUnique = true;
for(int j = 0; j < i; j++) { for (int j = 0; j < i; j++) {
if(result[j] == next) { if (result[j] == next) {
isUnique = false; isUnique = false;
break; break;
} }
} }
if(isUnique) if (isUnique) {
result[i] = next; result[i] = next;
else }
i--; // try over with this number else {
i--; // try over with this number
}
} }
return result; return result;
} }
@@ -224,9 +230,8 @@ public class DeckgenUtil {
* @param lst0 {@link javax.swing.JList} * @param lst0 {@link javax.swing.JList}
*/ */
public static void showDecklist(final Deck deck) { public static void showDecklist(final Deck deck) {
if (deck == null) { return; } if (deck == null) { return; }
// Dump into map and display. // Dump into map and display.
final String nl = System.getProperty("line.separator"); final String nl = System.getProperty("line.separator");
final StringBuilder deckList = new StringBuilder(); final StringBuilder deckList = new StringBuilder();
@@ -234,16 +239,17 @@ public class DeckgenUtil {
deckList.append(dName == null ? "" : dName + nl + nl); deckList.append(dName == null ? "" : dName + nl + nl);
int nLines = 0; int nLines = 0;
for(DeckSection s : DeckSection.values()){ for (DeckSection s : DeckSection.values()){
CardPool cp = deck.get(s); CardPool cp = deck.get(s);
if ( cp == null || cp.isEmpty() ) if (cp == null || cp.isEmpty()) {
continue; continue;
}
deckList.append(s.toString()).append(": "); deckList.append(s.toString()).append(": ");
if ( s.isSingleCard() ) { if (s.isSingleCard()) {
deckList.append(cp.get(0).getName()).append(nl); deckList.append(cp.get(0).getName()).append(nl);
nLines++; nLines++;
} else { }
else {
deckList.append(nl); deckList.append(nl);
nLines++; nLines++;
for (final Entry<PaperCard, Integer> ev : cp) { for (final Entry<PaperCard, Integer> ev : cp) {
@@ -255,11 +261,11 @@ public class DeckgenUtil {
nLines++; nLines++;
} }
final StringBuilder msg = new StringBuilder(); final StringBuilder msg = new StringBuilder();
if (nLines <= 32) { if (nLines <= 32) {
msg.append(deckList.toString()); msg.append(deckList.toString());
} else { }
else {
msg.append("Decklist too long for dialog." + nl + nl); msg.append("Decklist too long for dialog." + nl + nl);
} }
@@ -315,14 +321,15 @@ public class DeckgenUtil {
if (appearances < 2) { if (appearances < 2) {
schemes.add(cp); schemes.add(cp);
schemesToAdd--; schemesToAdd--;
} else { }
else {
attemptsLeft--; attemptsLeft--;
} }
} }
return schemes; return schemes;
} }
public static CardPool generatePlanarDeck() { public static CardPool generatePlanarDeck() {
CardPool res = new CardPool(); CardPool res = new CardPool();
List<PaperCard> allPlanars = new ArrayList<PaperCard>(); List<PaperCard> allPlanars = new ArrayList<PaperCard>();
@@ -334,23 +341,19 @@ public class DeckgenUtil {
int phenoms = 0; int phenoms = 0;
int targetsize = MyRandom.getRandom().nextInt(allPlanars.size()-10)+10; int targetsize = MyRandom.getRandom().nextInt(allPlanars.size()-10)+10;
while(true) while (true) {
{
PaperCard rndPlane = Aggregates.random(allPlanars); PaperCard rndPlane = Aggregates.random(allPlanars);
allPlanars.remove(rndPlane); allPlanars.remove(rndPlane);
if(rndPlane.getRules().getType().isPhenomenon() && phenoms < 2) if (rndPlane.getRules().getType().isPhenomenon() && phenoms < 2) {
{
res.add(rndPlane); res.add(rndPlane);
phenoms++; phenoms++;
} }
else if (rndPlane.getRules().getType().isPlane()) else if (rndPlane.getRules().getType().isPlane()) {
{
res.add(rndPlane); res.add(rndPlane);
} }
if(allPlanars.isEmpty() || res.countAll() == targetsize) if (allPlanars.isEmpty() || res.countAll() == targetsize) {
{
break; break;
} }
} }

View File

@@ -41,7 +41,6 @@ import forge.util.storage.IStorage;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class FDeckChooser extends JPanel implements IDecksComboBoxListener { public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
private final Color BORDER_COLOR = FSkin.getColor(FSkin.Colors.CLR_TEXT).getColor().darker(); private final Color BORDER_COLOR = FSkin.getColor(FSkin.Colors.CLR_TEXT).getColor().darker();
private boolean isUISetup = false; private boolean isUISetup = false;
@@ -116,7 +115,6 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
lst.setSelectedIndices(getSelectedDeckIndices(Arrays.asList(listData), new int[]{0, 1})); lst.setSelectedIndices(getSelectedDeckIndices(Arrays.asList(listData), new int[]{0, 1}));
lst.ensureIndexIsVisible(lst.getSelectedIndices()[0]); lst.ensureIndexIsVisible(lst.getSelectedIndices()[0]);
} }
} }
private void updateThemes() { private void updateThemes() {
@@ -141,7 +139,6 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
lst.setSelectedIndices(getSelectedDeckIndices(listData, new int[]{0})); lst.setSelectedIndices(getSelectedDeckIndices(listData, new int[]{0}));
lst.ensureIndexIsVisible(lst.getSelectedIndices()[0]); lst.ensureIndexIsVisible(lst.getSelectedIndices()[0]);
} }
} }
private void updateCustom() { private void updateCustom() {
@@ -226,7 +223,6 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
lst.setSelectedIndices(getSelectedDeckIndices(listData, new int[]{0})); lst.setSelectedIndices(getSelectedDeckIndices(listData, new int[]{0}));
lst.ensureIndexIsVisible(lst.getSelectedIndices()[0]); lst.ensureIndexIsVisible(lst.getSelectedIndices()[0]);
} }
} }
public Deck getDeck() { public Deck getDeck() {
@@ -236,17 +232,21 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
if (selection.isEmpty()) { return null; } if (selection.isEmpty()) { return null; }
// Special branch for quest events // Special branch for quest events
if (lst0.getName().equals(DeckgenUtil.DeckTypes.QUESTEVENTS.toString())) if (lst0.getName().equals(DeckgenUtil.DeckTypes.QUESTEVENTS.toString())) {
return DeckgenUtil.getQuestEvent(selection.get(0)).getEventDeck(); return DeckgenUtil.getQuestEvent(selection.get(0)).getEventDeck();
if (lst0.getName().equals(DeckgenUtil.DeckTypes.COLORS.toString()) && DeckgenUtil.colorCheck(selection)) }
if (lst0.getName().equals(DeckgenUtil.DeckTypes.COLORS.toString()) && DeckgenUtil.colorCheck(selection)) {
return DeckgenUtil.buildColorDeck(selection, isAi); return DeckgenUtil.buildColorDeck(selection, isAi);
if (lst0.getName().equals(DeckgenUtil.DeckTypes.THEMES.toString())) }
if (lst0.getName().equals(DeckgenUtil.DeckTypes.THEMES.toString())) {
return DeckgenUtil.buildThemeDeck(selection.get(0)); return DeckgenUtil.buildThemeDeck(selection.get(0));
if (lst0.getName().equals(DeckgenUtil.DeckTypes.CUSTOM.toString())) }
if (lst0.getName().equals(DeckgenUtil.DeckTypes.CUSTOM.toString())) {
return DeckgenUtil.getConstructedDeck(selection.get(0)); return DeckgenUtil.getConstructedDeck(selection.get(0));
if (lst0.getName().equals(DeckgenUtil.DeckTypes.PRECON.toString())) }
if (lst0.getName().equals(DeckgenUtil.DeckTypes.PRECON.toString())) {
return DeckgenUtil.getPreconDeck(selection.get(0)); return DeckgenUtil.getPreconDeck(selection.get(0));
}
return null; return null;
} }
@@ -268,7 +268,6 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
return new RegisteredPlayer(getDeck()); return new RegisteredPlayer(getDeck());
} }
public final boolean isAi() { public final boolean isAi() {
return isAi; return isAi;
} }
@@ -424,5 +423,4 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
return defaultSelection; return defaultSelection;
} }
} }
} }

View File

@@ -23,10 +23,9 @@ import com.google.common.base.Function;
import forge.util.IItemSerializer; import forge.util.IItemSerializer;
//reads and writeDeck Deck objects
/** /**
* <p> * <p>
* DeckManager class. * StorageImmediatelySerialized class.
* </p> * </p>
* *
* @param <T> the generic type * @param <T> the generic type
@@ -34,7 +33,6 @@ import forge.util.IItemSerializer;
* @version $Id$ * @version $Id$
*/ */
public class StorageImmediatelySerialized<T> extends StorageBase<T> { public class StorageImmediatelySerialized<T> extends StorageBase<T> {
private final IItemSerializer<T> serializer; private final IItemSerializer<T> serializer;
private final IStorage<IStorage<T>> subfolders; private final IStorage<IStorage<T>> subfolders;
@@ -44,10 +42,10 @@ public class StorageImmediatelySerialized<T> extends StorageBase<T> {
return new StorageImmediatelySerialized<T>(file.getName(), (IItemSerializer<T>) serializer.getReaderForFolder(file), true); return new StorageImmediatelySerialized<T>(file.getName(), (IItemSerializer<T>) serializer.getReaderForFolder(file), true);
} }
}; };
/** /**
* <p> * <p>
* Constructor for DeckManager. * Constructor for StorageImmediatelySerialized.
* </p> * </p>
* *
* @param io the io * @param io the io
@@ -55,8 +53,7 @@ public class StorageImmediatelySerialized<T> extends StorageBase<T> {
public StorageImmediatelySerialized(String name, final IItemSerializer<T> io) { public StorageImmediatelySerialized(String name, final IItemSerializer<T> io) {
this(name, io, false); this(name, io, false);
} }
public StorageImmediatelySerialized(String name, final IItemSerializer<T> io, boolean withSubFolders) { public StorageImmediatelySerialized(String name, final IItemSerializer<T> io, boolean withSubFolders) {
super(name, io); super(name, io);
this.serializer = io; this.serializer = io;
@@ -66,7 +63,7 @@ public class StorageImmediatelySerialized<T> extends StorageBase<T> {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see forge.deck.IFolderMap#add(T) * @see forge.util.storage.StorageBase#add(T)
*/ */
@Override @Override
public final void add(final T deck) { public final void add(final T deck) {
@@ -78,13 +75,13 @@ public class StorageImmediatelySerialized<T> extends StorageBase<T> {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see forge.deck.IFolderMap#delete(java.lang.String) * @see forge.util.storage.StorageBase#delete(java.lang.String)
*/ */
@Override @Override
public final void delete(final String deckName) { public final void delete(final String deckName) {
this.serializer.erase(this.map.remove(deckName)); this.serializer.erase(this.map.remove(deckName));
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see forge.util.storage.StorageBase#getFolders() * @see forge.util.storage.StorageBase#getFolders()
*/ */

View File

@@ -5,16 +5,13 @@ import java.util.HashMap;
import com.google.common.base.Function; import com.google.common.base.Function;
public class StorageNestedFolders<T> extends StorageBase<IStorage<T>> { public class StorageNestedFolders<T> extends StorageBase<IStorage<T>> {
private final File thisFolder; private final File thisFolder;
public StorageNestedFolders(File thisFolder, Iterable<File> subfolders, Function<File, IStorage<T>> factory) { public StorageNestedFolders(File thisFolder, Iterable<File> subfolders, Function<File, IStorage<T>> factory) {
super("<Subfolders>", new HashMap<String, IStorage<T>>()); super("<Subfolders>", new HashMap<String, IStorage<T>>());
this.thisFolder = thisFolder; this.thisFolder = thisFolder;
for(File sf : subfolders ) for (File sf : subfolders ) {
{
IStorage<T> newUnit = factory.apply(sf); IStorage<T> newUnit = factory.apply(sf);
map.put(sf.getName(), newUnit); map.put(sf.getName(), newUnit);
} }
@@ -37,8 +34,8 @@ public class StorageNestedFolders<T> extends StorageBase<IStorage<T>> {
IStorage<T> f = map.remove(deckName); IStorage<T> f = map.remove(deckName);
// TODO: Clear all that files from disk // TODO: Clear all that files from disk
if ( f != null ) if (f != null) {
subdir.delete(); // won't work if not empty; subdir.delete(); // won't work if not empty;
}
} }
} }