Add Nullable annotation to parameter of overridden equals method.

Closes: #1325
Original pull request: #1326
This commit is contained in:
Christoph Strobl
2022-11-08 14:23:32 +01:00
committed by Mark Paluch
parent c4fd1f2147
commit 52fbdad5a3
27 changed files with 42 additions and 30 deletions

View File

@@ -19,6 +19,7 @@ import java.util.Arrays;
import java.util.List;
import org.springframework.data.cassandra.core.cql.keyspace.KeyspaceActionSpecification;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
@@ -48,7 +49,7 @@ public final class KeyspaceActions {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -109,7 +109,7 @@ public class DeleteOptions extends WriteOptions {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -107,7 +107,7 @@ public class InsertOptions extends WriteOptions {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -111,7 +111,7 @@ public class UpdateOptions extends WriteOptions {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -32,6 +32,7 @@ import org.springframework.data.cassandra.core.mapping.UserTypeResolver;
import org.springframework.data.convert.CustomConversions;
import org.springframework.data.mapping.MappingException;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import com.datastax.oss.driver.api.core.CqlIdentifier;
@@ -402,7 +403,7 @@ public class SchemaFactory {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (!(o instanceof com.datastax.oss.driver.api.core.type.UserDefinedType))

View File

@@ -18,6 +18,7 @@ package org.springframework.data.cassandra.core.cql;
import java.io.Serializable;
import java.util.regex.Pattern;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -237,7 +238,7 @@ public final class CqlIdentifier implements Comparable<CqlIdentifier>, Serializa
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;

View File

@@ -17,6 +17,7 @@ package org.springframework.data.cassandra.core.cql;
import java.util.regex.Pattern;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import com.datastax.oss.driver.api.core.CqlIdentifier;
@@ -122,7 +123,7 @@ public final class KeyspaceIdentifier implements Comparable<KeyspaceIdentifier>
* equal to a {@link KeyspaceIdentifier}.
*/
@Override
public boolean equals(Object that) {
public boolean equals(@Nullable Object that) {
if (this == that) {
return true;
}

View File

@@ -217,7 +217,7 @@ public class QueryOptions {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -112,7 +112,7 @@ public class WriteOptions extends QueryOptions {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -165,7 +165,7 @@ public class CreateKeyspaceSpecification extends KeyspaceOptionsSpecification<Cr
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -18,6 +18,7 @@ package org.springframework.data.cassandra.core.cql.keyspace;
import org.springframework.data.cassandra.core.cql.KeyspaceIdentifier;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import org.springframework.lang.Nullable;
/**
* Object to configure a {@code DROP KEYSPACE} specification.
@@ -95,7 +96,7 @@ public class DropKeyspaceSpecification extends KeyspaceActionSpecification {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.data.cassandra.core.cql.keyspace;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -53,7 +54,7 @@ public abstract class KeyspaceActionSpecification {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -113,7 +113,7 @@ public abstract class KeyspaceOptionsSpecification<T extends KeyspaceOptionsSpec
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -19,6 +19,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -114,7 +115,7 @@ public class MapPreparedStatementCache implements PreparedStatementCache {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@@ -126,7 +126,7 @@ public class BasicMapId implements MapId {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object that) {
public boolean equals(@Nullable Object that) {
if (this == that) {
return true;
}

View File

@@ -117,7 +117,7 @@ public class EntityMapping {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -139,7 +139,7 @@ class MapIdProxyDelegate implements InvocationHandler {
}
@Override
public boolean equals(Object that) {
public boolean equals(@Nullable Object that) {
if (that == null) {
return false;
}

View File

@@ -93,7 +93,7 @@ public class PropertyMapping {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -17,6 +17,7 @@ package org.springframework.data.cassandra.core.query;
import java.util.Optional;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import com.datastax.oss.driver.api.core.CqlIdentifier;
@@ -85,7 +86,7 @@ public abstract class ColumnName {
* @see org.springframework.data.cassandra.core.query.Criteria#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -24,6 +24,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@@ -222,7 +223,7 @@ public class Columns implements Iterable<ColumnName> {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object object) {
public boolean equals(@Nullable Object object) {
if (this == object) {
return true;
@@ -390,7 +391,7 @@ public class Columns implements Iterable<ColumnName> {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
@@ -495,7 +496,7 @@ public class Columns implements Iterable<ColumnName> {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}

View File

@@ -280,7 +280,7 @@ public class Criteria implements CriteriaDefinition {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -102,7 +102,7 @@ public interface CriteriaDefinition {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;

View File

@@ -31,6 +31,7 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Order;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -303,7 +304,7 @@ public class Query implements Filter {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@@ -198,7 +198,7 @@ public class MapBuilder<K, V> implements Map<K, V> {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
return map.equals(o);
}

View File

@@ -26,6 +26,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.data.annotation.Id;
import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
import org.springframework.data.mapping.PropertyHandler;
import org.springframework.lang.Nullable;
/**
* Unit tests for {@link CassandraMappingContext}.
@@ -110,7 +111,7 @@ class CassandraPersistentEntityOrderPropertiesUnitTests {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
if (this == obj)
return true;
if (obj == null)

View File

@@ -25,6 +25,7 @@ import org.springframework.data.cassandra.core.mapping.PrimaryKey;
import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass;
import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
import org.springframework.data.cassandra.core.mapping.Table;
import org.springframework.lang.Nullable;
/**
* @author Matthew T. Adams
@@ -118,7 +119,7 @@ public class CorrelationEntity {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (!(o instanceof IdentityEntity))
@@ -182,7 +183,7 @@ public class CorrelationEntity {
}
@Override
public boolean equals(Object o) {
public boolean equals(@Nullable Object o) {
if (this == o)
return true;
if (!(o instanceof CorrelationEntity))

View File

@@ -144,7 +144,7 @@ public class UserDefinedTypeBuilder {
}
@Override
public boolean equals(Object obj) {
public boolean equals(@Nullable Object obj) {
return super.equals(obj) || delegate.equals(obj);
}