com.giants.dal.sharding.config.DalShardingRoutingConfig Maven / Gradle / Ivy
/**
*
*/
package com.giants.dal.sharding.config;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils;
import com.giants.dal.sharding.config.element.Algorithm;
import com.giants.dal.sharding.config.element.Strategy;
import com.giants.dal.sharding.config.element.Table;
import com.giants.xmlmapping.annotation.XmlEntity;
import com.giants.xmlmapping.annotation.XmlManyElement;
/**
* @author vencent.lu
*
* Create Date:2014年7月11日
*/
@XmlEntity
public class DalShardingRoutingConfig implements Serializable {
private static final long serialVersionUID = -7294284024428105643L;
@XmlManyElement
private List algorithms;
private Map algorithmMap;
@XmlManyElement
private List strategies;
private Map strategyMap;
@XmlManyElement
private List tables;
private Map tableMap;
public Algorithm getAlgorithm(String name) {
if (this.algorithmMap == null) {
return null;
}
return this.algorithmMap.get(name);
}
public Strategy getStrategy(String name) {
if (this.strategyMap == null) {
return null;
}
return this.strategyMap.get(name);
}
public Table getTable(String name) {
if (this.tableMap == null) {
return null;
}
return this.tableMap.get(name);
}
/**
* @return the hashAlgorithms
*/
public List getAlgorithms() {
return algorithms;
}
/**
* @param algorithms the hashAlgorithms to set
*/
public void setHashAlgorithms(List algorithms) {
this.algorithms = algorithms;
if (CollectionUtils.isNotEmpty(this.algorithms)) {
this.algorithmMap = new HashMap();
for (Algorithm algorithm : this.algorithms) {
this.algorithmMap.put(algorithm.getName(), algorithm);
}
}
}
/**
* @return the strategies
*/
public List getStrategies() {
return strategies;
}
/**
* @param strategies the strategies to set
*/
public void setStrategies(List strategies) {
this.strategies = strategies;
if (CollectionUtils.isNotEmpty(this.strategies)) {
this.strategyMap = new HashMap();
for (Strategy strategy : this.strategies) {
this.strategyMap.put(strategy.getName(), strategy);
}
}
}
/**
* @return the tables
*/
public List getTables() {
return tables;
}
/**
* @param tables the tables to set
*/
public void setTables(List tables) {
this.tables = tables;
if (CollectionUtils.isNotEmpty(this.tables)) {
this.tableMap = new HashMap();
for (Table table : this.tables) {
this.tableMap.put(table.getName(), table);
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy