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 4949 */
5050public final class ArgumentValue <T > {
5151
52+ private static final ArgumentValue <?> EMPTY = new ArgumentValue <>(null , false );
5253 private static final ArgumentValue <?> OMITTED = new ArgumentValue <>(null , true );
5354
5455
@@ -118,7 +119,7 @@ public void ifPresent(Consumer<? super T> action) {
118119
119120 @ Override
120121 public boolean equals (Object other ) {
121- // This covers OMITTED constant
122+ // This covers EMPTY and OMITTED constant
122123 if (this == other ) {
123124 return true ;
124125 }
@@ -142,8 +143,9 @@ public int hashCode() {
142143 * @param <T> the type of value
143144 * @param value the value to hold in the instance
144145 */
146+ @ SuppressWarnings ("unchecked" )
145147 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 );
147149 }
148150
149151 /**
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