diff --git a/sdmx30-infomodel/src/main/java/com/epam/jsdmx/infomodel/sdmx30/TextFormatImpl.java b/sdmx30-infomodel/src/main/java/com/epam/jsdmx/infomodel/sdmx30/TextFormatImpl.java index 0c6eb05..ee3817e 100644 --- a/sdmx30-infomodel/src/main/java/com/epam/jsdmx/infomodel/sdmx30/TextFormatImpl.java +++ b/sdmx30-infomodel/src/main/java/com/epam/jsdmx/infomodel/sdmx30/TextFormatImpl.java @@ -27,11 +27,17 @@ public TextFormatImpl(Set facets) { sentinelValues = f.getSentinelValues(); } + final FacetValueType newValueType = f.getValueType(); + + if (newValueType == null) { + continue; + } + if (valueType == null) { - valueType = f.getValueType(); + valueType = newValueType; } else { - if (valueType != f.getValueType()) { - throw new IllegalStateException("Inconsistent text format, multiple value types present: " + valueType + " and " + f.getValueType()); + if (valueType != newValueType) { + throw new IllegalStateException("Inconsistent text format, multiple value types present: " + valueType + " and " + newValueType); } } } diff --git a/sdmx30-infomodel/src/test/java/com/epam/jsdmx/infomodel/sdmx30/TextFormatImplTest.java b/sdmx30-infomodel/src/test/java/com/epam/jsdmx/infomodel/sdmx30/TextFormatImplTest.java new file mode 100644 index 0000000..f73af6e --- /dev/null +++ b/sdmx30-infomodel/src/test/java/com/epam/jsdmx/infomodel/sdmx30/TextFormatImplTest.java @@ -0,0 +1,25 @@ +package com.epam.jsdmx.infomodel.sdmx30; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + +import java.util.Set; + +import org.junit.jupiter.api.Test; + +class TextFormatImplTest { + + @Test + void shouldNotFailOnMultipleFacets() { + Facet f1 = new BaseFacetImpl(FacetValueType.STRING); + var f2 = new BaseFacetImpl(); + f2.setType(FacetType.IS_MULTILINGUAL); + f2.setValue("true"); + + TextFormat value = assertDoesNotThrow(() -> new TextFormatImpl(Set.of(f1, f2))); + + assertThat(value.getValueType()).contains(FacetValueType.STRING); + assertThat(value.getIsMultiLingual()).contains(true); + } + +} \ No newline at end of file