Consistently declare Object::equals argument as @Nullable
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.cache.config;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -45,16 +46,11 @@ public class TestEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (obj instanceof TestEntity) {
|
||||
return ObjectUtils.nullSafeEquals(this.id, ((TestEntity) obj).id);
|
||||
}
|
||||
return false;
|
||||
return (obj instanceof TestEntity that && ObjectUtils.nullSafeEquals(this.id, that.id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user