2b40e58a2e3ca2d7558a5cf2aaac538d7df5dfb0
[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.Config;
22 import org.wamblee.xmlrouter.config.DocumentType;
23 import org.wamblee.xmlrouter.config.Filter;
24 import org.wamblee.xmlrouter.config.RouterConfig;
25 import org.wamblee.xmlrouter.config.Transformation;
26
27 // TODO test this class.
28 public class CompositeRouterConfig implements ExtendedRouterConfig {
29
30     private Id<RouterConfig> id;
31     private CompositeConfig<DocumentType> documentTypes;
32     private CompositeConfig<Transformation> transformations;
33     private CompositeConfig<Filter> filters;
34
35     public CompositeRouterConfig(Id<RouterConfig> aId,
36         Collection<RouterConfig> aConfigs) {
37         id = aId;
38         documentTypes = new CompositeConfig<DocumentType>(new Id<Config>(
39             "documentTypes"));
40         transformations = new CompositeConfig<Transformation>(new Id<Config>(
41             "transformations"));
42         filters = new CompositeConfig<Filter>(new Id<Config>("filters"));
43         for (RouterConfig config : aConfigs) {
44             documentTypes.add(config.documentTypeConfig());
45             transformations.add(config.transformationConfig());
46             filters.add(config.filterConfig());
47         }
48     }
49
50     // TODO test id.
51
52     @Override
53     public Id<RouterConfig> getId() {
54         return id;
55     }
56
57     @Override
58     public Config<DocumentType> documentTypeConfig() {
59         return documentTypes;
60     }
61
62     @Override
63     public Config<Transformation> transformationConfig() {
64         return transformations;
65     }
66
67     @Override
68     public Config<Filter> filterConfig() {
69         return filters;
70     }
71 }