Created
March 5, 2012 16:38
-
-
Save NickHeiner/1979177 to your computer and use it in GitHub Desktop.
transactions via closures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getInvadeStartInstanceTransaction(long defendingPlayerId, long invadingPlayerId, Long defendingPlayerInstanceId, int defendingPlayerFloorCount) { | |
return new Transact<InstanceEntity>() { | |
@Override | |
public void run(DAOT daot) { | |
InstanceEntity instance = | |
defendingPlayerInstanceId != null | |
? daot.getInstanceEntity(defendingPlayerInstanceId) | |
: new InstanceEntity(defendingPlayerId, defendingPlayerFloorCount); | |
instance.addInvadingPlayer(invadingPlayerId); | |
instance.setCurrentFloor(invadingPlayerId, 0); | |
daot.put(instance); | |
result = instance; | |
} | |
}; | |
} | |
Transact<InstanceEntity> invadeStart = getInvadeStartTransaction(foo, bar, baz, batz); | |
// ... | |
invadeStart.result(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment