public class GameModelTranslator extends Object
GameModelTranslator
offers static methods to translate a GameModel
into an EMF-Model and vice versa.
To keep workload small, it registers a GameModelListener
at each GameModel it is used with and keeps the EMF-Objects updated on changes in their related GameModel.
Every GameModel that was translated is mapped to a GameStateNotification object
which is stored statically until the GameModel is explicitly removed from the translator.Constructor and Description |
---|
GameModelTranslator() |
Modifier and Type | Method and Description |
---|---|
static de.upb.swt.swtpra2017.swtinterface.Configuration |
configurationToEConfiguration(Configuration config)
Translates a Configuration object into an EMF Configuration object.
|
static Role |
eClientRoleToRole(de.upb.swt.swtpra2017.swtinterface.ClientRole eClientRole) |
static Configuration |
eConfigurationToConfiguration(de.upb.swt.swtpra2017.swtinterface.Configuration eConfig)
creates a new GameModel configuration object given the data of an EMF configuration object.
|
static FinishedReason |
eFinishedReasonToFinishedReason(de.upb.swt.swtpra2017.swtinterface.FinishedReason eFinishedReason) |
static GameState |
eGameStateToGameState(de.upb.swt.swtpra2017.swtinterface.GameState eGameState) |
static Gate |
eGateToGate(de.upb.swt.swtpra2017.swtinterface.Gate eGate) |
static JoinResponse |
eJoinResponseToJoinResponse(de.upb.swt.swtpra2017.swtinterface.JoinResponse eJoinResponse) |
static KickState |
eKickReasonToKickState(de.upb.swt.swtpra2017.swtinterface.KickReason eKickReason) |
static Placement |
ePlacementToPlacement(de.upb.swt.swtpra2017.swtinterface.Placement ePlacement)
Translates an EMF Placement object into a GameModel Placement object.
|
static Placement |
ePlacementToPlacement(de.upb.swt.swtpra2017.swtinterface.Placement ePlacement,
Player player)
Translates an EMF Placement object into a GameModel Placement object using
a Tile object of the player passed and removing it from that player's hand.
|
static Position |
ePositionToPosition(de.upb.swt.swtpra2017.swtinterface.Position ePos)
takes an EMF Position object and outputs the equivalent GameModel Position object
|
static Rotation |
eRotationToRotation(de.upb.swt.swtpra2017.swtinterface.Rotation eRotation) |
static Tile |
eTileToTile(de.upb.swt.swtpra2017.swtinterface.Tile eTile)
Translates an EMF Tile object into a GameModel Tile object, setting it's rotation to NORTH
|
static Token |
eTokenToToken(de.upb.swt.swtpra2017.swtinterface.Token eToken)
Translates an EMF Token object into a GameModel Token object.
|
static de.upb.swt.swtpra2017.swtinterface.FinishedReason |
finishedReasonToEFinishedReason(FinishedReason finishedReason) |
static de.upb.swt.swtpra2017.swtinterface.GameState |
gameStateToEGameState(GameState gameState) |
static de.upb.swt.swtpra2017.swtinterface.Gate |
gateToEGate(Gate gate) |
static de.upb.swt.swtpra2017.swtinterface.Player |
getCashedEPlayerById(int clientId,
GameModel gameModel)
Returns an EMF Player object from a specific GameModel by Id using the existing
EMF translation of the GameModel.
|
static String |
getEObjectClassName(org.eclipse.emf.ecore.EObject object)
Returns the simple class name of the object passed cutting of
every suffix starting with '*'.
|
static de.upb.swt.swtpra2017.swtinterface.JoinResponse |
joinResponseToEJoinResponse(JoinResponse joinResponse) |
static de.upb.swt.swtpra2017.swtinterface.KickReason |
kickStateToEKickReason(KickState kickState) |
static de.upb.swt.swtpra2017.swtinterface.Placement |
placementToEPlacement(Placement placement)
Translates a GameModel Placement object into an EMF Placement object.
|
static de.upb.swt.swtpra2017.swtinterface.Player |
playerToEPlayer(Player player)
creates an EMF Player object from a GameModel Player object
|
static de.upb.swt.swtpra2017.swtinterface.Position |
positionToEPosition(Position pos)
Takes a GameModel Position object and outputs the equivalent EMF Position object.
|
static de.upb.swt.swtpra2017.swtinterface.ClientRole |
roleToEClientRole(Role role) |
static de.upb.swt.swtpra2017.swtinterface.Rotation |
rotationToERotation(Rotation rotation) |
static de.upb.swt.swtpra2017.swtinterface.Tile |
tileToETile(Tile tile)
Translates a GameModel Tile object into an EMF Tile object, ignoring it's rotation
|
static de.upb.swt.swtpra2017.swtinterface.Token |
tokenToEToken(Token token)
Translates a GameModel Token object into an EMF Token object.
|
static List<Game> |
translateIntoGameList(org.eclipse.emf.common.util.EList<de.upb.swt.swtpra2017.swtinterface.Game> eGameList)
Translates an EList of EMF Game objects into a List of GameModel Game objects.
|
static GameModel |
translateIntoGameModel(de.upb.swt.swtpra2017.swtinterface.GameStateNotification n)
Generates a new GameModel from a given GameStateNotification.
|
static de.upb.swt.swtpra2017.swtinterface.GameStateNotification |
translateIntoGameStateNotification(GameModel gameModel)
Outputs a GameStateNotification containing the information of the gameModel passed.
|
static void |
updateGameModelByNotification(GameModel model,
org.eclipse.emf.ecore.EObject inputObject)
To be used on the client's side.
|
public static de.upb.swt.swtpra2017.swtinterface.GameStateNotification translateIntoGameStateNotification(GameModel gameModel)
gameModel
- the GameModel to take the information frompublic static de.upb.swt.swtpra2017.swtinterface.Player getCashedEPlayerById(int clientId, GameModel gameModel)
clientId
- the clientId of the player to be returnedgameModel
- the GameModel object that contains the playerpublic static GameModel translateIntoGameModel(de.upb.swt.swtpra2017.swtinterface.GameStateNotification n)
n
- the GameStateNotification to get the data frompublic static List<Game> translateIntoGameList(org.eclipse.emf.common.util.EList<de.upb.swt.swtpra2017.swtinterface.Game> eGameList)
eGameList
- the EList that should be translated into a List of GameModel Game objectspublic static void updateGameModelByNotification(GameModel model, org.eclipse.emf.ecore.EObject inputObject)
model
- the GameModel to be updatedinputObject
- the EMF notification object providing the new data (must be one of the notifications listed in the description)public static Position ePositionToPosition(de.upb.swt.swtpra2017.swtinterface.Position ePos)
ePos
- the EMF Position objectpublic static de.upb.swt.swtpra2017.swtinterface.Position positionToEPosition(Position pos)
pos
- the GameModel Position objectpublic static Configuration eConfigurationToConfiguration(de.upb.swt.swtpra2017.swtinterface.Configuration eConfig)
translateIntoGameModel
.eConfig
- the EMF Configuration object to be usedpublic static de.upb.swt.swtpra2017.swtinterface.Configuration configurationToEConfiguration(Configuration config)
config
- the GameModel Configuration object to be translatedpublic static Rotation eRotationToRotation(de.upb.swt.swtpra2017.swtinterface.Rotation eRotation)
public static de.upb.swt.swtpra2017.swtinterface.Rotation rotationToERotation(Rotation rotation)
public static Gate eGateToGate(de.upb.swt.swtpra2017.swtinterface.Gate eGate)
public static de.upb.swt.swtpra2017.swtinterface.Gate gateToEGate(Gate gate)
public static GameState eGameStateToGameState(de.upb.swt.swtpra2017.swtinterface.GameState eGameState)
public static de.upb.swt.swtpra2017.swtinterface.GameState gameStateToEGameState(GameState gameState)
public static FinishedReason eFinishedReasonToFinishedReason(de.upb.swt.swtpra2017.swtinterface.FinishedReason eFinishedReason)
public static de.upb.swt.swtpra2017.swtinterface.FinishedReason finishedReasonToEFinishedReason(FinishedReason finishedReason)
public static JoinResponse eJoinResponseToJoinResponse(de.upb.swt.swtpra2017.swtinterface.JoinResponse eJoinResponse)
public static de.upb.swt.swtpra2017.swtinterface.JoinResponse joinResponseToEJoinResponse(JoinResponse joinResponse)
public static KickState eKickReasonToKickState(de.upb.swt.swtpra2017.swtinterface.KickReason eKickReason)
public static de.upb.swt.swtpra2017.swtinterface.KickReason kickStateToEKickReason(KickState kickState)
public static de.upb.swt.swtpra2017.swtinterface.ClientRole roleToEClientRole(Role role)
public static Role eClientRoleToRole(de.upb.swt.swtpra2017.swtinterface.ClientRole eClientRole)
public static Token eTokenToToken(de.upb.swt.swtpra2017.swtinterface.Token eToken)
eToken
- the EMF Token object to be translatedpublic static de.upb.swt.swtpra2017.swtinterface.Token tokenToEToken(Token token)
token
- the GameModel Token object to be translatedpublic static Tile eTileToTile(de.upb.swt.swtpra2017.swtinterface.Tile eTile)
eTile
- the EMF Tile object to be translatedpublic static de.upb.swt.swtpra2017.swtinterface.Tile tileToETile(Tile tile)
tile
- the GameModel Tile objectpublic static Placement ePlacementToPlacement(de.upb.swt.swtpra2017.swtinterface.Placement ePlacement, Player player)
ePlacement
- the EMF Placement object to be usedplayer
- the GameModel Player object of the player who placed the tilepublic static Placement ePlacementToPlacement(de.upb.swt.swtpra2017.swtinterface.Placement ePlacement)
ePlacement
- the EMF Placement object to be usedpublic static de.upb.swt.swtpra2017.swtinterface.Placement placementToEPlacement(Placement placement)
placement
- the GameModel Placement object to be usedpublic static de.upb.swt.swtpra2017.swtinterface.Player playerToEPlayer(Player player)
player
- the GameModel player object to be usedpublic static String getEObjectClassName(org.eclipse.emf.ecore.EObject object)
object
- the object to get the class name ofCopyright © 2017 smarTen. All rights reserved.