diff --git a/src/main/java/org/hisp/dhis/rules/RuleEngine.java b/src/main/java/org/hisp/dhis/rules/RuleEngine.java index c49c222b..4cc97a09 100644 --- a/src/main/java/org/hisp/dhis/rules/RuleEngine.java +++ b/src/main/java/org/hisp/dhis/rules/RuleEngine.java @@ -23,19 +23,11 @@ import java.util.concurrent.Callable; public record RuleEngine( - @Nonnull - RuleEngineContext executionContext, - - @Nonnull - List events, - - @CheckForNull - RuleEnrollment enrollment, - - @CheckForNull - TriggerEnvironment triggerEnvironment -) -{ + @Nonnull RuleEngineContext executionContext, + @Nonnull List events, + @CheckForNull RuleEnrollment enrollment, + @CheckForNull TriggerEnvironment triggerEnvironment +) { @Nonnull public Callable> evaluate( @Nonnull RuleEvent ruleEvent ) { diff --git a/src/main/java/org/hisp/dhis/rules/RuleEngineContext.java b/src/main/java/org/hisp/dhis/rules/RuleEngineContext.java index 2fccdf1d..21a75252 100644 --- a/src/main/java/org/hisp/dhis/rules/RuleEngineContext.java +++ b/src/main/java/org/hisp/dhis/rules/RuleEngineContext.java @@ -10,18 +10,13 @@ import java.util.Map; public record RuleEngineContext( - @Nonnull - List rules, - @Nonnull - List ruleVariables, - @Nonnull - Map> supplementaryData, - @Nonnull - Map constantsValues, - @Nonnull - RuleEngineIntent ruleEngineIntent, - @CheckForNull - Map dataItemStore) { + @Nonnull List rules, + @Nonnull List ruleVariables, + @Nonnull Map> supplementaryData, + @Nonnull Map constantsValues, + @Nonnull RuleEngineIntent ruleEngineIntent, + @CheckForNull Map dataItemStore +) { RuleEngineContext(@Nonnull List rules, @Nonnull List ruleVariables, @Nonnull Map> supplementaryData, @Nonnull Map constantsValues) { diff --git a/src/main/java/org/hisp/dhis/rules/RuleEngineMultipleExecution.java b/src/main/java/org/hisp/dhis/rules/RuleEngineMultipleExecution.java index 82e50f71..ebe53361 100644 --- a/src/main/java/org/hisp/dhis/rules/RuleEngineMultipleExecution.java +++ b/src/main/java/org/hisp/dhis/rules/RuleEngineMultipleExecution.java @@ -14,14 +14,11 @@ import java.util.concurrent.Callable; record RuleEngineMultipleExecution( - @Nonnull - List rules, - @Nonnull - RuleVariableValueMap ruleVariableValueMap, - @Nonnull - Map> supplementaryData, - @Nonnull - RuleConditionEvaluator ruleConditionEvaluator) implements Callable> { + @Nonnull List rules, + @Nonnull RuleVariableValueMap ruleVariableValueMap, + @Nonnull Map> supplementaryData, + @Nonnull RuleConditionEvaluator ruleConditionEvaluator +) implements Callable> { RuleEngineMultipleExecution(@Nonnull List rules, @Nonnull RuleVariableValueMap ruleVariableValueMap, @Nonnull Map> supplementaryData ) diff --git a/src/main/java/org/hisp/dhis/rules/RuleVariableValue.java b/src/main/java/org/hisp/dhis/rules/RuleVariableValue.java index b2841179..c0ef89d0 100644 --- a/src/main/java/org/hisp/dhis/rules/RuleVariableValue.java +++ b/src/main/java/org/hisp/dhis/rules/RuleVariableValue.java @@ -11,14 +11,10 @@ import java.util.List; public record RuleVariableValue( - @CheckForNull - String value, - @Nonnull - RuleValueType type, - @Nonnull - List candidates, - @CheckForNull - String eventDate + @CheckForNull String value, + @Nonnull RuleValueType type, + @Nonnull List candidates, + @CheckForNull String eventDate ) implements VariableValue { private static final String DATE_PATTERN = "yyyy-MM-dd"; diff --git a/src/main/java/org/hisp/dhis/rules/models/RuleActionHideProgramStage.java b/src/main/java/org/hisp/dhis/rules/models/RuleActionHideProgramStage.java index b48abc40..976d274f 100644 --- a/src/main/java/org/hisp/dhis/rules/models/RuleActionHideProgramStage.java +++ b/src/main/java/org/hisp/dhis/rules/models/RuleActionHideProgramStage.java @@ -3,10 +3,8 @@ import javax.annotation.Nonnull; public record RuleActionHideProgramStage( - @Nonnull - String data, - @Nonnull - String programStage + @Nonnull String data, + @Nonnull String programStage ) implements RuleAction { @Nonnull diff --git a/src/main/java/org/hisp/dhis/rules/models/RuleActionText.java b/src/main/java/org/hisp/dhis/rules/models/RuleActionText.java index 8ab78b3f..ea863b64 100644 --- a/src/main/java/org/hisp/dhis/rules/models/RuleActionText.java +++ b/src/main/java/org/hisp/dhis/rules/models/RuleActionText.java @@ -14,13 +14,9 @@ * or 'program indicator' widget. */ public record RuleActionText( - @Nonnull - String data, - @Nonnull - String content, - @Nonnull - String location - + @Nonnull String data, + @Nonnull String content, + @Nonnull String location ) implements RuleAction { public static final String LOCATION_FEEDBACK_WIDGET = "feedback"; diff --git a/src/main/java/org/hisp/dhis/rules/models/RuleEffect.java b/src/main/java/org/hisp/dhis/rules/models/RuleEffect.java index 44f65ae2..44c02cd0 100644 --- a/src/main/java/org/hisp/dhis/rules/models/RuleEffect.java +++ b/src/main/java/org/hisp/dhis/rules/models/RuleEffect.java @@ -3,8 +3,6 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -; - public record RuleEffect( @Nonnull String ruleId, @Nonnull RuleAction ruleAction, @CheckForNull String data ) { public RuleEffect( @Nonnull String ruleId, @Nonnull RuleAction ruleAction ) diff --git a/src/main/java/org/hisp/dhis/rules/models/RuleEffects.java b/src/main/java/org/hisp/dhis/rules/models/RuleEffects.java index da15f6c2..3cf6f8d8 100644 --- a/src/main/java/org/hisp/dhis/rules/models/RuleEffects.java +++ b/src/main/java/org/hisp/dhis/rules/models/RuleEffects.java @@ -1,11 +1,12 @@ package org.hisp.dhis.rules.models; +import javax.annotation.Nonnull; import java.util.List; public record RuleEffects( - TrackerObjectType trackerObjectType, - String trackerObjectUid, - List ruleEffects) + @Nonnull TrackerObjectType trackerObjectType, + @Nonnull String trackerObjectUid, + @Nonnull List ruleEffects) { public boolean isEnrollment(){ return this.trackerObjectType == TrackerObjectType.ENROLLMENT; diff --git a/src/main/java/org/hisp/dhis/rules/models/RuleEvaluationResult.java b/src/main/java/org/hisp/dhis/rules/models/RuleEvaluationResult.java index e2978d01..d7348d7b 100644 --- a/src/main/java/org/hisp/dhis/rules/models/RuleEvaluationResult.java +++ b/src/main/java/org/hisp/dhis/rules/models/RuleEvaluationResult.java @@ -1,24 +1,25 @@ package org.hisp.dhis.rules.models; +import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; public record RuleEvaluationResult( - Rule rule, - List ruleEffects, + @Nonnull Rule rule, + @Nonnull List ruleEffects, boolean evaluatedAs, boolean error) { - public static RuleEvaluationResult evaluatedResult(Rule rule, List ruleEffects) { + public static RuleEvaluationResult evaluatedResult(@Nonnull Rule rule, @Nonnull List ruleEffects) { return new RuleEvaluationResult( rule, ruleEffects, true, false ); } - public static RuleEvaluationResult notEvaluatedResult(Rule rule) { + public static RuleEvaluationResult notEvaluatedResult(@Nonnull Rule rule) { return new RuleEvaluationResult( rule, new ArrayList<>(), false, false ); } - public static RuleEvaluationResult errorRule( Rule rule, String errorMessage ) { + public static RuleEvaluationResult errorRule( @Nonnull Rule rule, @Nonnull String errorMessage ) { ArrayList effects = new ArrayList<>(); effects.add(new RuleEffect(rule.uid(), RuleActionError.create(errorMessage), errorMessage)); diff --git a/src/main/java/org/hisp/dhis/rules/models/RuleValidationResult.java b/src/main/java/org/hisp/dhis/rules/models/RuleValidationResult.java index 9b3dbc3c..c4157c28 100644 --- a/src/main/java/org/hisp/dhis/rules/models/RuleValidationResult.java +++ b/src/main/java/org/hisp/dhis/rules/models/RuleValidationResult.java @@ -28,54 +28,50 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import javax.annotation.CheckForNull; + /** * @author Zubair Asghar */ public record RuleValidationResult( - String description, - boolean valid, - String errorMessage, - Throwable exception) { + @CheckForNull String description, + boolean valid, + @CheckForNull String errorMessage, + @CheckForNull Throwable exception +) { - public static Builder builder() - { + public static Builder builder() { return new Builder(); } - public static class Builder - { + public static class Builder { private String description; private boolean isValid; private String errorMessage; private Throwable exception; - public Builder description( String description ) - { + public Builder description(String description) { this.description = description; return this; } - public Builder isValid( boolean isValid ) - { + public Builder isValid(boolean isValid) { this.isValid = isValid; return this; } - public Builder errorMessage( String errorMessage ) - { + public Builder errorMessage(String errorMessage) { this.errorMessage = errorMessage; return this; } - public Builder exception( Throwable exception ) - { + public Builder exception(Throwable exception) { this.exception = exception; return this; } - public RuleValidationResult build() - { - return new RuleValidationResult( this.description, this.isValid, this.errorMessage, exception ); + public RuleValidationResult build() { + return new RuleValidationResult(this.description, this.isValid, this.errorMessage, exception); } } }