com.threerings.config
Class ConfigGroup<T extends ManagedConfig>

java.lang.Object
  extended by com.threerings.config.ConfigGroup<T>
All Implemented Interfaces:
Exportable, Copyable

public class ConfigGroup<T extends ManagedConfig>
extends Object
implements Copyable, Exportable

Contains a group of managed configurations, all of the same class.


Constructor Summary
ConfigGroup()
          No-arg constructor for deserialization.
ConfigGroup(Class<T> clazz)
          Creates a new config group for the specified class.
 
Method Summary
 void addConfig(T config)
          Adds a configuration to the set.
 void addConfigs(Collection<T> configs)
          Adds all of the supplied configurations to the set.
 void addListener(ConfigGroupListener<T> listener)
          Adds a listener for configuration events.
 Object copy(Object dest)
          Creates a copy of this object, (re)populating the supplied destination object if possible.
 Object copy(Object dest, Object outer)
          Creates a copy of this object, (re)populating the supplied destination object if possible.
 T getConfig(String name)
          Retrieves a configuration by name.
 Class<T> getConfigClass()
          Returns the class of the configurations in this group.
 Collection<T> getConfigs()
          Returns the collection of all registered configurations.
 String getName()
          Returns the name of this group.
static String getName(Class<?> clazz)
          Returns the group name for the specified config class.
 void init(ConfigManager cfgmgr)
          Initializes this group.
 void load(File file)
          Loads the configurations from the specified file.
 void load(File file, boolean merge)
          Loads the configurations from the specified file.
 void readFields(Importer in)
          Reads the fields of this object.
 void removeConfig(T config)
          Removes a configuration from the set.
 void removeListener(ConfigGroupListener<T> listener)
          Removes a configuration event listener.
 void revert()
          Reverts to the last saved configurations.
 void save()
          Saves this group's configurations.
 void save(Collection<T> configs, File file)
          Saves the provided collection of configurations to a file.
 void save(File file)
          Saves this group's configurations to the specified file.
 void writeFields(Exporter out)
          Writes the fields of this object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigGroup

public ConfigGroup(Class<T> clazz)
Creates a new config group for the specified class.


ConfigGroup

public ConfigGroup()
No-arg constructor for deserialization.

Method Detail

getName

public static String getName(Class<?> clazz)
Returns the group name for the specified config class.


init

public void init(ConfigManager cfgmgr)
Initializes this group.


getName

public String getName()
Returns the name of this group.


getConfigClass

public Class<T> getConfigClass()
Returns the class of the configurations in this group.


getConfig

public T getConfig(String name)
Retrieves a configuration by name.


getConfigs

public Collection<T> getConfigs()
Returns the collection of all registered configurations.


addListener

public void addListener(ConfigGroupListener<T> listener)
Adds a listener for configuration events.


removeListener

public void removeListener(ConfigGroupListener<T> listener)
Removes a configuration event listener.


addConfigs

public void addConfigs(Collection<T> configs)
Adds all of the supplied configurations to the set.


addConfig

public void addConfig(T config)
Adds a configuration to the set.


removeConfig

public void removeConfig(T config)
Removes a configuration from the set.


save

public void save()
Saves this group's configurations.


save

public void save(File file)
Saves this group's configurations to the specified file.


save

public void save(Collection<T> configs,
                 File file)
Saves the provided collection of configurations to a file.


revert

public void revert()
Reverts to the last saved configurations.


load

public void load(File file)
Loads the configurations from the specified file.


load

public void load(File file,
                 boolean merge)
Loads the configurations from the specified file.

Parameters:
merge - if true, merge with the existing configurations; do not delete configurations that do not exist in the file.

writeFields

public void writeFields(Exporter out)
                 throws IOException
Writes the fields of this object.

Throws:
IOException

readFields

public void readFields(Importer in)
                throws IOException
Reads the fields of this object.

Throws:
IOException

copy

public Object copy(Object dest)
Description copied from interface: Copyable
Creates a copy of this object, (re)populating the supplied destination object if possible.

Specified by:
copy in interface Copyable
Returns:
either a reference to the destination object, if it could be repopulated, or a new object containing the copied state.

copy

public Object copy(Object dest,
                   Object outer)
Description copied from interface: Copyable
Creates a copy of this object, (re)populating the supplied destination object if possible.

Specified by:
copy in interface Copyable
outer - the outer object reference to use for inner object creation, if any.
Returns:
either a reference to the destination object, if it could be repopulated, or a new object containing the copied state.


Copyright © 2011. All Rights Reserved.