From 40d6cd4108b8a7f4857b2e47aba50553a06166fc Mon Sep 17 00:00:00 2001 From: patrick-werner Date: Tue, 25 Feb 2020 19:16:59 +0100 Subject: [PATCH] added messageArgument aware method --- .../main/java/org/hl7/fhir/validation/BaseValidator.java | 9 +++++++++ .../hl7/fhir/validation/instance/InstanceValidator.java | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java index 68eb86af0..3c81d0ec3 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java @@ -70,6 +70,7 @@ public class BaseValidator { * Set this parameter to false if the validation does not pass * @return Returns thePass (in other words, returns true if the rule did not fail validation) */ + //todo: remove after i18n implementation done protected boolean fail(List errors, IssueType type, int line, int col, String path, boolean thePass, String msg) { if (!thePass) { addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.FATAL); @@ -77,6 +78,14 @@ public class BaseValidator { return thePass; } + protected boolean fail(List errors, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) { + if (!thePass) { + String msg = formatMessage(theMessage, theMessageArguments); + addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.FATAL); + } + return thePass; + } + /** * Test a rule and add a {@link IssueSeverity#FATAL} validation message if the validation fails * diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java index 44849ccee..a516c401c 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java @@ -3798,7 +3798,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat if (qItem.getType() == null) { fail(errors, IssueType.REQUIRED, element.line(), element.col(), stack.getLiteralPath(), false,messages.getString("Definition_for_item__does_not_contain_a_type"), qItem.getLinkId()); } else if (qItem.getType() == QuestionnaireItemType.DISPLAY) { - List items = new ArrayList(); + List items = new ArrayList<>(); element.getNamedChildren("item", items); rule(errors, IssueType.STRUCTURE, element.line(), element.col(), stack.getLiteralPath(), items.isEmpty(),messages.getString("Items_not_of_type_DISPLAY_should_not_have_items__linkId_0"), qItem.getLinkId()); } else {