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
@@ -108,7 +108,7 @@ public final class StatSet extends DSet<Stat>
updateStat(stat); updateStat(stat);
} }
} }
/** /**
* Adds a string value to a {@link StringSetStat}. * Adds a string value to a {@link StringSetStat}.
* *
@@ -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}.
* *
@@ -172,7 +190,7 @@ public final class StatSet extends DSet<Stat>
IntArrayStat stat = (IntArrayStat)get(type.name()); IntArrayStat stat = (IntArrayStat)get(type.name());
return (stat == null) ? new int[0] : stat.getValue(); return (stat == null) ? new int[0] : stat.getValue();
} }
/** /**
* Returns true if the specified {@link StringSetStat} contains the specified value, false * Returns true if the specified {@link StringSetStat} contains the specified value, false
* otherwise. * otherwise.