Skip to content

Commit

Permalink
Deprecate validate methods with markCompleted parameter (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Jan 30, 2024
1 parent c4a82dd commit 7eb5802
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void initialize() throws IOException, XFormParser.ParseException {

@Benchmark
public void benchmarkFormDefValidate(FormDefValidateState state, Blackhole bh) {
ValidateOutcome validateOutcome = state.formDef.validate(true);
ValidateOutcome validateOutcome = state.formDef.validate();
bh.consume(validateOutcome);
}
}
8 changes: 8 additions & 0 deletions src/main/java/org/javarosa/core/model/FormDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,14 @@ public Collection<QuickTriggerable> triggerTriggerables(TreeReference ref) {
return dagImpl.triggerTriggerables(getMainInstance(), getEvaluationContext(), ref);
}

public ValidateOutcome validate() {
return validate(true);
}

/**
* @deprecated Use 'validate' without the 'markCompleted' parameter, as the 'true' value has been the only one used.
*/
@Deprecated
public ValidateOutcome validate(boolean markCompleted) {

FormEntryModel formEntryModelToBeValidated = new FormEntryModel(this);
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/org/javarosa/core/model/TriggerableDag.java
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,14 @@ void reportDependencyCycles() {
* FormEntryController is based upon the FormDef, but has its own model and
* controller independent of anything at the UI layer.
*/
public ValidateOutcome validate(FormEntryController formEntryControllerToBeValidated) {
return validate(formEntryControllerToBeValidated, true);
}

/**
* @deprecated Use 'validate' without the 'markCompleted' parameter, as the 'true' value has been the only one used.
*/
@Deprecated
public ValidateOutcome validate(FormEntryController formEntryControllerToBeValidated, boolean markCompleted) {

formEntryControllerToBeValidated.jumpToIndex(FormIndex.createBeginningOfFormIndex());
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/javarosa/core/test/FormDefMatchers.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static TypeSafeMatcher<FormDef> valid() {
return new TypeSafeMatcher<FormDef>() {
@Override
protected boolean matchesSafely(FormDef item) {
return item.validate(true) == null;
return item.validate() == null;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/javarosa/core/test/Scenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public FormIndex getCurrentIndex() {
}

public ValidateOutcome getValidationOutcome() {
return formDef.validate(true);
return formDef.validate();
}

/**
Expand Down

0 comments on commit 7eb5802

Please sign in to comment.