/**
 * 
 */
package org.springblade.etl.enums;

import java.util.stream.Stream;

import org.springblade.core.tool.exception.ServiceException;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author wookvn
 *
 */
@Getter
@AllArgsConstructor
public enum JdbcType {

	MYSQL("mysql-connector-java-8.0.27.jar", 0),
	
	SQLSERVER("mssql-jdbc-9.2.1.jre8.jar", 2),
	
	ORACLE("ojdbc8-12.2.0.1.jar", 1),
	
	POSTGRESQL("postgresql-42.4.3.jar", 3),
	
//	CLICKHOUSE("clickhouse-jdbc-0.4.5.jar", 4),
	
	KINGBASE("kingbase8-8.6.0.jar", 5),
	DAMENG("DmJdbcDriver18-8.1.2.141.jar", 6),
	SYBASE("jconn4-16.0.jar", 9),
	MONGO("", 10),

	;
	
	private String jarName;
	private Integer dsType;
	
	public final static JdbcType[] jdbcs = JdbcType.values();
	
	/**
	 * 
	 * @param dsType
	 * @return
	 */
	public static JdbcType ofDsType(Integer dsType) {
		return Stream.of(jdbcs).filter(item -> dsType != null && item.getDsType() == dsType.intValue()).findFirst().orElseThrow(() -> new ServiceException("不支持的数据源类型|dsType="+dsType));
	}
}
