File tree Expand file tree Collapse file tree 2 files changed +4
-3
lines changed
main/java/org/springframework/graphql/data
test/java/org/springframework/graphql/data Expand file tree Collapse file tree 2 files changed +4
-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 );
52
53
private static final ArgumentValue <?> OMITTED = new ArgumentValue <>(null , true );
53
54
54
55
@@ -118,7 +119,7 @@ public void ifPresent(Consumer<? super T> action) {
118
119
119
120
@ Override
120
121
public boolean equals (Object other ) {
121
- // This covers OMITTED constant
122
+ // This covers EMPTY and OMITTED constant
122
123
if (this == other ) {
123
124
return true ;
124
125
}
@@ -142,8 +143,9 @@ public int hashCode() {
142
143
* @param <T> the type of value
143
144
* @param value the value to hold in the instance
144
145
*/
146
+ @ SuppressWarnings ("unchecked" )
145
147
public static <T > ArgumentValue <T > ofNullable (@ Nullable T value ) {
146
- return new ArgumentValue <>(value , false );
148
+ return value == null ? ( ArgumentValue < T >) EMPTY : new ArgumentValue <>(value , false );
147
149
}
148
150
149
151
/**
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