mirror of https://github.com/apache/lucene.git
SOLR-14541: Ensure classes that implement equals implement hashCode or suppress warnings
This commit is contained in:
parent
f1650d5f47
commit
11538e52a2
|
@ -391,6 +391,9 @@ Other Changes
|
|||
|
||||
* SOLR-14589: Remove IntelliJ //noinspection comments (Erick Erickson)
|
||||
|
||||
* SOLR-14541: Ensure classes that implement equals implement hashCode or suppress warnings
|
||||
(gezapeti, Ilan Ginsburg, Erick Erickson)
|
||||
|
||||
================== 8.5.2 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||
|
|
|
@ -365,7 +365,7 @@ public class Rule {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
throw new UnsupportedOperationException("TODO unimplemented");
|
||||
return Objects.hash(name, operand);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.solr.packagemanager;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.solr.common.annotation.JsonProperty;
|
||||
import org.apache.solr.common.util.ReflectMapWriter;
|
||||
|
@ -61,7 +62,7 @@ public class SolrPackageInstance implements ReflectMapWriter {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
throw new UnsupportedOperationException("TODO unimplemented");
|
||||
return Objects.hash(name, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -210,7 +210,7 @@ public class PackageAPI {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
throw new UnsupportedOperationException("TODO unimplemented");
|
||||
return Objects.hash(version);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.solr.common.MapWriter;
|
||||
import org.apache.solr.common.params.AutoScalingParams;
|
||||
|
@ -42,7 +43,6 @@ import static java.util.stream.Collectors.toList;
|
|||
* Bean representation of <code>autoscaling.json</code>, which parses data
|
||||
* lazily.
|
||||
*/
|
||||
@SuppressWarnings({"overrides"})
|
||||
public class AutoScalingConfig implements MapWriter {
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
|
@ -59,7 +59,6 @@ public class AutoScalingConfig implements MapWriter {
|
|||
/**
|
||||
* Bean representation of trigger listener config.
|
||||
*/
|
||||
@SuppressWarnings({"overrides"})
|
||||
public static class TriggerListenerConfig implements MapWriter {
|
||||
public final String name;
|
||||
public final String trigger;
|
||||
|
@ -140,11 +139,11 @@ public class AutoScalingConfig implements MapWriter {
|
|||
return properties.equals(that.properties);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// throw new UnsupportedOperationException("TODO unimplemented");
|
||||
// }
|
||||
//
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, trigger, listenerClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Utils.toJSONString(this);
|
||||
|
@ -154,7 +153,6 @@ public class AutoScalingConfig implements MapWriter {
|
|||
/**
|
||||
* Bean representation of trigger config.
|
||||
*/
|
||||
@SuppressWarnings({"overrides"})
|
||||
public static class TriggerConfig implements MapWriter {
|
||||
/** Trigger name. */
|
||||
public final String name;
|
||||
|
@ -234,10 +232,11 @@ public class AutoScalingConfig implements MapWriter {
|
|||
if (event != that.event) return false;
|
||||
return properties.equals(that.properties);
|
||||
}
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// throw new UnsupportedOperationException("TODO unimplemented");
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeMap(EntryWriter ew) throws IOException {
|
||||
|
@ -262,11 +261,10 @@ public class AutoScalingConfig implements MapWriter {
|
|||
/**
|
||||
* Bean representation of trigger action configuration.
|
||||
*/
|
||||
@SuppressWarnings({"overrides"})
|
||||
public static class ActionConfig implements MapWriter {
|
||||
/** Action name. */
|
||||
public final String name;
|
||||
/** Class name of action implementtion. */
|
||||
/** Class name of action implementation. */
|
||||
public final String actionClass;
|
||||
/** Additional action properties. */
|
||||
public final Map<String, Object> properties;
|
||||
|
@ -305,10 +303,10 @@ public class AutoScalingConfig implements MapWriter {
|
|||
return properties.equals(that.properties);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// throw new UnsupportedOperationException("TODO unimplemented");
|
||||
// }
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -587,11 +585,11 @@ public class AutoScalingConfig implements MapWriter {
|
|||
if (!getTriggerListenerConfigs().equals(that.getTriggerListenerConfigs())) return false;
|
||||
return getProperties().equals(that.getProperties());
|
||||
}
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// throw new UnsupportedOperationException("TODO unimplemented");
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getPolicy());
|
||||
}
|
||||
|
||||
private static List<Object> getList(String key, Map<String, Object> properties) {
|
||||
return getList(key, properties, null);
|
||||
|
|
|
@ -70,7 +70,6 @@ import static org.apache.solr.client.solrj.cloud.autoscaling.Variable.Type.WITH_
|
|||
* Create a fresh new session for each use
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings({"overrides"})
|
||||
public class Policy implements MapWriter {
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
|
@ -288,10 +287,8 @@ public class Policy implements MapWriter {
|
|||
return getClusterPreferences().equals(policy.getClusterPreferences());
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// throw new UnsupportedOperationException("TODO unimplemented");
|
||||
// }
|
||||
@Override
|
||||
public int hashCode() { return Objects.hash(getPolicies()); }
|
||||
|
||||
public static Map<String, List<Clause>> clausesFromMap(Map<String, List<Map<String, Object>>> map, List<String> newParams) {
|
||||
Map<String, List<Clause>> newPolicies = new HashMap<>();
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.lang.invoke.MethodHandles;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.solr.common.MapWriter;
|
||||
import org.apache.solr.common.util.StrUtils;
|
||||
|
@ -29,7 +30,6 @@ import org.apache.solr.common.util.Utils;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@SuppressWarnings({"overrides"})
|
||||
public class Preference implements MapWriter {
|
||||
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
|
||||
|
||||
|
@ -133,10 +133,10 @@ public class Preference implements MapWriter {
|
|||
return original.equals(that.original);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// throw new UnsupportedOperationException("TODO unimplemented");
|
||||
// }
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getName(), precision, sort, idx);
|
||||
}
|
||||
|
||||
public Policy.SortParam getName() {
|
||||
return name;
|
||||
|
|
|
@ -19,12 +19,12 @@ package org.apache.solr.client.solrj.cloud.autoscaling;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.solr.common.MapWriter;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
|
||||
@SuppressWarnings({"overrides"})
|
||||
class ReplicaCount implements MapWriter {
|
||||
long nrt, tlog, pull;
|
||||
|
||||
|
@ -107,10 +107,10 @@ class ReplicaCount implements MapWriter {
|
|||
return false;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// throw new UnsupportedOperationException("TODO unimplemented");
|
||||
// }
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(nrt, tlog, pull);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -35,7 +35,6 @@ import static org.apache.solr.common.ConditionalMapWriter.NON_NULL_VAL;
|
|||
import static org.apache.solr.common.ConditionalMapWriter.dedupeKeyPredicate;
|
||||
import static org.apache.solr.common.cloud.ZkStateReader.LEADER_PROP;
|
||||
|
||||
@SuppressWarnings({"overrides"})
|
||||
public class ReplicaInfo implements MapWriter {
|
||||
private final String name;
|
||||
private final String core, collection, shard;
|
||||
|
@ -209,10 +208,10 @@ public class ReplicaInfo implements MapWriter {
|
|||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// throw new UnsupportedOperationException("TODO unimplemented");
|
||||
// }
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, core, collection, shard, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.apache.zookeeper.CreateMode;
|
|||
/**
|
||||
* Immutable representation of binary data with version.
|
||||
*/
|
||||
@SuppressWarnings({"overrides"})
|
||||
public class VersionedData implements MapWriter {
|
||||
private final int version;
|
||||
private final byte[] data;
|
||||
|
@ -93,9 +92,8 @@ public class VersionedData implements MapWriter {
|
|||
mode == that.mode;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// throw new UnsupportedOperationException("TODO unimplemented");
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(version, owner);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -463,7 +463,6 @@ public class CloudSolrStream extends TupleStream implements Expressible {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"overrides"})
|
||||
protected class TupleWrapper implements Comparable<TupleWrapper> {
|
||||
private Tuple tuple;
|
||||
private SolrStream stream;
|
||||
|
@ -491,6 +490,11 @@ public class CloudSolrStream extends TupleStream implements Expressible {
|
|||
return this == o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(tuple);
|
||||
}
|
||||
|
||||
public Tuple getTuple() {
|
||||
return tuple;
|
||||
}
|
||||
|
|
|
@ -411,7 +411,6 @@ public class DeepRandomStream extends TupleStream implements Expressible {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"overrides"})
|
||||
protected class TupleWrapper implements Comparable<TupleWrapper> {
|
||||
private Tuple tuple;
|
||||
private SolrStream stream;
|
||||
|
@ -435,10 +434,15 @@ public class DeepRandomStream extends TupleStream implements Expressible {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return this == o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(tuple);
|
||||
}
|
||||
public Tuple getTuple() {
|
||||
return tuple;
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ package org.apache.solr.client.solrj.io.stream.expr;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Expression containing a function and set of parameters
|
||||
*/
|
||||
@SuppressWarnings({"overrides"})
|
||||
public class StreamExpression implements StreamExpressionParameter {
|
||||
private String functionName;
|
||||
private List<StreamExpressionParameter> parameters;
|
||||
|
@ -124,4 +124,9 @@ public class StreamExpression implements StreamExpressionParameter {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(functionName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
package org.apache.solr.client.solrj.io.stream.expr;
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Provides a named parameter
|
||||
*/
|
||||
@SuppressWarnings({"overrides"})
|
||||
public class StreamExpressionNamedParameter implements StreamExpressionParameter {
|
||||
private String name;
|
||||
private StreamExpressionParameter parameter;
|
||||
|
@ -106,4 +107,9 @@ public class StreamExpressionNamedParameter implements StreamExpressionParameter
|
|||
|
||||
return this.parameter.equals(check.parameter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
*/
|
||||
package org.apache.solr.client.solrj.io.stream.expr;
|
||||
|
||||
/**
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Basic string stream expression
|
||||
*/
|
||||
@SuppressWarnings({"overrides"})
|
||||
public class StreamExpressionValue implements StreamExpressionParameter {
|
||||
|
||||
private String value;
|
||||
|
@ -63,4 +64,9 @@ public class StreamExpressionValue implements StreamExpressionParameter {
|
|||
|
||||
return this.value.equals(((StreamExpressionValue)other).value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.apache.solr.common.util.ReflectMapWriter;
|
|||
/**
|
||||
* POJO for a plugin metadata used in container plugins
|
||||
*/
|
||||
@SuppressWarnings({"overrides"})
|
||||
public class PluginMeta implements ReflectMapWriter {
|
||||
@JsonProperty(required = true)
|
||||
public String name;
|
||||
|
@ -55,4 +54,8 @@ public class PluginMeta implements ReflectMapWriter {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, version, klass);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ import static org.apache.solr.common.util.Utils.toJSONString;
|
|||
/**
|
||||
* Models a Collection in zookeeper (but that Java name is obviously taken, hence "DocCollection")
|
||||
*/
|
||||
@SuppressWarnings({"overrides"})
|
||||
public class DocCollection extends ZkNodeProps implements Iterable<Slice> {
|
||||
|
||||
public static final String DOC_ROUTER = "router";
|
||||
|
@ -383,10 +382,10 @@ public class DocCollection extends ZkNodeProps implements Iterable<Slice> {
|
|||
return super.equals(that) && Objects.equals(this.name, other.name) && this.znodeVersion == other.znodeVersion;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// throw new UnsupportedOperationException("TODO unimplemented DocCollection.hashCode");
|
||||
// }
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, znodeVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of replicas of type {@link org.apache.solr.common.cloud.Replica.Type#NRT} this collection was created with
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.Objects;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.solr.common.util.Utils;
|
||||
@SuppressWarnings({"overrides"})
|
||||
public class Replica extends ZkNodeProps {
|
||||
|
||||
/**
|
||||
|
@ -153,10 +152,12 @@ public class Replica extends ZkNodeProps {
|
|||
|
||||
return name.equals(replica.name);
|
||||
}
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// throw new UnsupportedOperationException("TODO unimplemented Replica.hashCode()");
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
}
|
||||
|
||||
/** Also known as coreNodeName. */
|
||||
public String getName() {
|
||||
return name;
|
||||
|
|
|
@ -17,10 +17,7 @@
|
|||
package org.apache.solr.common.cloud;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.solr.common.util.JavaBinCodec;
|
||||
import org.apache.solr.common.util.Utils;
|
||||
|
@ -31,7 +28,6 @@ import static org.apache.solr.common.util.Utils.toJSONString;
|
|||
/**
|
||||
* ZkNodeProps contains generic immutable properties.
|
||||
*/
|
||||
@SuppressWarnings({"overrides"})
|
||||
public class ZkNodeProps implements JSONWriter.Writable {
|
||||
|
||||
protected final Map<String,Object> propMap;
|
||||
|
@ -171,8 +167,9 @@ public class ZkNodeProps implements JSONWriter.Writable {
|
|||
public boolean equals(Object that) {
|
||||
return that instanceof ZkNodeProps && ((ZkNodeProps)that).propMap.equals(this.propMap);
|
||||
}
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// throw new UnsupportedOperationException("TODO unimplemented ZkNodeProps.hashCode");
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(propMap);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.solr.common.NavigableObject;
|
||||
import org.apache.solr.common.SolrException;
|
||||
|
@ -40,7 +41,6 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||
import static java.util.Collections.unmodifiableList;
|
||||
import static java.util.Collections.unmodifiableSet;
|
||||
|
||||
@SuppressWarnings({"overrides"})
|
||||
public class ValidatingJsonMap implements Map<String, Object>, NavigableObject {
|
||||
|
||||
private static final String INCLUDE = "#include";
|
||||
|
@ -348,10 +348,10 @@ public class ValidatingJsonMap implements Map<String, Object>, NavigableObject {
|
|||
return that instanceof Map && this.delegate.equals(that);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// throw new UnsupportedOperationException("TODO unimplemented ValidatingJsonMap.hashCode");
|
||||
// }
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(delegate);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public static final ValidatingJsonMap EMPTY = new ValidatingJsonMap(Collections.EMPTY_MAP);
|
||||
|
|
Loading…
Reference in New Issue