33import javax .annotation .CheckForNull ;
44import javax .annotation .Nullable ;
55import org .springframework .beans .factory .annotation .Value ;
6+ import org .springframework .lang .NonNull ;
67
78public class NullableInjectedFieldsHaveDefaultValueSample {
89 @ Nullable
@@ -39,7 +40,7 @@ public class NullableInjectedFieldsHaveDefaultValueSample {
3940
4041 private static final String NON_COMPLIANT_IN_A_CONSTANT = "${non.compliant.constant}" ;
4142 //fix@fixStaticConstant {{Set null as default value}}
42- //edit@fixStaticConstant [[sl=40 ;el=40 ;sc=61;ec=88]] {{"${non.compliant.constant:#{null}}"}}
43+ //edit@fixStaticConstant [[sl=-4 ;el=-4 ;sc=61;ec=88]] {{"${non.compliant.constant:#{null}}"}}
4344 @ Nullable
4445 @ Value (value = NON_COMPLIANT_IN_A_CONSTANT ) // Noncompliant [[sc=3;ec=46;secondary=-1;quickfixes=fixStaticConstant,localFixOnStaticConstant]]
4546 //fix@localFixOnStaticConstant {{Set null as default value locally}}
@@ -48,7 +49,7 @@ public class NullableInjectedFieldsHaveDefaultValueSample {
4849
4950 private final String finalButNotStatic = "${non.compliant.constant}" ;
5051 //fix@fixConstant {{Set null as default value}}
51- //edit@fixConstant [[sl=49 ;el=49 ;sc=44;ec=71]] {{"${non.compliant.constant:#{null}}"}}
52+ //edit@fixConstant [[sl=-4 ;el=-4 ;sc=44;ec=71]] {{"${non.compliant.constant:#{null}}"}}
5253 @ Nullable
5354 @ Value (finalButNotStatic ) // Noncompliant [[sc=3;ec=28;secondary=-1;quickfixes=fixConstant,localFixOnConstant]]
5455 // fix@localFixOnConstant {{Set null as default value locally}}
@@ -118,4 +119,16 @@ private String setNothingWithTwoParameters(@Nullable String a, String b) {
118119 @ org .jspecify .annotations .Nullable
119120 @ Value ("${my.property_jspecify}" ) // Noncompliant {{Provide a default null value for this field.}} [[sc=3;ec=27;secondary=-1]]
120121 private String myProperty_jspecify ;
122+
123+ @ Value ("${notNull}" )
124+ @ NonNull
125+ private String notNull ; // Compliant, fields marked as non-null should be ignored
126+
127+ private String nonNullArgument1 (@ Value ("${x}" ) @ org .jspecify .annotations .NonNull String x ) { // Compliant, parameters marked as non-null should be ignored
128+ return x ;
129+ }
130+
131+ private String nonNullArgument2 (@ Value ("${x}" ) @ NonNull String x ) { // Compliant, parameters marked as non-null should be ignored
132+ return x ;
133+ }
121134}
0 commit comments