StatRepository.updateStat returns the new value of the Stat if it was modified, rather than a boolean
git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@722 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -64,10 +64,10 @@ public class StatRepository extends DepotRepository
|
|||||||
* Applies a modification to a single stat. If the stat in question does not exist, a blank
|
* Applies a modification to a single stat. If the stat in question does not exist, a blank
|
||||||
* instance will be created via {@link Stat.Type#newStat}.
|
* instance will be created via {@link Stat.Type#newStat}.
|
||||||
*
|
*
|
||||||
* @return true if the stat was modified and written to the database, false if the modifier had
|
* @return the modified Stat, if any modification took place; or null if the modification had
|
||||||
* no effect on the stat's data.
|
* no effect on the stat's data.
|
||||||
*/
|
*/
|
||||||
public <T extends Stat> boolean updateStat (int playerId, StatModifier<T> modifier)
|
public <T extends Stat> T updateStat (int playerId, StatModifier<T> modifier)
|
||||||
throws PersistenceException
|
throws PersistenceException
|
||||||
{
|
{
|
||||||
Where where = new Where(StatRecord.PLAYER_ID_C, playerId,
|
Where where = new Where(StatRecord.PLAYER_ID_C, playerId,
|
||||||
@@ -80,10 +80,10 @@ public class StatRepository extends DepotRepository
|
|||||||
@SuppressWarnings("unchecked") T tstat = (T)stat;
|
@SuppressWarnings("unchecked") T tstat = (T)stat;
|
||||||
modifier.modify(tstat);
|
modifier.modify(tstat);
|
||||||
if (!tstat.isModified()) {
|
if (!tstat.isModified()) {
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
if (updateStat(playerId, stat, false)) {
|
if (updateStat(playerId, tstat, false)) {
|
||||||
return true;
|
return tstat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user