mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
IN PROGRESS - issue DRUID-81: SQLExpr的派生类实现Equals和HashCode方法
http://code.alibabatech.com/jira/browse/DRUID-81
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user