com.threerings.stats.data
Class StatModifier<T extends Stat>

java.lang.Object
  extended by com.threerings.stats.data.StatModifier<T>
All Implemented Interfaces:
Streamable
Direct Known Subclasses:
IntSetStatAdder, IntStatIncrementer, IntStatMinimumer

public abstract class StatModifier<T extends Stat>
extends Object
implements Streamable

Encapsulates a modification to a single stat that can be serialized and sent to a different server, if needed, to update stats loaded at runtime.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
Streamable.Closure
 
Field Summary
protected  Stat.Type _type
          The type of the stat on which we're operating.
 
Constructor Summary
protected StatModifier()
          Constructs an empty StatModifier (for Streaming purposes).
  StatModifier(Stat.Type type)
          Creates a modifier that will operate on the supplied stat type.
 
Method Summary
 Stat.Type getType()
          Returns the Stat.Type of the stat being modified.
abstract  void modify(T stat)
          Applies the modification to the stat in question.
 void readObject(ObjectInputStream in)
          Reads our custom streamable fields.
 void writeObject(ObjectOutputStream out)
          Writes our custom streamable fields.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_type

protected transient Stat.Type _type
The type of the stat on which we're operating.

Constructor Detail

StatModifier

public StatModifier(Stat.Type type)
Creates a modifier that will operate on the supplied stat type. Note that this type may be serialized and shipped between servers.


StatModifier

protected StatModifier()
Constructs an empty StatModifier (for Streaming purposes).

Method Detail

getType

public Stat.Type getType()
Returns the Stat.Type of the stat being modified.


writeObject

public void writeObject(ObjectOutputStream out)
                 throws IOException
Writes our custom streamable fields.

Throws:
IOException

readObject

public void readObject(ObjectInputStream in)
                throws IOException,
                       ClassNotFoundException
Reads our custom streamable fields.

Throws:
IOException
ClassNotFoundException

modify

public abstract void modify(T stat)
Applies the modification to the stat in question.