All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cc.iliz.mybatis.shading.db.ShardingEntry Maven / Gradle / Ivy

There is a newer version: 2.2.2
Show newest version
package cc.iliz.mybatis.shading.db;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.ibatis.mapping.SqlCommandType;
import org.springframework.util.StringUtils;

public class ShardingEntry {
	private Map> dbTables=new ConcurrentHashMap<>();
	private String sql;
	private SqlCommandType sqlCommandType;
	private Set names;
	
	public ShardingEntry(){}
	
	public ShardingEntry(String sql) {
		super();
		this.sql = sql;
	}
	
	public String getSql() {
		return sql;
	}
	public void setSql(String sql) {
		this.sql = sql;
	}

	public SqlCommandType getSqlCommandType() {
		return sqlCommandType;
	}

	public void setSqlCommandType(SqlCommandType sqlCommandType) {
		this.sqlCommandType = sqlCommandType;
	}

	public Set getNames() {
		return names;
	}

	public void setNames(Set names) {
		this.names = names;
	}

	public Map> getDbTables() {
		return dbTables;
	}

	public void setDbTables(Map> dbTables) {
		this.dbTables = dbTables;
	}
	
	public void addItemToDbTables(String datasourceName,String tableName){
		if(StringUtils.isEmpty(datasourceName) || StringUtils.isEmpty(tableName)){
			return;
		}
		Set tableNames = dbTables.get(datasourceName);
		if(tableNames != null){
			tableNames.add(tableName);
		}else{
			tableNames = new HashSet<>();
			tableNames.add(tableName);
			dbTables.put(datasourceName, tableNames);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy