1 /**
2 * Copyright 2005-2012 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 org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.krad.exception.DuplicateKeyException;
20
21 import java.util.LinkedHashMap;
22 import java.util.Map;
23
24
25 /**
26 * Adds a litle strong type-checking and validation on top of the generic LinkedHashMap
27 *
28 *
29 */
30 @Deprecated
31 public class StringMap extends LinkedHashMap<String, Object> {
32 private static final long serialVersionUID = 7364206011639131063L;
33
34 /**
35 * Associates the given String with the given Map value.
36 *
37 * @param key
38 * @param value
39 */
40 public void set(String key, Map<String, Object> value) {
41 setUnique(key, value);
42 }
43
44 /**
45 * Associates the given String with the given String value.
46 *
47 * @param key
48 * @param value
49 */
50 public void set(String key, String value) {
51 setUnique(key, value);
52 }
53
54
55 /**
56 * Verifies that the key isn't blank, and that the value isn't null, and prevents duplicate keys from being used.
57 *
58 * @param key
59 * @param value
60 */
61 private void setUnique(String key, Object value) {
62 if (value == null) {
63 throw new IllegalArgumentException("invalid (null) value");
64 }
65
66 if (containsKey(key)) {
67 throw new DuplicateKeyException("duplicate key '" + key + "'");
68 }
69
70 super.put(key, value);
71 }
72
73 @Override
74 public Object put(String key, Object value) {
75 throw new UnsupportedOperationException("direct calls to put not supported");
76 }
77
78 @Override
79 public void putAll(Map<? extends String, ? extends Object> m) {
80 throw new UnsupportedOperationException("direct calls to put not supported");
81 }
82 }