added copying of SingleRouterConfig.
[xmlrouter] / impl / src / main / java / org / wamblee / xmlrouter / impl / SingleRouterConfig.java
index 8eab34b708996198b73c4cbfd271462937ff1119..deb38f6656fcd39ea9f3bf37e4768b23a94431cb 100644 (file)
@@ -31,11 +31,59 @@ import org.wamblee.xmlrouter.config.Transformation;
  * @author Erik Brakkee
  */
 public class SingleRouterConfig implements ExtendedRouterConfig {
+
+    public static final class DocumentConfig extends ConfigImpl<DocumentType> {
+        public DocumentConfig(Id<Config> aId) {
+            super(aId);
+        }
+
+        public DocumentConfig(DocumentConfig aConfig) {
+            super(aConfig);
+        }
+
+        @Override
+        public DocumentType wrap(String aPrefix, DocumentType aT) {
+            return new RobustDocumentType(aPrefix, aT);
+        }
+    }
+
+    public static final class TransformationConfig extends
+        ConfigImpl<Transformation> {
+        public TransformationConfig(Id<Config> aId) {
+            super(aId);
+        }
+
+        public TransformationConfig(TransformationConfig aConfig) {
+            super(aConfig);
+        }
+
+        @Override
+        public Transformation wrap(String aPrefix,
+            Transformation aTransformation) {
+            return new RobustTransformation(aPrefix, aTransformation);
+        }
+    }
+
+    public static final class FilterConfig extends ConfigImpl<Filter> {
+        public FilterConfig(Id<Config> aId) {
+            super(aId);
+        }
+
+        public FilterConfig(FilterConfig aConfig) {
+            super(aConfig);
+        }
+
+        @Override
+        public Filter wrap(String aPrefix, Filter aFilter) {
+            return new RobustFilter(aPrefix, aFilter);
+        }
+    }
+
     private Id<RouterConfig> id;
 
-    private ExtendedConfig<DocumentType> documentTypes;
-    private ExtendedConfig<Transformation> transformations;
-    private ExtendedConfig<Filter> filters;
+    private DocumentConfig documentTypes;
+    private TransformationConfig transformations;
+    private FilterConfig filters;
 
     /**
      * Constructs a router configuration.
@@ -45,28 +93,18 @@ public class SingleRouterConfig implements ExtendedRouterConfig {
      */
     public SingleRouterConfig(Id<RouterConfig> aId) {
         id = aId;
-        documentTypes = new ConfigImpl<DocumentType>(new Id<Config>(
-            aId.getId() + ".documenttypes")) {
-            @Override
-            public DocumentType wrap(String aPrefix, DocumentType aT) {
-                return new RobustDocumentType(aPrefix, aT);
-            }
-        };
-        transformations = new ConfigImpl<Transformation>(new Id<Config>(
-            aId.getId() + ".transformations")) {
-            @Override
-            public Transformation wrap(String aPrefix,
-                Transformation aTransformation) {
-                return new RobustTransformation(aPrefix, aTransformation);
-            }
-        };
-        filters = new ConfigImpl<Filter>(new Id<Config>(aId.getId() +
-            ".filters")) {
-            @Override
-            public Filter wrap(String aPrefix, Filter aFilter) {
-                return new RobustFilter(aPrefix, aFilter);
-            }
-        };
+        documentTypes = new DocumentConfig(new Id<Config>(aId.getId() +
+            ".documenttypes"));
+        transformations = new TransformationConfig(new Id<Config>(aId.getId() +
+            ".transformations"));
+        filters = new FilterConfig(new Id<Config>(aId.getId() + ".filters"));
+    }
+
+    public SingleRouterConfig(SingleRouterConfig aConfig) {
+        id = aConfig.id;
+        documentTypes = new DocumentConfig(aConfig.documentTypes);
+        transformations = new TransformationConfig(aConfig.transformations);
+        filters = new FilterConfig(aConfig.filters);
     }
 
     @Override