SQL: Fix checkstyle / add missing hashCode (elastic/x-pack-elasticsearch#3323)
* Fix checkstyle / add missing hashCode * Improve formatting Original commit: elastic/x-pack-elasticsearch@a3ad2793bb
This commit is contained in:
parent
59e6d34c29
commit
624a1530c0
|
@ -9,7 +9,6 @@
|
|||
<suppress files="sql[/\\]server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\]parser[/\\]SqlBase(Base(Listener|Visitor)|Lexer|Listener|Parser|Visitor).java" checks="." />
|
||||
|
||||
<suppress files="sql[/\\]server[/\\].*.java" checks="LineLength" />
|
||||
<suppress files="sql[/\\]server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]sql[/\\]expression[/\\].*.java" checks="EqualsHashCode" />
|
||||
|
||||
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]common[/\\]action[/\\]XPackDeleteByQueryAction.java" checks="LineLength" />
|
||||
<suppress files="plugin[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]xpack[/\\]ml[/\\]action[/\\]StopDatafeedAction.java" checks="LineLength" />
|
||||
|
|
|
@ -43,6 +43,7 @@ public abstract class Attribute extends NamedExpression {
|
|||
return qualifier == null ? name() : qualifier + "." + name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nullable() {
|
||||
return nullable;
|
||||
}
|
||||
|
@ -89,6 +90,22 @@ public abstract class Attribute extends NamedExpression {
|
|||
return other instanceof Attribute ? id().equals(((Attribute) other).id()) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), qualifier, nullable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (super.equals(obj)) {
|
||||
Attribute other = (Attribute) obj;
|
||||
return Objects.equals(qualifier, other.qualifier)
|
||||
&& Objects.equals(nullable, other.nullable);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name() + "{" + label() + "}" + "#" + id();
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.sql.expression;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.elasticsearch.xpack.sql.tree.Location;
|
||||
import org.elasticsearch.xpack.sql.type.DataType;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class TypedAttribute extends Attribute {
|
||||
|
||||
private final DataType dataType;
|
||||
|
@ -29,21 +29,17 @@ public abstract class TypedAttribute extends Attribute {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), dataType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (super.equals(obj)) {
|
||||
TypedAttribute other = (TypedAttribute) obj;
|
||||
return Objects.equals(dataType, other.dataType);
|
||||
}
|
||||
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TypedAttribute other = (TypedAttribute) obj;
|
||||
return Objects.equals(name(), other.name())
|
||||
&& Objects.equals(id(), other.id())
|
||||
&& Objects.equals(nullable(), other.nullable())
|
||||
&& Objects.equals(dataType(), other.dataType())
|
||||
&& Objects.equals(qualifier(), other.qualifier())
|
||||
&& Objects.equals(synthetic(), other.synthetic());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,18 +34,14 @@ public class UnresolvedAlias extends UnresolvedNamedExpression {
|
|||
throw new UnresolvedException("nullable", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), child);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UnresolvedAlias other = (UnresolvedAlias) obj;
|
||||
return Objects.equals(child, other.child);
|
||||
return super.equals(obj) && Objects.equals(child, ((UnresolvedAlias) obj).child);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -92,6 +92,11 @@ public class UnresolvedAttribute extends Attribute implements Unresolvable {
|
|||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), resolutionMetadata, unresolvedMsg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (super.equals(obj)) {
|
||||
|
|
|
@ -31,20 +31,21 @@ public class UnresolvedStar extends UnresolvedNamedExpression {
|
|||
return qualifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), qualifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (super.equals(obj)) {
|
||||
UnresolvedStar other = (UnresolvedStar) obj;
|
||||
return Objects.equals(qualifier, other.qualifier);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private String message() {
|
||||
return (qualifier() != null ? qualifier() + "." : "") + "*";
|
||||
}
|
||||
|
|
|
@ -26,6 +26,11 @@ public abstract class FunctionAttribute extends TypedAttribute {
|
|||
return functionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), functionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return super.equals(obj) && Objects.equals(functionId, ((FunctionAttribute) obj).functionId());
|
||||
|
|
|
@ -47,6 +47,11 @@ public class AggregateFunctionAttribute extends FunctionAttribute {
|
|||
return new AggregateFunctionAttribute(location(), name(), dataType(), qualifier(), nullable(), id(), synthetic(), functionId, propertyPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), propertyPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return super.equals(obj) && Objects.equals(propertyPath(), ((AggregateFunctionAttribute) obj).propertyPath());
|
||||
|
|
|
@ -77,6 +77,11 @@ public class Cast extends UnaryScalarFunction {
|
|||
return new UnaryProcessorDefinition(this, ProcessorDefinitions.toProcessorDefinition(field()), new CastProcessor(DataTypeConversion.conversionFor(from(), to())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), dataType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return super.equals(obj) && Objects.equals(dataType, ((Cast) obj).dataType());
|
||||
|
|
|
@ -59,6 +59,11 @@ public class ScalarFunctionAttribute extends FunctionAttribute {
|
|||
processorDef);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), orderBy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return super.equals(obj) && Objects.equals(orderBy, ((ScalarFunctionAttribute) obj).orderBy());
|
||||
|
|
Loading…
Reference in New Issue