I have an abstract class to be used as a template for my programs. This abstract class has a constructor that currently accepts 7 booleans, each defining whether or not a certain module will be used and should be enabled (constructed). Instead of passing 7 booleans to this super constructor, I thought about passing a list of strings or a string of characters that match up to a module to enable. This seems like a bad workaround for what I want since it requires memorizing the module codes (They would be in the javadocs, but is still not my preference). My next thought is to use annotations for each module you want to enable. Each module would have an annotation associated with it, and the super constructor would read the subclasses annotations to determine what to enable. Is there any proper or elegant way to do this module system? I feel like all of these systems are not optimal.
Super class:
public Template(boolean commands, boolean config, boolean listeners, boolean logging, boolean permissions, boolean reflection, boolean threads) {
this.commandManager = commands ? new CommandManager(this) : null;
this.configManager = config ? new ConfigManager(this) : null;
/*...*/
}
public CommandManager getCommandManager() {
return this.commandManager;
}
Subclass that uses commands and permissions (alternate calls shown in comments)
public SubTemplate() {
super(true, false, false, false, true, false, false);
//super({"commands", "permissions"});
//super("Cp"); C being commands, p being permissions
}