Use Object.equals() where feasible

See gh-31916
This commit is contained in:
Yanming Zhou 2023-12-28 15:26:12 +08:00 committed by Stéphane Nicoll
parent a6e87b40c7
commit 72a9864788
9 changed files with 19 additions and 9 deletions

View File

@ -16,6 +16,8 @@
package org.springframework.beans.testfixture.beans;
import java.util.Objects;
import org.springframework.lang.Nullable;
/**
@ -50,7 +52,7 @@ public class Pet {
final Pet pet = (Pet) o;
if (name != null ? !name.equals(pet.name) : pet.name != null) {
if (!Objects.equals(name, pet.name)) {
return false;
}

View File

@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.springframework.asm.ClassVisitor;
@ -288,7 +289,7 @@ abstract public class BeanMap implements Map {
}
Object v1 = get(key);
Object v2 = other.get(key);
if (!((v1 == null) ? v2 == null : v1.equals(v2))) {
if (!(Objects.equals(v1, v2))) {
return false;
}
}

View File

@ -22,6 +22,7 @@ import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonView;
import jakarta.jms.BytesMessage;
@ -285,7 +286,7 @@ class MappingJackson2MessageConverterTests {
return false;
}
MyBean bean = (MyBean) o;
if (foo != null ? !foo.equals(bean.foo) : bean.foo != null) {
if (!Objects.equals(foo, bean.foo)) {
return false;
}
return true;

View File

@ -18,6 +18,7 @@ package org.springframework.web.reactive.function.server;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@ -275,7 +276,7 @@ class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTe
return false;
}
Person person = (Person) o;
return !(this.name != null ? !this.name.equals(person.name) : person.name != null);
return !(!Objects.equals(this.name, person.name));
}
@Override

View File

@ -18,6 +18,7 @@ package org.springframework.web.reactive.function.server;
import java.net.URI;
import java.util.List;
import java.util.Objects;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@ -146,7 +147,7 @@ class PublisherHandlerFunctionIntegrationTests extends AbstractRouterFunctionInt
return false;
}
Person person = (Person) o;
return !(this.name != null ? !this.name.equals(person.name) : person.name != null);
return !(!Objects.equals(this.name, person.name));
}
@Override

View File

@ -17,6 +17,7 @@
package org.springframework.web.reactive.function.server;
import java.time.Duration;
import java.util.Objects;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@ -175,7 +176,7 @@ class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIntegrati
return false;
}
Person person = (Person) o;
return !(this.name != null ? !this.name.equals(person.name) : person.name != null);
return !(!Objects.equals(this.name, person.name));
}
@Override

View File

@ -17,6 +17,7 @@
package org.springframework.web.reactive.result.method.annotation;
import java.time.Duration;
import java.util.Objects;
import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;
@ -153,7 +154,7 @@ class JacksonStreamingIntegrationTests extends AbstractHttpHandlerIntegrationTes
return false;
}
Person person = (Person) o;
return !(this.name != null ? !this.name.equals(person.name) : person.name != null);
return !(!Objects.equals(this.name, person.name));
}
@Override

View File

@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import io.reactivex.rxjava3.core.Completable;
@ -712,7 +713,7 @@ class RequestMappingMessageConversionIntegrationTests extends AbstractRequestMap
return false;
}
Person person = (Person) o;
return !(this.name != null ? !this.name.equals(person.name) : person.name != null);
return !(!Objects.equals(this.name, person.name));
}
@Override

View File

@ -21,6 +21,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.time.Duration;
import java.util.Objects;
import java.util.stream.Stream;
import org.junit.jupiter.api.Disabled;
@ -277,7 +278,7 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
return false;
}
Person person = (Person) o;
return !(this.name != null ? !this.name.equals(person.name) : person.name != null);
return !(!Objects.equals(this.name, person.name));
}
@Override