use of pcgen.output.base.ModeModelFactory in project pcgen by PCGen.
the class OutputDB method registerMode.
/**
* Registers a ModeModelFactory under the given name.
*
* Note that only one ModeModelFactory can be registered under a given (case
* insensitive) name. Additional items registered under the same name will
* cause an UnsupportedOperationException.
*
* @param name
* The Name the given ModeModelFactory should be registered under
* for use as an interpolation under gamemode. in FreeMarker
* @param factory
* The ModeModelFactory to be registered under the given name
*/
public static void registerMode(String name, ModeModelFactory factory) {
if (factory == null) {
throw new IllegalArgumentException("Model Factory may not be null");
}
int dotLoc = name.indexOf('.');
if (dotLoc != -1) {
throw new IllegalArgumentException("Name may not contain a dot: " + name);
}
ModeModelFactory old = modeModels.put(name, factory);
if (old != null) {
throw new UnsupportedOperationException("Cannot have two Mode Models using the same name: " + name);
}
}
use of pcgen.output.base.ModeModelFactory in project pcgen by PCGen.
the class OutputDB method buildModeDataModel.
/**
* Builds the "game mode" data model
*
* @return Returns a Map containing the "game mode" information
*/
public static Map<String, Object> buildModeDataModel(GameMode mode) {
Map<String, Object> input = new HashMap<>();
for (Object key : modeModels.keySet()) {
ModeModelFactory modelFactory = modeModels.get(key);
input.put(key.toString(), modelFactory.generate(mode));
}
return input;
}
Aggregations