fun.langel.cql.spring.Configuration Maven / Gradle / Ivy
The newest version!
package fun.langel.cql.spring;
import fun.langel.cql.bind.CaveRegister;
import fun.langel.cql.datasource.DataSource;
import fun.langel.cql.datasource.DataSourceHolder;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
/**
* @author [email protected](GuHan)
* @since 2021/8/20 5:51 下午
**/
public class Configuration {
private CaveRegister caveRegister = new CaveRegister(this);
private List dataSourceHolders = new LinkedList<>();
public void setDataSource(final List holders) {
this.dataSourceHolders.addAll(holders);
}
public void addDataSource(final DataSourceHolder holder) {
this.dataSourceHolders.add(holder);
}
public List getDataSourceHolders() {
this.dataSourceHolders.sort(Comparator.comparingInt(DataSourceHolder::priority));
return this.dataSourceHolders;
}
public DataSourceHolder getFirstDataSource() {
List holders = getDataSourceHolders();
if (holders.size() > 0) {
return holders.get(0);
}
return null;
}
public DataSourceHolder getDataSource(final String name) {
if (this.dataSourceHolders == null || name == null) {
return null;
}
for (DataSourceHolder holder : this.dataSourceHolders) {
if (name.equalsIgnoreCase(holder.name())) {
return holder;
}
}
return null;
}
public void addCave(final Class> klass) {
this.caveRegister.addCave(klass);
}
public T getCave(final Class> klass) {
return this.caveRegister.getCave(klass);
}
public boolean hasCave(final Class> klass) {
return caveRegister.hasCave(klass);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy