001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.datadictionary.exporter; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.rice.krad.exception.DuplicateKeyException; 020 021import java.util.LinkedHashMap; 022import java.util.Map; 023 024 025/** 026 * Adds a litle strong type-checking and validation on top of the generic LinkedHashMap 027 * 028 * 029 */ 030@Deprecated 031public class StringMap extends LinkedHashMap<String, Object> { 032 private static final long serialVersionUID = 7364206011639131063L; 033 034 /** 035 * Associates the given String with the given Map value. 036 * 037 * @param key 038 * @param value 039 */ 040 public void set(String key, Map<String, Object> value) { 041 setUnique(key, value); 042 } 043 044 /** 045 * Associates the given String with the given String value. 046 * 047 * @param key 048 * @param value 049 */ 050 public void set(String key, String value) { 051 setUnique(key, value); 052 } 053 054 055 /** 056 * Verifies that the key isn't blank, and that the value isn't null, and prevents duplicate keys from being used. 057 * 058 * @param key 059 * @param value 060 */ 061 private void setUnique(String key, Object value) { 062 if (value == null) { 063 throw new IllegalArgumentException("invalid (null) value"); 064 } 065 066 if (containsKey(key)) { 067 throw new DuplicateKeyException("duplicate key '" + key + "'"); 068 } 069 070 super.put(key, value); 071 } 072 073 @Override 074 public Object put(String key, Object value) { 075 throw new UnsupportedOperationException("direct calls to put not supported"); 076 } 077 078 @Override 079 public void putAll(Map<? extends String, ? extends Object> m) { 080 throw new UnsupportedOperationException("direct calls to put not supported"); 081 } 082}