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 java.util.Collections;
019import 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
028public 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    /**
039     * @return exportKey associated with this instance
040     */
041    public String getExportKey() {
042        return this.exportKey;
043    }
044
045    /**
046     * @return unmodifiable copy of the exportData associated with this Map
047     */
048    public Map<String, Object> getExportData() {
049        return Collections.unmodifiableMap(this.exportData);
050    }
051
052
053    /**
054     * Adds the ExportMap's exportKey and exportData as a key,value pair to this Map
055     */
056    public void set(ExportMap map) {
057        if (map == null) {
058            throw new IllegalArgumentException("invalid (null) map");
059        }
060
061        exportData.set(map.getExportKey(), map.getExportData());
062    }
063
064    /**
065     * If the given map is not null, adds the ExportMap's exportKey and exportData as a key,value pair to this Map.
066     */
067    public void setOptional(ExportMap map) {
068        if (map != null) {
069            set(map);
070        }
071    }
072
073    /**
074     * Adds the given key,value pair to this Map
075     * 
076     * @param key
077     * @param value
078     */
079    public void set(String key, String value) {
080        if (key == null) {
081            throw new IllegalArgumentException("invalid (null) key");
082        }
083        if (value == null) {
084            throw new IllegalArgumentException("invalid (null) value - key=" + key);
085        }
086
087        exportData.set(key, value);
088    }
089
090
091    /**
092     * @see java.lang.Object#toString()
093     */
094    public String toString() {
095        return this.exportKey + "(" + this.exportData.size() + " children)";
096    }
097}