View Javadoc

1   /*
2    * Copyright 2007-2008 Naoki NOSE.
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 jp.liq.container.vocabulary;
17  
18  import java.util.List;
19  
20  import jp.liq.container.Component;
21  import jp.liq.container.Container;
22  import jp.liq.container.Module;
23  
24  public class ComponentsConfig {
25      public ComponentsModule configure(Container container) {
26          ComponentsModule module = new ComponentsModule();
27          container.include(module);
28          return module;
29      }
30      
31      public class ComponentsModule extends Module {
32  
33          /**
34           * 引数で指定されたコンポーネントを登録します。
35           * @param component 登録するコンポーネント
36           * @return 引数と同じオブジェクト
37           */
38          public <T> ComponentsModule define(Component<T> component) {
39              addComponent(component);
40              return this;
41          }
42  
43          /**
44           * 引数で指定されたコンポーネントのリストを登録します。
45           * このメソッドは、単に引数の Component のリストの各要素に対し、
46           * {@link #define(Component)} を呼出します。
47           * @param component
48           */
49          public final ComponentsModule define(List<? extends Component<?>> component) {
50              for (Component<?> c : component) {
51                  define(c);
52              }
53              return this;
54          }
55  
56      }
57  }