CCM NG: LocalizedString now accepts null for the list of values
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5135 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
1408198b19
commit
c75ae20480
|
|
@ -18,9 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.l10n;
|
package org.libreccm.l10n;
|
||||||
|
|
||||||
|
import static org.libreccm.l10n.L10NConstants.*;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import org.hibernate.annotations.Type;
|
import org.hibernate.annotations.Type;
|
||||||
import org.hibernate.search.annotations.Field;
|
import org.hibernate.search.annotations.Field;
|
||||||
|
import org.libreccm.l10n.jaxb.LocalizedStringValuesAdapter;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.ElementCollection;
|
import javax.persistence.ElementCollection;
|
||||||
|
|
@ -28,6 +31,7 @@ import javax.persistence.Embeddable;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.Lob;
|
import javax.persistence.Lob;
|
||||||
import javax.persistence.MapKeyColumn;
|
import javax.persistence.MapKeyColumn;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
@ -36,6 +40,12 @@ import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper class for localisable string properties. This class is declared as
|
* A helper class for localisable string properties. This class is declared as
|
||||||
* embeddable, so that it can be used in every other entity. The localised
|
* embeddable, so that it can be used in every other entity. The localised
|
||||||
|
|
@ -45,8 +55,8 @@ import java.util.Set;
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
@Embeddable
|
@Embeddable
|
||||||
//@XmlRootElement(name = "localized-string", namespace = L10N_XML_NS)
|
@XmlRootElement(name = "localized-string", namespace = L10N_XML_NS)
|
||||||
//@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class LocalizedString implements Serializable {
|
public class LocalizedString implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 7378282657084330425L;
|
private static final long serialVersionUID = 7378282657084330425L;
|
||||||
|
|
@ -60,8 +70,8 @@ public class LocalizedString implements Serializable {
|
||||||
@Lob
|
@Lob
|
||||||
@Type(type = "org.hibernate.type.TextType")
|
@Type(type = "org.hibernate.type.TextType")
|
||||||
@Field
|
@Field
|
||||||
//@XmlElement(name = "values", namespace = L10N_XML_NS)
|
@XmlElement(name = "values", namespace = L10N_XML_NS)
|
||||||
//@XmlJavaTypeAdapter(LocalizedStringValuesAdapter.class)
|
@XmlJavaTypeAdapter(LocalizedStringValuesAdapter.class)
|
||||||
private Map<Locale, String> values;
|
private Map<Locale, String> values;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -92,8 +102,12 @@ public class LocalizedString implements Serializable {
|
||||||
* @param values The new map of values.
|
* @param values The new map of values.
|
||||||
*/
|
*/
|
||||||
protected void setValues(final Map<Locale, String> values) {
|
protected void setValues(final Map<Locale, String> values) {
|
||||||
|
if (values == null) {
|
||||||
|
this.values = values;
|
||||||
|
} else {
|
||||||
this.values = new HashMap<>(values);
|
this.values = new HashMap<>(values);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the values for the default locale.
|
* Retrieves the values for the default locale.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue