import java.util.Set;
import org.wamblee.xmlrouter.common.Id;
-import org.wamblee.xmlrouter.config.Config;
-import org.wamblee.xmlrouter.config.ConfigException;
import org.wamblee.xmlrouter.config.Identifiable;
/**
public class CompositeConfig<T extends Identifiable<T>> implements
ExtendedConfig<T> {
- private static final Id<Config> ID = new Id<Config>("compositeconfig");
+ private static final String PREFIX = "compositeconfig";
private static final String READ_ONLY_INSTANCE = "read only instance";
private Class<T> type;
- private Set<Id<Config>> ids;
+ private Set<String> prefixes;
private List<Id<T>> valueIds;
private List<T> values;
public CompositeConfig(Class<T> aType) {
type = aType;
- ids = new HashSet<Id<Config>>();
+ prefixes = new HashSet<String>();
valueIds = new ArrayList<Id<T>>();
values = new ArrayList<T>();
}
}
@Override
- public Id<Config> getId() {
- return ID;
+ public String getPrefix() {
+ return PREFIX;
}
public void addConfig(Config<T> aConfig) {
notNull("aConfig", aConfig);
- if (ids.contains(aConfig.getId())) {
- throw new ConfigException("duplicate id '" +
- aConfig.getId().toString() + "'");
+ if (prefixes.contains(aConfig.getPrefix())) {
+ throw new ConfigException("duplicate prefix '" +
+ aConfig.getPrefix() + "'");
}
- String prefix = aConfig.getId().getId() + ".";
+ String prefix = aConfig.getPrefix() + ".";
for (T item : aConfig.values()) {
Id<T> newId = new Id<T>(prefix + item.getId());
if (valueIds.contains(newId)) {
}
}
- ids.add(aConfig.getId());
+ prefixes.add(aConfig.getPrefix());
for (T item : aConfig.values()) {
Id<T> newId = new Id<T>(prefix + item.getId());