id prefixes are now done at the very last moment instead of when an item is added.
[xmlrouter] / impl / src / main / java / org / wamblee / xmlrouter / impl / ConfigImpl.java
index a1733ab41bf84a9b84cb3986f460586871bd763e..0e1da0be84853fb6b7690d5ddecfef1f1bd3c3ed 100644 (file)
@@ -37,18 +37,41 @@ import org.wamblee.xmlrouter.config.Identifiable;
 public abstract class ConfigImpl<T extends Identifiable<T>> implements
     ExtendedConfig<T> {
 
+    private Class<T> type;
     private Id<Config> id;
     private Map<Id<T>, T> registered;
 
     /**
      * Constructs the object.
      */
-    public ConfigImpl(Id<Config> aId) {
+    public ConfigImpl(Class<T> aType, Id<Config> aId) {
+        notNull("type", aType);
         notNull("id", aId);
+        type = aType;
         id = aId;
         registered = new HashMap<Id<T>, T>();
     }
 
+    @Override
+    public Class<T> getType() {
+        return type;
+    }
+
+    /**
+     * Copies the config object.
+     * 
+     * @param aConfig
+     *            Config to copy.
+     */
+    public ConfigImpl(ConfigImpl<T> aConfig) {
+        notNull("config", aConfig);
+        id = aConfig.id;
+        registered = new HashMap<Id<T>, T>();
+        for (Map.Entry<Id<T>, T> entry : aConfig.registered.entrySet()) {
+            registered.put(entry.getKey(), entry.getValue());
+        }
+    }
+
     @Override
     public Id<Config> getId() {
         return id;