From 5c2d3d03edf0219b0ebec5a6075eec00fe6455e5 Mon Sep 17 00:00:00 2001 From: Jan Bernitt Date: Tue, 28 Nov 2023 10:47:56 +0100 Subject: [PATCH] chore: replace @Nullable with @CheckForNull --- .../org/hisp/dhis/rules/RuleEngineContext.java | 15 +++++++-------- .../org/hisp/dhis/rules/RuleVariableValue.java | 6 +++--- .../dhis/rules/RuleVariableValueMapBuilder.java | 14 +++++++------- .../hisp/dhis/rules/RuleVariableValueAssert.java | 4 ++-- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/hisp/dhis/rules/RuleEngineContext.java b/src/main/java/org/hisp/dhis/rules/RuleEngineContext.java index 5dc96af0..2fccdf1d 100644 --- a/src/main/java/org/hisp/dhis/rules/RuleEngineContext.java +++ b/src/main/java/org/hisp/dhis/rules/RuleEngineContext.java @@ -5,7 +5,6 @@ import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -52,19 +51,19 @@ public static class Builder { private RuleEngineIntent intent; - @Nullable + @CheckForNull private List rules; - @Nullable + @CheckForNull private List ruleVariables; - @Nullable + @CheckForNull private Map> supplementaryData; - @Nullable + @CheckForNull private Map constantsValues; - @Nullable + @CheckForNull private Map itemStore; Builder( @Nonnull RuleExpressionEvaluator evaluator ) @@ -100,14 +99,14 @@ public Builder ruleVariables( List ruleVariables ) } @Nonnull - public Builder ruleEngineItent( @Nullable RuleEngineIntent ruleEngineIntent ) + public Builder ruleEngineItent( @CheckForNull RuleEngineIntent ruleEngineIntent ) { this.intent = ruleEngineIntent; return this; } @Nonnull - public Builder itemStore( @Nullable Map itemStore ) + public Builder itemStore( @CheckForNull Map itemStore ) { this.itemStore = itemStore; return this; diff --git a/src/main/java/org/hisp/dhis/rules/RuleVariableValue.java b/src/main/java/org/hisp/dhis/rules/RuleVariableValue.java index cd6a428c..b2841179 100644 --- a/src/main/java/org/hisp/dhis/rules/RuleVariableValue.java +++ b/src/main/java/org/hisp/dhis/rules/RuleVariableValue.java @@ -4,20 +4,20 @@ import org.hisp.dhis.lib.expression.spi.VariableValue; import org.hisp.dhis.rules.models.RuleValueType; +import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; public record RuleVariableValue( - @Nullable + @CheckForNull String value, @Nonnull RuleValueType type, @Nonnull List candidates, - @Nullable + @CheckForNull String eventDate ) implements VariableValue { private static final String DATE_PATTERN = "yyyy-MM-dd"; diff --git a/src/main/java/org/hisp/dhis/rules/RuleVariableValueMapBuilder.java b/src/main/java/org/hisp/dhis/rules/RuleVariableValueMapBuilder.java index e2464a18..3c084379 100644 --- a/src/main/java/org/hisp/dhis/rules/RuleVariableValueMapBuilder.java +++ b/src/main/java/org/hisp/dhis/rules/RuleVariableValueMapBuilder.java @@ -9,8 +9,8 @@ import org.hisp.dhis.rules.models.TriggerEnvironment; import org.hisp.dhis.rules.utils.RuleEngineUtils; +import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; @@ -39,13 +39,13 @@ public final class RuleVariableValueMapBuilder @Nonnull private final List ruleEvents; - @Nullable + @CheckForNull public RuleEnrollment ruleEnrollment; - @Nullable + @CheckForNull public RuleEvent ruleEvent; - @Nullable + @CheckForNull private TriggerEnvironment triggerEnvironment; private RuleVariableValueMapBuilder() @@ -100,7 +100,7 @@ RuleVariableValueMapBuilder ruleVariables( @Nonnull List ruleVaria } @Nonnull - RuleVariableValueMapBuilder ruleEnrollment( @Nullable RuleEnrollment ruleEnrollment ) + RuleVariableValueMapBuilder ruleEnrollment( @CheckForNull RuleEnrollment ruleEnrollment ) { if ( this.ruleEnrollment != null ) { @@ -113,7 +113,7 @@ RuleVariableValueMapBuilder ruleEnrollment( @Nullable RuleEnrollment ruleEnrollm } @Nonnull - RuleVariableValueMapBuilder triggerEnvironment( @Nullable TriggerEnvironment triggerEnvironment ) + RuleVariableValueMapBuilder triggerEnvironment( @CheckForNull TriggerEnvironment triggerEnvironment ) { if ( this.triggerEnvironment != null ) { @@ -182,7 +182,7 @@ RuleVariableValueMap multipleBuild() } private boolean isEventInList( @Nonnull List ruleEvents, - @Nullable RuleEvent ruleEvent ) + @CheckForNull RuleEvent ruleEvent ) { if ( ruleEvent != null ) { diff --git a/src/test/java/org/hisp/dhis/rules/RuleVariableValueAssert.java b/src/test/java/org/hisp/dhis/rules/RuleVariableValueAssert.java index e04cf05f..d37d2958 100644 --- a/src/test/java/org/hisp/dhis/rules/RuleVariableValueAssert.java +++ b/src/test/java/org/hisp/dhis/rules/RuleVariableValueAssert.java @@ -2,8 +2,8 @@ import org.hisp.dhis.rules.models.RuleValueType; +import javax.annotation.CheckForNull; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import static org.junit.Assert.assertEquals; @@ -23,7 +23,7 @@ static RuleVariableValueAssert assertThatVariable( @Nonnull RuleVariableValue va } @Nonnull - RuleVariableValueAssert hasValue( @Nullable String value ) + RuleVariableValueAssert hasValue( @CheckForNull String value ) { assertEquals( value , variableValue.value() ); return this;