File tree 2 files changed +5
-3
lines changed
main/java/org/springframework/graphql/data
test/java/org/springframework/graphql/data
2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 49
49
*/
50
50
public final class ArgumentValue <T > {
51
51
52
+ private static final ArgumentValue <?> EMPTY = new ArgumentValue <>(null , false );
53
+
52
54
private static final ArgumentValue <?> OMITTED = new ArgumentValue <>(null , true );
53
55
54
56
@@ -118,7 +120,7 @@ public void ifPresent(Consumer<? super T> action) {
118
120
119
121
@ Override
120
122
public boolean equals (Object other ) {
121
- // This covers OMITTED constant
123
+ // This covers EMPTY and OMITTED constant
122
124
if (this == other ) {
123
125
return true ;
124
126
}
@@ -142,8 +144,9 @@ public int hashCode() {
142
144
* @param <T> the type of value
143
145
* @param value the value to hold in the instance
144
146
*/
147
+ @ SuppressWarnings ("unchecked" )
145
148
public static <T > ArgumentValue <T > ofNullable (@ Nullable T value ) {
146
- return new ArgumentValue <>(value , false );
149
+ return ( value != null ) ? new ArgumentValue <>(value , false ) : ( ArgumentValue < T >) EMPTY ;
147
150
}
148
151
149
152
/**
Original file line number Diff line number Diff line change @@ -74,7 +74,6 @@ void ifPresentShouldSkipWhenNull() {
74
74
}
75
75
76
76
@ Test
77
-
78
77
void ifPresentShouldSkipWhenOmitted () {
79
78
AtomicBoolean called = new AtomicBoolean ();
80
79
ArgumentValue .omitted ().ifPresent (value -> called .set (true ));
You can’t perform that action at this time.
0 commit comments