Trying to remove empty text node

This commit is contained in:
James Agnew 2015-04-22 17:45:00 -04:00
parent 5310d684df
commit e18433d709
3 changed files with 15 additions and 1 deletions

View File

@ -44,6 +44,11 @@ public class CodeDt extends BasePrimitive<String> implements ICodedDatatype, Com
setValue(theCode);
}
@Override
public boolean isEmpty() {
return isBlank(getValueAsString());
}
@Override
public int compareTo(CodeDt theCode) {
if (theCode == null) {

View File

@ -48,6 +48,11 @@ public class XhtmlDt extends BasePrimitive<List<XMLEvent>> {
// nothing
}
@Override
public boolean isEmpty() {
return super.isEmpty() && (getValue() == null || getValue().isEmpty());
}
/**
* Constructor which accepts a string code
*

View File

@ -108,14 +108,18 @@ public class JsonParserDstu2Test {
public void testEncodeBundleNewBundleNoText() {
ca.uhn.fhir.model.dstu2.resource.Bundle b = new ca.uhn.fhir.model.dstu2.resource.Bundle();
b.getText().getDiv();
// b.getText().setDiv("<div>aaa</div>");
b.getText().getStatus().setValueAsString("");;
Entry e = b.addEntry();
e.setResource(new Patient());
String val = new FhirContext().newJsonParser().setPrettyPrint(false).encodeResourceToString(b);
ourLog.info(val);
assertThat(val, not(containsString("text")));
val = new FhirContext().newXmlParser().setPrettyPrint(false).encodeResourceToString(b);
ourLog.info(val);
assertThat(val, not(containsString("text")));
}