SchemaStatVisitor support relationship

This commit is contained in:
温少
2012-02-25 10:07:14 +08:00
5 changed files with 259 additions and 47 deletions
@@ -22,6 +22,15 @@ public class TableStat {
int deleteCount = 0;
int insertCount = 0;
int dropCount = 0;
int mergeCount = 0;
public int getMergeCount() {
return mergeCount;
}
public void incrementMergeCount() {
this.mergeCount++;
}
public int getDropCount() {
return dropCount;
@@ -85,6 +94,9 @@ public class TableStat {
public String toString() {
StringBuilder buf = new StringBuilder(4);
if (mergeCount > 0) {
buf.append("Merge");
}
if (insertCount > 0) {
buf.append("Insert");
}
@@ -135,6 +147,89 @@ public class TableStat {
}
}
public static class Relationship {
private Column left;
private Column right;
private String operator;
public Column getLeft() {
return left;
}
public void setLeft(Column left) {
this.left = left;
}
public Column getRight() {
return right;
}
public void setRight(Column right) {
this.right = right;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((left == null) ? 0 : left.hashCode());
result = prime * result + ((operator == null) ? 0 : operator.hashCode());
result = prime * result + ((right == null) ? 0 : right.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;
}
Relationship other = (Relationship) obj;
if (left == null) {
if (other.left != null) {
return false;
}
} else if (!left.equals(other.left)) {
return false;
}
if (operator == null) {
if (other.operator != null) {
return false;
}
} else if (!operator.equals(other.operator)) {
return false;
}
if (right == null) {
if (other.right != null) {
return false;
}
} else if (!right.equals(other.right)) {
return false;
}
return true;
}
@Override
public String toString() {
return left + " " + operator + " " + right;
}
}
public static class Condition {
private Column column;
@@ -272,7 +367,7 @@ public class TableStat {
}
public static enum Mode {
Insert(1), Update(2), Delete(4), Select(8);
Insert(1), Update(2), Delete(4), Select(8), Merge(16);
public final int mark;