pers.clare.hisql.support.ResultSetConverter Maven / Gradle / Ivy
The newest version!
package pers.clare.hisql.support;
import pers.clare.hisql.function.ResultSetValueConverter;
import java.io.InputStream;
import java.sql.ResultSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class ResultSetConverter {
private final Map, ResultSetValueConverter>> converterMap = new ConcurrentHashMap<>();
{
register(InputStream.class, ResultSet::getBinaryStream);
}
public void register(Class> returnClass, ResultSetValueConverter> resultSetValueConverter) {
converterMap.put(returnClass, resultSetValueConverter);
}
@SuppressWarnings("unchecked")
public ResultSetValueConverter get(Class returnClass) {
return (ResultSetValueConverter) converterMap.get(returnClass);
}
}