File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
main/java/org/springframework/graphql/data
test/java/org/springframework/graphql/data Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 4949 */
5050public final class ArgumentValue <T > {
5151
52+ private static final ArgumentValue <?> EMPTY = new ArgumentValue <>(null , false );
53+
5254 private static final ArgumentValue <?> OMITTED = new ArgumentValue <>(null , true );
5355
5456
@@ -118,7 +120,7 @@ public void ifPresent(Consumer<? super T> action) {
118120
119121 @ Override
120122 public boolean equals (Object other ) {
121- // This covers OMITTED constant
123+ // This covers EMPTY and OMITTED constant
122124 if (this == other ) {
123125 return true ;
124126 }
@@ -142,8 +144,9 @@ public int hashCode() {
142144 * @param <T> the type of value
143145 * @param value the value to hold in the instance
144146 */
147+ @ SuppressWarnings ("unchecked" )
145148 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 ;
147150 }
148151
149152 /**
Original file line number Diff line number Diff line change @@ -74,7 +74,6 @@ void ifPresentShouldSkipWhenNull() {
7474 }
7575
7676 @ Test
77-
7877 void ifPresentShouldSkipWhenOmitted () {
7978 AtomicBoolean called = new AtomicBoolean ();
8079 ArgumentValue .omitted ().ifPresent (value -> called .set (true ));
You can’t perform that action at this time.
0 commit comments