Adding blank case for ExpressionNode.toString() in r4 and r5. (#609)

This commit is contained in:
Mark Iantorno 2021-09-27 14:52:55 -04:00 committed by GitHub
parent ad18e131d8
commit 72b7300700
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 102 additions and 95 deletions

View File

@ -1 +1,2 @@
* https://github.com/hapifhir/org.hl7.fhir.core/issues/499
* https://github.com/hapifhir/org.hl7.fhir.core/issues/602

View File

@ -331,43 +331,46 @@ public class ExpressionNode {
public String toString() {
StringBuilder b = new StringBuilder();
switch (kind) {
case Name:
b.append(name);
break;
case Function:
if (function == Function.Item)
b.append("[");
else {
b.append(name);
b.append("(");
}
boolean first = true;
for (ExpressionNode n : parameters) {
if (first)
first = false;
else
b.append(", ");
b.append(n.toString());
}
if (function == Function.Item)
b.append("]");
else {
b.append(")");
}
case Name:
b.append(name);
break;
case Function:
if (function == Function.Item)
b.append("[");
else {
b.append(name);
b.append("(");
}
boolean first = true;
for (ExpressionNode n : parameters) {
if (first)
first = false;
else
b.append(", ");
b.append(n.toString());
}
if (function == Function.Item) {
b.append("]");
} else {
b.append(")");
}
break;
case Constant:
if (constant instanceof StringType)
b.append("'"+Utilities.escapeJson(constant.primitiveValue())+"'");
else if (constant instanceof Quantity) {
if (constant == null) {
b.append("{}");
} else if (constant instanceof StringType) {
b.append("'" + Utilities.escapeJson(constant.primitiveValue()) + "'");
} else if (constant instanceof Quantity) {
Quantity q = (Quantity) constant;
b.append(Utilities.escapeJson(q.getValue().toPlainString()));
b.append(" '");
b.append(Utilities.escapeJson(q.getUnit()));
b.append("'");
} else if (constant.primitiveValue() != null)
b.append(Utilities.escapeJson(constant.primitiveValue()));
else
} else if (constant.primitiveValue() != null) {
b.append(Utilities.escapeJson(constant.primitiveValue()));
} else {
b.append(Utilities.escapeJson(constant.toString()));
}
break;
case Group:
b.append("(");

View File

@ -395,25 +395,28 @@ public class ExpressionNode {
b.append(", ");
b.append(n.toString());
}
if (function == Function.Item)
b.append("]");
else {
if (function == Function.Item) {
b.append("]");
} else {
b.append(")");
}
break;
case Constant:
if (constant instanceof StringType)
b.append("'"+Utilities.escapeJson(constant.primitiveValue())+"'");
else if (constant instanceof Quantity) {
if (constant == null) {
b.append("{}");
} else if (constant instanceof StringType) {
b.append("'" + Utilities.escapeJson(constant.primitiveValue()) + "'");
} else if (constant instanceof Quantity) {
Quantity q = (Quantity) constant;
b.append(Utilities.escapeJson(q.getValue().toPlainString()));
b.append(" '");
b.append(Utilities.escapeJson(q.getUnit()));
b.append("'");
} else if (constant.primitiveValue() != null)
b.append(Utilities.escapeJson(constant.primitiveValue()));
else
} else if (constant.primitiveValue() != null) {
b.append(Utilities.escapeJson(constant.primitiveValue()));
} else {
b.append(Utilities.escapeJson(constant.toString()));
}
break;
case Group:
b.append("(");