1 package org.andromda.core.namespace;
2
3 import java.util.Arrays;
4 import java.util.Collection;
5 import java.util.LinkedHashSet;
6 import org.andromda.core.common.ClassUtils;
7
8
9
10
11
12
13 public class Component
14 {
15
16
17
18 private String name;
19
20
21
22
23
24
25 public String getName()
26 {
27 return name;
28 }
29
30
31
32
33
34
35 public void setName(final String name)
36 {
37 this.name = name;
38 }
39
40
41
42
43 private final Collection<String> paths = new LinkedHashSet<String>();
44
45
46
47
48
49
50
51 public String[] getPaths()
52 {
53 return paths.toArray(new String[paths.size()]);
54 }
55
56
57
58
59
60
61 public void addPath(final String path)
62 {
63 this.paths.add(path);
64 }
65
66
67
68
69
70
71
72 final void addPaths(final String[] paths)
73 {
74 if (paths != null && paths.length > 0)
75 {
76 this.paths.addAll(Arrays.asList(paths));
77 }
78 }
79
80
81
82
83 private Class type;
84
85
86
87
88
89
90 public void setTypeClass(final String typeClass)
91 {
92 final Class type = ClassUtils.loadClass(typeClass);
93 if (!NamespaceComponent.class.isAssignableFrom(type))
94 {
95 throw new NamespaceComponentsException(
96 "namespace component '" + type + "' must implement --> '" + NamespaceComponent.class.getName() + '\'');
97 }
98 this.type = type;
99 }
100
101
102
103
104
105
106 public Class getType()
107 {
108 return this.type;
109 }
110 }