com.threerings.stats.data

## Class StatSet

- java.lang.Object
- - com.threerings.presents.dobj.DSet<Stat>
  - - com.threerings.stats.data.StatSet

All Implemented Interfaces:
  com.threerings.io.Streamable, Cloneable, Iterable<Stat>

    public class StatSet
    extends com.threerings.presents.dobj.DSet<Stat>

A distributed set containing `Stat` objects.

### Nested Class Summary

Nested Classes
`static interface` `StatSet.Container` An interface to be implemented by an entity that wishes to be notified when the contents of a stat set change.

### Nested classes/interfaces inherited from class com.threerings.presents.dobj.DSet

`com.threerings.presents.dobj.DSet.Entry`

### Nested classes/interfaces inherited from interface com.threerings.io.Streamable

`com.threerings.io.Streamable.Closure`

### Constructor Summary

Constructors
Constructor and Description
`StatSet()` Creates a blank stat set.
`StatSet(Iterable<Stat> contents)` Creates a stat set with the specified contents.
`StatSet(Iterator<Stat> contents)` Creates a stat set with the specified contents.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addQuietly(Stat stat)` Don't call this method, it's only needed by some tricky business we do when preventing distributed object event generation for all but the bounty criteria related stats.
`<T> void` `addToSetStat(Stat.Type type, T value)` Adds a value to a `SetStat`.
`void` `appendStat(Stat.Type type, int value)` Appends an integer value to an `IntArrayStat`.
`<T> boolean` `containsValue(Stat.Type type, T value)` Returns true if the specified `SetStat` contains the specified value, false otherwise.
`int[]` `getIntArrayStat(Stat.Type type)` Returns the current value of the specified integer array statistic.
`int` `getIntStat(Stat.Type type)` Returns the current value of the specified integer statistic.
`int` `getMapValue(Stat.Type type, String value)` Returns the value to which the specified string is mapped in a `StringMapStat` or zero if the value has not been mapped.
`int` `getMaxIntStat(Stat.Type type)` Returns the maximum value by which the specified integer statistic has ever been incremented.
`int` `getSetStatSize(Stat.Type type)` Returns the current size of the specified SetStat statistic.
`void` `incrementMapStat(Stat.Type type, String value, int amount)` Increments a string value in a `StringMapStat`.
`void` `incrementStat(Stat.Type type, int delta)` Increments an integer statistic in this set.
`void` `maxStat(Stat.Type type, int value)` Sets an integer stat to the specified value, if it exceeds our existing recorded value.
`void` `setContainer(StatSet.Container container)` Wires this stat set up to a containing user object.
`void` `setStat(Stat.Type type, int value)` Sets an integer statistic in this set.
`<T extends Stat> void` `syncStat(StatModifier<T> modifier)` Updates a stat in this set, using the supplied StatModifier.

### Methods inherited from class com.threerings.presents.dobj.DSet

`asSet, clone, compare, contains, containsKey, entries, get, isEmpty, iterator, newDSet, newDSet, readObject, size, toArray, toArray, toArrayList, toString, typedClone, writeObject`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.lang.Iterable

`forEach, spliterator`

### Constructor Detail

#### StatSet

    public StatSet(Iterable<Stat> contents)

Creates a stat set with the specified contents.

#### StatSet

    public StatSet(Iterator<Stat> contents)

Creates a stat set with the specified contents.

#### StatSet

    public StatSet()

Creates a blank stat set.

### Method Detail

#### setContainer

    public void setContainer(StatSet.Container container)

Wires this stat set up to a containing user object. All subsequent modifications will be published to the container.

#### syncStat

    public <T extends Stat> void syncStat(StatModifier<T> modifier)

Updates a stat in this set, using the supplied StatModifier. This function should only be called after a successful stat modification has been made to the StatRepository. It will increment the Stat's modCount, and won't set its dirty bit if it's not already set, to prevent the Stat from being re-written to the repo unnecessarily.

#### setStat

    public void setStat(Stat.Type type,
                        int value)

Sets an integer statistic in this set.

Throws:
  `ClassCastException` - thrown if the registered type of the specified stat is not an `IntStat`.

#### maxStat

    public void maxStat(Stat.Type type,
                        int value)

Sets an integer stat to the specified value, if it exceeds our existing recorded value.

Throws:
  `ClassCastException` - thrown if the registered type of the specified stat is not an `IntStat`.

#### incrementStat

    public void incrementStat(Stat.Type type,
                              int delta)

Increments an integer statistic in this set.

Throws:
  `ClassCastException` - thrown if the registered type of the specified stat is not an `IntStat`.

#### appendStat

    public void appendStat(Stat.Type type,
                           int value)

Appends an integer value to an `IntArrayStat`.

Throws:
  `ClassCastException` - thrown if the registered type of the specified stat is not an `IntArrayStat`.

#### addToSetStat

    public <T> void addToSetStat(Stat.Type type,
                                 T value)

Adds a value to a `SetStat`.

Throws:
  `ClassCastException` - thrown if the registered type of the specified stat is not an `SetStat` parameterized on the given type.

#### incrementMapStat

    public void incrementMapStat(Stat.Type type,
                                 String value,
                                 int amount)

Increments a string value in a `StringMapStat`.

Throws:
  `ClassCastException` - thrown if the registered type of the specified stat is not an `StringMapStat`.

#### getIntStat

    public int getIntStat(Stat.Type type)

Returns the current value of the specified integer statistic.

Throws:
  `ClassCastException` - thrown if the registered type of the specified stat is not an `IntStat`.

#### getMaxIntStat

    public int getMaxIntStat(Stat.Type type)

Returns the maximum value by which the specified integer statistic has ever been incremented.

Throws:
  `ClassCastException` - thrown if the registered type of the specified stat is not an `MaxIntStat`.

#### getIntArrayStat

    public int[] getIntArrayStat(Stat.Type type)

Returns the current value of the specified integer array statistic.

Throws:
  `ClassCastException` - thrown if the registered type of the specified stat is not an `IntArrayStat`.

#### getSetStatSize

    public int getSetStatSize(Stat.Type type)

Returns the current size of the specified SetStat statistic.

Throws:
  `ClassCastException` - thrown if the registered type of the specified stat is not an `SetStat`.

#### containsValue

    public <T> boolean containsValue(Stat.Type type,
                                     T value)

Returns true if the specified `SetStat` contains the specified value, false otherwise.

#### getMapValue

    public int getMapValue(Stat.Type type,
                           String value)

Returns the value to which the specified string is mapped in a `StringMapStat` or zero if the value has not been mapped.

#### addQuietly

    public void addQuietly(Stat stat)

Don't call this method, it's only needed by some tricky business we do when preventing distributed object event generation for all but the bounty criteria related stats.