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