diff options
author | Eduardo Pedroni <e.pedroni91@gmail.com> | 2016-08-07 22:18:55 +0200 |
---|---|---|
committer | Eduardo Pedroni <e.pedroni91@gmail.com> | 2016-08-07 22:18:55 +0200 |
commit | f7fe057b745d3f0e19b5dd6bd1819b11fc89c551 (patch) | |
tree | 1d19673aa4170f91248682a21db9fbc7c3945f4e /src/eu/equalparts/cardbase/cardstorage/StandaloneCardContainer.java | |
parent | 64c8e926d167a17865a6c3d86e48b383d413b569 (diff) |
Added filtering, still not working fully
Diffstat (limited to 'src/eu/equalparts/cardbase/cardstorage/StandaloneCardContainer.java')
-rw-r--r-- | src/eu/equalparts/cardbase/cardstorage/StandaloneCardContainer.java | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/src/eu/equalparts/cardbase/cardstorage/StandaloneCardContainer.java b/src/eu/equalparts/cardbase/cardstorage/StandaloneCardContainer.java deleted file mode 100644 index 53d248d..0000000 --- a/src/eu/equalparts/cardbase/cardstorage/StandaloneCardContainer.java +++ /dev/null @@ -1,66 +0,0 @@ -package eu.equalparts.cardbase.cardstorage; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import eu.equalparts.cardbase.cards.Card; - -/** - * TODO fix comments - * Holds actual card data in addition to the card counts in {@code ReferenceCardContainer}. - * - * @author Eduardo Pedroni - * - */ -public class StandaloneCardContainer extends ReferenceCardContainer { - /** - * A map with card hashes as entry keys (calculated used {@code Card.hashCode()}) - * and card objects as entry values. - */ - @JsonProperty private Map<Integer, Card> cardData = new HashMap<>(); - - /** - * Returns a card from the cardbase by set code and number. - * If no such card is in the cardbase, returns null. - * - * @param setCode the set to which the requested card belongs. - * @param number the requested card's set number. - * @return the requested {@code Card} or null if no card is found. - */ - public Card getCard(String setCode, String number) { - return cardData.get(Card.makeHash(setCode, number)); - } - - /** - * This method is intended to allow iteration directly on the list of cards, - * while at the same time retaining control over the insert and remove procedures. - * The returned {@code List} is a read-only; trying to modify its structure will - * result in an {@code UnsupportedOperationException}. - * - * @return an unmodifiable list of all the cards in the cardbase. - */ - public List<Card> getCards() { - return new LinkedList<Card>(cardData.values()); - } - - @Override - public void addCard(Card cardToAdd, int count) { - super.addCard(cardToAdd, count); - cardData.putIfAbsent(cardToAdd.hashCode(), cardToAdd); - } - - @Override - public int removeCard(Card cardToRemove, int count) { - int removed = super.removeCard(cardToRemove, count); - - if (getCount(cardToRemove) <= 0) { - cardData.remove(cardToRemove.hashCode()); - } - - return removed; - } -} |