From 64c10daa00f68cdb1deacaa09865b22c6a0d41c7 Mon Sep 17 00:00:00 2001 From: Cody Hansen Date: Thu, 21 Dec 2023 06:20:00 -1000 Subject: [PATCH] Added documentation for the new validation result (#112) --- .../activity-types/parameters.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/mission-modeling/activity-types/parameters.md b/docs/mission-modeling/activity-types/parameters.md index f0ed92f..9d1a4bb 100644 --- a/docs/mission-modeling/activity-types/parameters.md +++ b/docs/mission-modeling/activity-types/parameters.md @@ -34,3 +34,26 @@ public boolean validateInstrumentPowers() { ``` The annotation processor identifies these methods and arranges for them to be invoked whenever a planner instantiates an instance of the class. A message will be provided to the planner for each failing validation, so the order of validation methods does not matter. + +Validations can also be more dynamic if failure reasons are needed for specific cases, rather than using the annotation above the following is supported. The first parameter is the validation result, the second is the subject of the validation, and the third is the message. + +If returning a `true` result the subject and message can be `null`. + +```java +@Validation +public ValidationResult validateInstrumentPowers() { + if (instrumentPower_W < 0) { + return new ValidationResult(false, "instrumentPower_W", "Instrument W's power is below " + 0); + } else if (instrumentPower_W > 1000.0) { + return new ValidationResult(false, "instrumentPower_W", "Instrument W's power is above " + 1000.0); + } + + if (instrumentPower_Y < 0) { + return new ValidationResult(false, "instrumentPower_Y", "Instrument Y's power is below " + 0); + } else if (instrumentPower_Y > 1000.0) { + return new ValidationResult(false, "instrumentPower_Y", "Instrument Y's power is above " + 1000.0); + } + + return new ValidationResult(true, null, null); +} +```