001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.portlet;
016    
017    import com.liferay.portal.kernel.util.Validator;
018    
019    import java.util.HashMap;
020    import java.util.Map;
021    
022    import javax.portlet.WindowState;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class WindowStateFactory {
028    
029            public static WindowState getWindowState(String name) {
030                    return _instance._getWindowState(name);
031            }
032    
033            private WindowStateFactory() {
034                    _windowStates = new HashMap<>();
035    
036                    _windowStates.put(_NORMAL, LiferayWindowState.NORMAL);
037                    _windowStates.put(_MAXIMIZED, LiferayWindowState.MAXIMIZED);
038                    _windowStates.put(_MINIMIZED, LiferayWindowState.MINIMIZED);
039                    _windowStates.put(_EXCLUSIVE, LiferayWindowState.EXCLUSIVE);
040                    _windowStates.put(_POP_UP, LiferayWindowState.POP_UP);
041            }
042    
043            private WindowState _getWindowState(String name) {
044                    if (Validator.isNull(name)) {
045                            return WindowState.NORMAL;
046                    }
047    
048                    WindowState windowState = _windowStates.get(name);
049    
050                    if (windowState == null) {
051                            windowState = new WindowState(name);
052                    }
053    
054                    return windowState;
055            }
056    
057            private static final String _EXCLUSIVE =
058                    LiferayWindowState.EXCLUSIVE.toString();
059    
060            private static final String _MAXIMIZED = WindowState.MAXIMIZED.toString();
061    
062            private static final String _MINIMIZED = WindowState.MINIMIZED.toString();
063    
064            private static final String _NORMAL = WindowState.NORMAL.toString();
065    
066            private static final String _POP_UP = LiferayWindowState.POP_UP.toString();
067    
068            private static final WindowStateFactory _instance =
069                    new WindowStateFactory();
070    
071            private final Map<String, WindowState> _windowStates;
072    
073    }