StatSet.addToSetStat, for IntSetStats

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@671 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Tom Conkling
2008-07-22 00:39:41 +00:00
parent 624daadcd9
commit ae8ec1e2ac
@@ -127,6 +127,24 @@ public final class StatSet extends DSet<Stat>
} }
} }
/**
* Adds an int value to a {@link IntSetStat}.
*
* @exception ClassCastException thrown if the registered type of the specified stat is not an
* {@link IntSetStat}.
*/
public void addToSetStat (Stat.Type type, int value)
{
IntSetStat stat = (IntSetStat)get(type.name());
if (stat == null) {
stat = (IntSetStat)type.newStat();
stat.add(value);
addStat(stat);
} else if (stat.add(value)) {
updateStat(stat);
}
}
/** /**
* Increments a string value in a {@link StringMapStat}. * Increments a string value in a {@link StringMapStat}.
* *