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.settings;
016    
017    import java.util.HashMap;
018    import java.util.Locale;
019    import java.util.Map;
020    
021    /**
022     * @author Iv??n Zaera
023     */
024    public class LocalizedValuesMap {
025    
026            public LocalizedValuesMap() {
027                    this(null);
028            }
029    
030            public LocalizedValuesMap(String defaultValue) {
031                    _defaultValue = defaultValue;
032            }
033    
034            public String get(Locale locale) {
035                    String value = _values.get(locale);
036    
037                    if (value == null) {
038                            value = _defaultValue;
039                    }
040    
041                    return value;
042            }
043    
044            public String getDefaultValue() {
045                    return _defaultValue;
046            }
047    
048            public Map<Locale, String> getValues() {
049                    return new HashMap<>(_values);
050            }
051    
052            public void put(Locale locale, String value) {
053                    _values.put(locale, value);
054            }
055    
056            private final String _defaultValue;
057            private final Map<Locale, String> _values = new HashMap<>();
058    
059    }