Config no longer implements Identifiable because this was in violation of the contrac...
[xmlrouter] / impl / src / main / java / org / wamblee / xmlrouter / impl / CompositeRouterConfig.java
1 /*
2  * Copyright 2005-2011 the original author or authors.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.wamblee.xmlrouter.impl;
17
18 import java.util.Collection;
19
20 import org.wamblee.xmlrouter.common.Id;
21 import org.wamblee.xmlrouter.config.DocumentType;
22 import org.wamblee.xmlrouter.config.Filter;
23 import org.wamblee.xmlrouter.config.Transformation;
24
25 public class CompositeRouterConfig implements ExtendedRouterConfig {
26
27     private static final Id<RouterConfig> ID = new Id<RouterConfig>(
28         "compositerouterconfig");
29     private CompositeConfig<DocumentType> documentTypes;
30     private CompositeConfig<Transformation> transformations;
31     private CompositeConfig<Filter> filters;
32
33     public CompositeRouterConfig(Id<RouterConfig> aId,
34         Collection<RouterConfig> aConfigs) {
35         documentTypes = new CompositeConfig<DocumentType>(DocumentType.class);
36         transformations = new CompositeConfig<Transformation>(
37             Transformation.class);
38         filters = new CompositeConfig<Filter>(Filter.class);
39         for (RouterConfig config : aConfigs) {
40             documentTypes.addConfig(config.documentTypeConfig());
41             transformations.addConfig(config.transformationConfig());
42             filters.addConfig(config.filterConfig());
43         }
44     }
45
46     @Override
47     public Id<RouterConfig> getId() {
48         return ID;
49     }
50
51     @Override
52     public Config<DocumentType> documentTypeConfig() {
53         return documentTypes;
54     }
55
56     @Override
57     public Config<Transformation> transformationConfig() {
58         return transformations;
59     }
60
61     @Override
62     public Config<Filter> filterConfig() {
63         return filters;
64     }
65 }