IN PROGRESS - issue DRUID-81: SQLExpr的派生类实现Equals和HashCode方法

http://code.alibabatech.com/jira/browse/DRUID-81
This commit is contained in:
wenshao
2011-11-07 15:51:51 +08:00
parent 72c0d1c7b5
commit 01fd745646
45 changed files with 1514 additions and 1 deletions
@@ -58,4 +58,36 @@ public class MySqlBinaryExpr extends SQLLiteralExpr implements MySqlExpr {
buf.append(value);
buf.append('\'');
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
MySqlBinaryExpr other = (MySqlBinaryExpr) obj;
if (value == null) {
if (other.value != null) {
return false;
}
} else if (!value.equals(other.value)) {
return false;
}
return true;
}
}
@@ -56,4 +56,32 @@ public class MySqlBooleanExpr extends SQLLiteralExpr implements MySqlExpr {
buf.append("x");
buf.append(value ? "TRUE" : "FALSE");
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (value ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
MySqlBooleanExpr other = (MySqlBooleanExpr) obj;
if (value != other.value) {
return false;
}
return true;
}
}
@@ -59,4 +59,38 @@ public class MySqlExtractExpr extends SQLExprImpl implements MySqlExpr {
mysqlVisitor.endVisit(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((unit == null) ? 0 : unit.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof MySqlExtractExpr)) {
return false;
}
MySqlExtractExpr other = (MySqlExtractExpr) obj;
if (unit != other.unit) {
return false;
}
if (value == null) {
if (other.value != null) {
return false;
}
} else if (!value.equals(other.value)) {
return false;
}
return true;
}
}
@@ -61,4 +61,38 @@ public class MySqlIntervalExpr extends SQLExprImpl implements MySqlExpr {
mysqlVisitor.endVisit(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((unit == null) ? 0 : unit.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
MySqlIntervalExpr other = (MySqlIntervalExpr) obj;
if (unit != other.unit) {
return false;
}
if (value == null) {
if (other.value != null) {
return false;
}
} else if (!value.equals(other.value)) {
return false;
}
return true;
}
}
@@ -82,4 +82,47 @@ public class MySqlMatchAgainstExpr extends SQLExprImpl implements MySqlExpr {
}
mysqlVisitor.endVisit(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((against == null) ? 0 : against.hashCode());
result = prime * result + ((columns == null) ? 0 : columns.hashCode());
result = prime * result + ((searchModifier == null) ? 0 : searchModifier.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
MySqlMatchAgainstExpr other = (MySqlMatchAgainstExpr) obj;
if (against == null) {
if (other.against != null) {
return false;
}
} else if (!against.equals(other.against)) {
return false;
}
if (columns == null) {
if (other.columns != null) {
return false;
}
} else if (!columns.equals(other.columns)) {
return false;
}
if (searchModifier != other.searchModifier) {
return false;
}
return true;
}
}
@@ -29,4 +29,35 @@ public class GroupingSetExpr extends SQLExprImpl {
visitor.endVisit(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((parameters == null) ? 0 : parameters.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GroupingSetExpr)) {
return false;
}
GroupingSetExpr other = (GroupingSetExpr) obj;
if (parameters == null) {
if (other.parameters != null) {
return false;
}
} else if (!parameters.equals(other.parameters)) {
return false;
}
return true;
}
}
@@ -42,4 +42,34 @@ public class OracleBinaryDoubleExpr extends SQLNumericLiteralExpr implements Ora
visitor.endVisit(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
OracleBinaryDoubleExpr other = (OracleBinaryDoubleExpr) obj;
if (value == null) {
if (other.value != null) {
return false;
}
} else if (!value.equals(other.value)) {
return false;
}
return true;
}
}
@@ -42,4 +42,34 @@ public class OracleBinaryFloatExpr extends SQLNumericLiteralExpr implements Orac
visitor.endVisit(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
OracleBinaryFloatExpr other = (OracleBinaryFloatExpr) obj;
if (value == null) {
if (other.value != null) {
return false;
}
} else if (!value.equals(other.value)) {
return false;
}
return true;
}
}
@@ -39,4 +39,34 @@ public class OracleCursorExpr extends SQLExprImpl implements OracleExpr {
}
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((query == null) ? 0 : query.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
OracleCursorExpr other = (OracleCursorExpr) obj;
if (query == null) {
if (other.query != null) {
return false;
}
} else if (!query.equals(other.query)) {
return false;
}
return true;
}
}
@@ -47,4 +47,34 @@ public class OracleDateExpr extends SQLLiteralExpr implements OracleExpr {
visitor.endVisit(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((literal == null) ? 0 : literal.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
OracleDateExpr other = (OracleDateExpr) obj;
if (literal == null) {
if (other.literal != null) {
return false;
}
} else if (!literal.equals(other.literal)) {
return false;
}
return true;
}
}
@@ -65,4 +65,42 @@ public class OracleDbLinkExpr extends SQLExprImpl implements SQLName, OracleExpr
visitor.endVisit(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((dbLink == null) ? 0 : dbLink.hashCode());
result = prime * result + ((expr == null) ? 0 : expr.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
OracleDbLinkExpr other = (OracleDbLinkExpr) obj;
if (dbLink == null) {
if (other.dbLink != null) {
return false;
}
} else if (!dbLink.equals(other.dbLink)) {
return false;
}
if (expr == null) {
if (other.expr != null) {
return false;
}
} else if (!expr.equals(other.expr)) {
return false;
}
return true;
}
}
@@ -66,4 +66,39 @@ public class OracleExtractExpr extends SQLExprImpl implements OracleExpr {
visitor.endVisit(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((from == null) ? 0 : from.hashCode());
result = prime * result + ((unit == null) ? 0 : unit.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
OracleExtractExpr other = (OracleExtractExpr) obj;
if (from == null) {
if (other.from != null) {
return false;
}
} else if (!from.equals(other.from)) {
return false;
}
if (unit != other.unit) {
return false;
}
return true;
}
}
@@ -91,4 +91,67 @@ public class OracleIntervalExpr extends SQLLiteralExpr implements OracleExpr {
visitor.visit(this);
visitor.endVisit(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((factionalSecondsPrecision == null) ? 0 : factionalSecondsPrecision.hashCode());
result = prime * result + ((precision == null) ? 0 : precision.hashCode());
result = prime * result + ((toFactionalSecondsPrecision == null) ? 0 : toFactionalSecondsPrecision.hashCode());
result = prime * result + ((toType == null) ? 0 : toType.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
OracleIntervalExpr other = (OracleIntervalExpr) obj;
if (factionalSecondsPrecision == null) {
if (other.factionalSecondsPrecision != null) {
return false;
}
} else if (!factionalSecondsPrecision.equals(other.factionalSecondsPrecision)) {
return false;
}
if (precision == null) {
if (other.precision != null) {
return false;
}
} else if (!precision.equals(other.precision)) {
return false;
}
if (toFactionalSecondsPrecision == null) {
if (other.toFactionalSecondsPrecision != null) {
return false;
}
} else if (!toFactionalSecondsPrecision.equals(other.toFactionalSecondsPrecision)) {
return false;
}
if (toType != other.toType) {
return false;
}
if (type != other.type) {
return false;
}
if (value == null) {
if (other.value != null) {
return false;
}
} else if (!value.equals(other.value)) {
return false;
}
return true;
}
}
@@ -38,4 +38,34 @@ public class OracleIsSetExpr extends SQLExprImpl implements OracleExpr {
}
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((nestedTable == null) ? 0 : nestedTable.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
OracleIsSetExpr other = (OracleIsSetExpr) obj;
if (nestedTable == null) {
if (other.nestedTable != null) {
return false;
}
} else if (!nestedTable.equals(other.nestedTable)) {
return false;
}
return true;
}
}
@@ -59,4 +59,34 @@ public class OracleOuterExpr extends SQLExprImpl implements OracleExpr {
visitor.endVisit(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((expr == null) ? 0 : expr.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
OracleOuterExpr other = (OracleOuterExpr) obj;
if (expr == null) {
if (other.expr != null) {
return false;
}
} else if (!expr.equals(other.expr)) {
return false;
}
return true;
}
}
@@ -55,4 +55,43 @@ public class OracleTimestampExpr extends SQLLiteralExpr implements OracleExpr {
visitor.endVisit(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((literal == null) ? 0 : literal.hashCode());
result = prime * result + ((timeZone == null) ? 0 : timeZone.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
OracleTimestampExpr other = (OracleTimestampExpr) obj;
if (literal == null) {
if (other.literal != null) {
return false;
}
} else if (!literal.equals(other.literal)) {
return false;
}
if (timeZone == null) {
if (other.timeZone != null) {
return false;
}
} else if (!timeZone.equals(other.timeZone)) {
return false;
}
return true;
}
}
@@ -91,4 +91,74 @@ public class OracleTableExpr extends SQLExprImpl {
visitor.endVisit(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((dbLink == null) ? 0 : dbLink.hashCode());
result = prime * result + ((partition == null) ? 0 : partition.hashCode());
result = prime * result + ((partitionFor == null) ? 0 : partitionFor.hashCode());
result = prime * result + ((subPartition == null) ? 0 : subPartition.hashCode());
result = prime * result + ((subPartitionFor == null) ? 0 : subPartitionFor.hashCode());
result = prime * result + ((table == null) ? 0 : table.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
OracleTableExpr other = (OracleTableExpr) obj;
if (dbLink == null) {
if (other.dbLink != null) {
return false;
}
} else if (!dbLink.equals(other.dbLink)) {
return false;
}
if (partition == null) {
if (other.partition != null) {
return false;
}
} else if (!partition.equals(other.partition)) {
return false;
}
if (partitionFor == null) {
if (other.partitionFor != null) {
return false;
}
} else if (!partitionFor.equals(other.partitionFor)) {
return false;
}
if (subPartition == null) {
if (other.subPartition != null) {
return false;
}
} else if (!subPartition.equals(other.subPartition)) {
return false;
}
if (subPartitionFor == null) {
if (other.subPartitionFor != null) {
return false;
}
} else if (!subPartitionFor.equals(other.subPartitionFor)) {
return false;
}
if (table == null) {
if (other.table != null) {
return false;
}
} else if (!table.equals(other.table)) {
return false;
}
return true;
}
}