mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.alibaba.druid.mapping;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Entity {
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private String tableName;
|
||||
|
||||
private List<Property> properties = new ArrayList<Property>();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public List<Property> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(List<Property> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.alibaba.druid.mapping;
|
||||
|
||||
import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitorAdapter;
|
||||
|
||||
public class EntityMapingMySqlVisitor extends MySqlASTVisitorAdapter {
|
||||
|
||||
private final Entity entity;
|
||||
|
||||
public EntityMapingMySqlVisitor(Entity entity){
|
||||
super();
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.alibaba.druid.mapping;
|
||||
|
||||
public class Property {
|
||||
|
||||
private String name;
|
||||
private String dbColumnName;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDbColumnName() {
|
||||
return dbColumnName;
|
||||
}
|
||||
|
||||
public void setDbColumnName(String dbColumnName) {
|
||||
this.dbColumnName = dbColumnName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,27 +26,26 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
public class SQLAggregateExpr extends SQLExprImpl implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected SQLIdentifierExpr methodName;
|
||||
protected String methodName;
|
||||
protected int option;
|
||||
protected final List<SQLExpr> arguments = new ArrayList<SQLExpr>();
|
||||
|
||||
public SQLAggregateExpr(String methodName){
|
||||
|
||||
this.methodName = new SQLIdentifierExpr(methodName);
|
||||
this.methodName = methodName;
|
||||
this.option = 1;
|
||||
}
|
||||
|
||||
public SQLAggregateExpr(String methodName, int option){
|
||||
|
||||
this.methodName = new SQLIdentifierExpr(methodName);
|
||||
this.methodName = methodName;
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
public SQLIdentifierExpr getMethodName() {
|
||||
public String getMethodName() {
|
||||
return this.methodName;
|
||||
}
|
||||
|
||||
public void setMethodName(SQLIdentifierExpr methodName) {
|
||||
public void setMethodName(String methodName) {
|
||||
this.methodName = methodName;
|
||||
}
|
||||
|
||||
@@ -75,7 +74,6 @@ public class SQLAggregateExpr extends SQLExprImpl implements Serializable {
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, this.methodName);
|
||||
acceptChild(visitor, this.arguments);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.alibaba.druid.sql.dialect.mysql.visitor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
|
||||
public class MySqlMappingVisitor extends MySqlASTVisitorAdapter {
|
||||
|
||||
private final Map<String, SQLExpr> mapping = new HashMap<String, SQLExpr>();
|
||||
|
||||
public void addMapping(String column, String targetExpr) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import java.io.Serializable;
|
||||
|
||||
import com.alibaba.druid.sql.ast.SQLExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
@@ -54,10 +53,6 @@ public class OracleAggregateExpr extends SQLAggregateExpr implements Serializabl
|
||||
super(methodName, option);
|
||||
}
|
||||
|
||||
public SQLIdentifierExpr getMethodName() {
|
||||
return this.methodName;
|
||||
}
|
||||
|
||||
public OracleAnalytic getOver() {
|
||||
return this.over;
|
||||
}
|
||||
@@ -87,7 +82,6 @@ public class OracleAggregateExpr extends SQLAggregateExpr implements Serializabl
|
||||
this.accept0((OracleASTVisitor) visitor);
|
||||
} else {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, this.methodName);
|
||||
acceptChild(visitor, this.arguments);
|
||||
acceptChild(visitor, this.over);
|
||||
}
|
||||
@@ -97,7 +91,6 @@ public class OracleAggregateExpr extends SQLAggregateExpr implements Serializabl
|
||||
|
||||
public void accept0(OracleASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, this.methodName);
|
||||
acceptChild(visitor, this.arguments);
|
||||
acceptChild(visitor, this.over);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
}
|
||||
|
||||
public boolean visit(OracleAggregateExpr expr) {
|
||||
expr.getMethodName().accept(this);
|
||||
print(expr.getMethodName());
|
||||
print("(");
|
||||
if (expr.isUnique()) {
|
||||
print("UNIQUE ");
|
||||
|
||||
@@ -387,7 +387,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter {
|
||||
}
|
||||
|
||||
public boolean visit(SQLAggregateExpr x) {
|
||||
x.getMethodName().accept(this);
|
||||
print(x.getMethodName());
|
||||
print("(");
|
||||
printAndAccept(x.getArguments(), ", ");
|
||||
print(")");
|
||||
|
||||
Reference in New Issue
Block a user