38
38
* @author Juergen Hoeller
39
39
* @author Sam Brannen
40
40
* @author Phillip Webb
41
+ * @author Sebastien Deleuze
41
42
*/
42
43
class MethodParameterTests {
43
44
@@ -51,19 +52,25 @@ class MethodParameterTests {
51
52
52
53
private MethodParameter jspecifyNullableParameter ;
53
54
55
+ private MethodParameter jspecifyNonNullParameter ;
56
+
54
57
private MethodParameter springNullableParameter ;
55
58
59
+ private MethodParameter springNonNullParameter ;
60
+
56
61
57
62
@ BeforeEach
58
63
void setup () throws NoSuchMethodException {
59
64
method = getClass ().getMethod ("method" , String .class , long .class );
60
65
stringParameter = new MethodParameter (method , 0 );
61
66
longParameter = new MethodParameter (method , 1 );
62
67
intReturnType = new MethodParameter (method , -1 );
63
- Method jspecifyNullableMethod = getClass ().getMethod ("jspecifyNullableMethod" , String .class );
68
+ Method jspecifyNullableMethod = getClass ().getMethod ("jspecifyNullableMethod" , String .class , String . class );
64
69
jspecifyNullableParameter = new MethodParameter (jspecifyNullableMethod , 0 );
65
- Method springNullableMethod = getClass ().getMethod ("springNullableMethod" , String .class );
70
+ jspecifyNonNullParameter = new MethodParameter (jspecifyNullableMethod , 1 );
71
+ Method springNullableMethod = getClass ().getMethod ("springNullableMethod" , String .class , String .class );
66
72
springNullableParameter = new MethodParameter (springNullableMethod , 0 );
73
+ springNonNullParameter = new MethodParameter (springNullableMethod , 1 );
67
74
}
68
75
69
76
@@ -250,23 +257,33 @@ void jspecifyNullableParameter() {
250
257
assertThat (jspecifyNullableParameter .isOptional ()).isTrue ();
251
258
}
252
259
260
+ @ Test
261
+ void jspecifyNonNullParameter () {
262
+ assertThat (jspecifyNonNullParameter .isOptional ()).isFalse ();
263
+ }
264
+
253
265
@ Test
254
266
void springNullableParameter () {
255
267
assertThat (springNullableParameter .isOptional ()).isTrue ();
256
268
}
257
269
270
+ @ Test
271
+ void springNonNullParameter () {
272
+ assertThat (springNonNullParameter .isOptional ()).isFalse ();
273
+ }
274
+
258
275
public int method (String p1 , long p2 ) {
259
276
return 42 ;
260
277
}
261
278
262
- public @ org .jspecify .annotations .Nullable String jspecifyNullableMethod (@ org .jspecify .annotations .Nullable String parameter ) {
263
- return parameter ;
279
+ public @ org .jspecify .annotations .Nullable String jspecifyNullableMethod (@ org .jspecify .annotations .Nullable String nullableParameter , String nonNullParameter ) {
280
+ return nullableParameter ;
264
281
}
265
282
266
283
@ SuppressWarnings ("deprecation" )
267
284
@ org .springframework .lang .Nullable
268
- public String springNullableMethod (@ org .springframework .lang .Nullable String parameter ) {
269
- return parameter ;
285
+ public String springNullableMethod (@ org .springframework .lang .Nullable String nullableParameter , String nonNullParameter ) {
286
+ return nullableParameter ;
270
287
}
271
288
272
289
@ SuppressWarnings ("unused" )
0 commit comments