Skip to content

Commit

Permalink
Create Factory for Card, Game, and CardInPlay
Browse files Browse the repository at this point in the history
See #24

Signed-off-by: vartanbeno <vartanbeno@gmail.com>
  • Loading branch information
vartanbeno committed Nov 19, 2018
1 parent fc03dad commit 29bd322
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 0 deletions.
Binary file added build/classes/dom/model/card/CardFactory.class
Binary file not shown.
Binary file not shown.
Binary file added build/classes/dom/model/game/GameFactory.class
Binary file not shown.
28 changes: 28 additions & 0 deletions src/dom/model/card/CardFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dom.model.card;

import org.dsrg.soenea.domain.MapperException;
import org.dsrg.soenea.uow.MissingMappingException;
import org.dsrg.soenea.uow.UoW;

public class CardFactory {

public static Card createNew(long id, long version, long deck, String type, String name)
throws MissingMappingException, MapperException {

Card card = new Card(id, version, deck, type, name);
UoW.getCurrent().registerNew(card);

return card;

}

public static Card createClean(long id, long version, long deck, String type, String name) {

Card card = new Card(id, version, deck, type, name);
UoW.getCurrent().registerClean(card);

return card;

}

}
34 changes: 34 additions & 0 deletions src/dom/model/cardinplay/CardInPlayFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package dom.model.cardinplay;

import org.dsrg.soenea.domain.MapperException;
import org.dsrg.soenea.uow.MissingMappingException;
import org.dsrg.soenea.uow.UoW;

import dom.model.card.ICard;
import dom.model.deck.IDeck;
import dom.model.game.IGame;
import dom.model.user.IUser;

public class CardInPlayFactory {

public static CardInPlay createNew(long id, long version, IGame game, IUser player, IDeck deck, ICard card, int status)
throws MissingMappingException, MapperException {

CardInPlay cardInPlay = new CardInPlay(id, version, game, player, deck, card, status);
UoW.getCurrent().registerNew(cardInPlay);

return cardInPlay;

}

public static CardInPlay createClean(long id, long version, IGame game, IUser player, IDeck deck, ICard card, int status)
throws MissingMappingException, MapperException {

CardInPlay cardInPlay = new CardInPlay(id, version, game, player, deck, card, status);
UoW.getCurrent().registerClean(cardInPlay);

return cardInPlay;

}

}
31 changes: 31 additions & 0 deletions src/dom/model/game/GameFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package dom.model.game;

import org.dsrg.soenea.domain.MapperException;
import org.dsrg.soenea.uow.MissingMappingException;
import org.dsrg.soenea.uow.UoW;

import dom.model.deck.IDeck;
import dom.model.user.IUser;

public class GameFactory {

public static Game createNew(long id, long version, IUser challenger, IUser challengee, IDeck challengerDeck, IDeck challengeeDeck, int status)
throws MissingMappingException, MapperException {

Game game = new Game(id, version, challenger, challengee, challengerDeck, challengeeDeck, status);
UoW.getCurrent().registerNew(game);

return game;

}

public static Game createClean(long id, long version, IUser challenger, IUser challengee, IDeck challengerDeck, IDeck challengeeDeck, int status) {

Game game = new Game(id, version, challenger, challengee, challengerDeck, challengeeDeck, status);
UoW.getCurrent().registerClean(game);

return game;

}

}

0 comments on commit 29bd322

Please sign in to comment.