@Override public void saveDeck(Deck deck) { String destinationName = deck.name(); DeckData deckData = buildDeckData(deck); String deckDataString = gson.toJson(deckData); persist(destinationName, deckDataString); }
private DeckData buildDeckData(Deck deck) { DeckData data = new DeckData(); data.setName(deck.name()); data.setIdentity(deck.getIdentity().key()); List<CardEntry> entries = deck.cards(); for (CardEntry cardEntry : entries) { data.addCardRef(cardEntry.getKey(), cardEntry.getCount()); } return data; }