001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.dynamicdatamapping.util;
016    
017    import com.liferay.portal.kernel.util.ListUtil;
018    
019    import java.util.HashMap;
020    import java.util.List;
021    import java.util.Map;
022    import java.util.Set;
023    
024    /**
025     * @author Eduardo Garcia
026     */
027    public class DDMDisplayRegistryImpl implements DDMDisplayRegistry {
028    
029            @Override
030            public DDMDisplay getDDMDisplay(String portletId) {
031                    return _ddmDisplays.get(portletId);
032            }
033    
034            @Override
035            public List<DDMDisplay> getDDMDisplays() {
036                    return ListUtil.fromMapValues(_ddmDisplays);
037            }
038    
039            @Override
040            public String[] getPortletIds() {
041                    Set<String> portletIds = _ddmDisplays.keySet();
042    
043                    return portletIds.toArray(new String[portletIds.size()]);
044            }
045    
046            @Override
047            public void register(DDMDisplay ddmDisplay) {
048                    _ddmDisplays.put(ddmDisplay.getPortletId(), ddmDisplay);
049            }
050    
051            @Override
052            public void unregister(DDMDisplay ddmDisplay) {
053                    _ddmDisplays.remove(ddmDisplay.getPortletId());
054            }
055    
056            private Map<String, DDMDisplay> _ddmDisplays =
057                    new HashMap<String, DDMDisplay>();
058    
059    }