com.liferay.dynamic.data.mapping.kernel.UnlocalizedValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.portal.kernel Show documentation
Show all versions of com.liferay.portal.kernel Show documentation
Contains interfaces for the portal services. Interfaces are only loaded by the global class loader and are shared by all plugins.
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.dynamic.data.mapping.kernel;
import com.liferay.portal.kernel.util.LocaleUtil;
import com.liferay.portal.kernel.util.Validator;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
/**
* @author Marcellus Tavares
*/
public class UnlocalizedValue implements Value {
public UnlocalizedValue(String value) {
_values.put(LocaleUtil.ROOT, value);
}
public UnlocalizedValue(UnlocalizedValue unlocalizedValue) {
_values.put(
LocaleUtil.ROOT, unlocalizedValue.getString(LocaleUtil.ROOT));
}
@Override
public void addString(Locale locale, String value) {
_values.put(LocaleUtil.ROOT, value);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof UnlocalizedValue)) {
return false;
}
UnlocalizedValue unlocalizedValue = (UnlocalizedValue)obj;
if (Validator.equals(_values, unlocalizedValue._values)) {
return true;
}
return false;
}
@Override
public Set getAvailableLocales() {
return _values.keySet();
}
@Override
public Locale getDefaultLocale() {
return LocaleUtil.ROOT;
}
@Override
public String getString(Locale locale) {
return _values.get(LocaleUtil.ROOT);
}
@Override
public Map getValues() {
return _values;
}
@Override
public int hashCode() {
return _values.hashCode();
}
@Override
public boolean isLocalized() {
return false;
}
@Override
public void setDefaultLocale(Locale defaultLocale) {
throw new UnsupportedOperationException();
}
private final Map _values = new HashMap<>();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy