1 package org.andromda.core.configuration;
2
3 import java.io.Serializable;
4 import java.util.ArrayList;
5 import java.util.Collection;
6 import java.util.LinkedHashMap;
7 import java.util.Map;
8
9
10
11
12
13
14 public class Namespace
15 implements Serializable
16 {
17 private static final long serialVersionUID = 34L;
18
19
20
21
22 private String name;
23
24
25
26
27
28
29
30 public String getName()
31 {
32 return this.name;
33 }
34
35
36
37
38
39
40 public void setName(final String name)
41 {
42 this.name = name;
43 }
44
45
46
47
48 private final Map<String, Collection<Property>> properties = new LinkedHashMap<String, Collection<Property>>();
49
50
51
52
53
54
55
56 public void addProperty(final Property property)
57 {
58 if (property != null)
59 {
60 Collection<Property> properties = this.properties.get(property.getName());
61 if (properties == null)
62 {
63 properties = new ArrayList<Property>();
64 this.properties.put(
65 property.getName(),
66 properties);
67 }
68 properties.add(property);
69 }
70 }
71
72
73
74
75
76
77
78
79 public Collection<Property> getProperties(final String name)
80 {
81 return this.properties.get(name);
82 }
83
84
85
86
87
88
89
90
91 public Property getProperty(final String name)
92 {
93 final Collection<Property> properties = this.getProperties(name);
94 return properties == null || properties.isEmpty() ?
95 null : properties.iterator().next();
96 }
97
98
99
100
101
102
103 public Collection<Collection<Property>> getProperties()
104 {
105 return this.properties.values();
106 }
107
108
109
110
111 public String toString()
112 {
113 return super.toString() + '[' + this.name + ']';
114 }
115 }