Config no longer implements Identifiable because this was in violation of the contrac...
[xmlrouter] / impl / src / main / java / org / wamblee / xmlrouter / impl / CompositeConfig.java
index 0c6100dc3fc82c2c9a4484bc2af21e258e84d7a0..3b45a3ef25b5d35d395e8703bafec1db0f1946cd 100644 (file)
@@ -23,8 +23,6 @@ import java.util.List;
 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;
 
 /**
@@ -37,17 +35,17 @@ 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>();
     }
@@ -58,17 +56,17 @@ public class CompositeConfig<T extends Identifiable<T>> implements
     }
 
     @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)) {
@@ -77,7 +75,7 @@ public class CompositeConfig<T extends Identifiable<T>> implements
             }
         }
 
-        ids.add(aConfig.getId());
+        prefixes.add(aConfig.getPrefix());
 
         for (T item : aConfig.values()) {
             Id<T> newId = new Id<T>(prefix + item.getId());