Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ExportMap |
|
| 2.0;2 |
1 | /* | |
2 | * Copyright 2005-2007 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php | |
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.kuali.rice.krad.datadictionary.exporter; | |
17 | ||
18 | import java.util.Collections; | |
19 | import java.util.Map; | |
20 | ||
21 | /* | |
22 | * An ExportMap represents an entry or definition from the dataDictionary as a Map of the contents of that entry or definintion, and | |
23 | * the key by which that entry or definition will be stored in the parent Map. | |
24 | * | |
25 | * | |
26 | */ | |
27 | public class ExportMap { | |
28 | private final String exportKey; | |
29 | private final StringMap exportData; | |
30 | ||
31 | 0 | public ExportMap(String exportKey) { |
32 | 0 | this.exportKey = exportKey; |
33 | 0 | this.exportData = new StringMap(); |
34 | 0 | } |
35 | ||
36 | ||
37 | /** | |
38 | * @return exportKey associated with this instance | |
39 | */ | |
40 | public String getExportKey() { | |
41 | 0 | return this.exportKey; |
42 | } | |
43 | ||
44 | /** | |
45 | * @return unmodifiable copy of the exportData associated with this Map | |
46 | */ | |
47 | public Map getExportData() { | |
48 | 0 | return Collections.unmodifiableMap(this.exportData); |
49 | } | |
50 | ||
51 | ||
52 | /** | |
53 | * Adds the ExportMap's exportKey and exportData as a key,value pair to this Map | |
54 | * | |
55 | * @param key | |
56 | * @param value | |
57 | */ | |
58 | public void set(ExportMap map) { | |
59 | 0 | if (map == null) { |
60 | 0 | throw new IllegalArgumentException("invalid (null) map"); |
61 | } | |
62 | ||
63 | 0 | exportData.set(map.getExportKey(), map.getExportData()); |
64 | 0 | } |
65 | ||
66 | /** | |
67 | * If the given map is not null, adds the ExportMap's exportKey and exportData as a key,value pair to this Map | |
68 | * | |
69 | * @param key | |
70 | * @param value | |
71 | */ | |
72 | public void setOptional(ExportMap map) { | |
73 | 0 | if (map != null) { |
74 | 0 | set(map); |
75 | } | |
76 | 0 | } |
77 | ||
78 | /** | |
79 | * Adds the given key,value pair to this Map | |
80 | * | |
81 | * @param key | |
82 | * @param value | |
83 | */ | |
84 | public void set(String key, String value) { | |
85 | 0 | if (key == null) { |
86 | 0 | throw new IllegalArgumentException("invalid (null) key"); |
87 | } | |
88 | 0 | if (value == null) { |
89 | 0 | throw new IllegalArgumentException("invalid (null) value - key=" + key); |
90 | } | |
91 | ||
92 | 0 | exportData.set(key, value); |
93 | 0 | } |
94 | ||
95 | ||
96 | /** | |
97 | * @see java.lang.Object#toString() | |
98 | */ | |
99 | public String toString() { | |
100 | 0 | return this.exportKey + "(" + this.exportData.size() + " children)"; |
101 | } | |
102 | } |