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;
17
18 /**
19 * コンポーネントの定義情報を表現します。
20 * @author nose
21 */
22 final class ComponentMetadata {
23
24 private static final String LS = System.getProperty("line.separator");
25
26 private final Component<?> component;
27
28 private final Module ownerModule;
29
30 /**
31 * このクラスの新しいインスタンスを構築します。
32 *
33 * @param comp
34 * このインスタンスが保持するコンポーネント
35 * @param owner
36 * このインスタンスを保持するモジュール
37 */
38 ComponentMetadata(Component<?> comp, Module owner) {
39 this.component = comp;
40 this.ownerModule = owner;
41 }
42
43 /**
44 * このコンポーネント定義情報が保持するコンポーネントを返します。
45 *
46 * @return
47 */
48 Component<?> getComponent() {
49 return component;
50 }
51
52 /**
53 * このコンポーネント定義情報が保持する Module を返します。
54 *
55 * @return
56 */
57 Module getOwnerModule() {
58 return ownerModule;
59 }
60
61 /**
62 * このインスタンスが保持するコンポーネントの説明を返します。
63 * @return コンポーネントの説明
64 */
65 String describe() {
66 StringBuffer rv = new StringBuffer();
67 rv.append("{");
68 rv.append(LS);
69 rv.append(" type: " + component.getType());
70 rv.append(LS);
71 rv.append(" owner module: ");
72 rv.append(ownerModule.getClass().getName());
73 rv.append(LS);
74 rv.append(" component type: ");
75 rv.append(component.getClass().getName());
76 rv.append(LS);
77 rv.append(" component detail: " + component.getDescription());
78 rv.append(LS);
79 rv.append('}');
80 return rv.toString();
81 }
82 }