001 /** 002 * Copyright 2005-2014 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 */ 016 package org.kuali.rice.krad.datadictionary.exporter; 017 018 import java.util.Collections; 019 import java.util.Map; 020 021 /* 022 * An ExportMap represents an entry or definition from the dataDictionary as a Map of the contents of that entry or definintion, and 023 * the key by which that entry or definition will be stored in the parent Map. 024 * 025 * 026 */ 027 @Deprecated 028 public class ExportMap { 029 private final String exportKey; 030 private final StringMap exportData; 031 032 public ExportMap(String exportKey) { 033 this.exportKey = exportKey; 034 this.exportData = new StringMap(); 035 } 036 037 /** 038 * @return exportKey associated with this instance 039 */ 040 public String getExportKey() { 041 return this.exportKey; 042 } 043 044 /** 045 * @return unmodifiable copy of the exportData associated with this Map 046 */ 047 public Map<String, Object> getExportData() { 048 return Collections.unmodifiableMap(this.exportData); 049 } 050 051 /** 052 * Adds the ExportMap's exportKey and exportData as a key,value pair to this Map 053 */ 054 public void set(ExportMap map) { 055 if (map == null) { 056 throw new IllegalArgumentException("invalid (null) map"); 057 } 058 059 exportData.set(map.getExportKey(), map.getExportData()); 060 } 061 062 /** 063 * If the given map is not null, adds the ExportMap's exportKey and exportData as a key,value pair to this Map. 064 */ 065 public void setOptional(ExportMap map) { 066 if (map != null) { 067 set(map); 068 } 069 } 070 071 /** 072 * Adds the given key,value pair to this Map 073 * 074 * @param key 075 * @param value 076 */ 077 public void set(String key, String value) { 078 if (key == null) { 079 throw new IllegalArgumentException("invalid (null) key"); 080 } 081 if (value == null) { 082 throw new IllegalArgumentException("invalid (null) value - key=" + key); 083 } 084 085 exportData.set(key, value); 086 } 087 088 /** 089 * @see java.lang.Object#toString() 090 */ 091 public String toString() { 092 return this.exportKey + "(" + this.exportData.size() + " children)"; 093 } 094 }