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

cool.scx.jdbc.result_handler.ResultHandler Maven / Gradle / Ivy

There is a newer version: 2.7.4
Show newest version
package cool.scx.jdbc.result_handler;

import cool.scx.jdbc.bean_builder.BeanBuilder;
import cool.scx.jdbc.dialect.Dialect;
import cool.scx.jdbc.dialect.StandardDialect;

import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * 

ResultHandler interface.

* * @author scx567888 * @version 0.0.7 */ public interface ResultHandler { static ResultHandler> ofMap() { return MapHandler.INSTANCE; } static ResultHandler> ofMap(Supplier> mapSupplier) { return new MapHandler(mapSupplier); } static ResultHandler>> ofMapList() { return MapListHandler.INSTANCE; } static ResultHandler>> ofMapList(Supplier> mapSupplier) { return new MapListHandler(mapSupplier); } static ResultHandler ofBean(Class clazz) { return new BeanHandler<>(BeanBuilder.of(clazz)); } static ResultHandler ofBean(Class clazz, Function columnNameMapping) { return new BeanHandler<>(BeanBuilder.of(clazz, columnNameMapping)); } static ResultHandler ofBean(BeanBuilder beanBuilder) { return new BeanHandler<>(beanBuilder); } static ResultHandler> ofBeanList(Class clazz) { return new BeanListHandler<>(BeanBuilder.of(clazz)); } static ResultHandler> ofBeanList(Class clazz, Function columnNameMapping) { return new BeanListHandler<>(BeanBuilder.of(clazz, columnNameMapping)); } static ResultHandler> ofBeanList(BeanBuilder beanBuilder) { return new BeanListHandler<>(beanBuilder); } static ResultHandler ofBeanConsumer(Class clazz, Consumer consumer) { return new BeanConsumerHandler<>(BeanBuilder.of(clazz), consumer); } static ResultHandler ofBeanConsumer(Class clazz, Function columnNameMapping, Consumer consumer) { return new BeanConsumerHandler<>(BeanBuilder.of(clazz, columnNameMapping), consumer); } static ResultHandler ofBeanConsumer(BeanBuilder beanBuilder, Consumer consumer) { return new BeanConsumerHandler<>(beanBuilder, consumer); } static ResultHandler ofMapConsumer(Consumer> consumer) { return new MapConsumerHandler(consumer); } static ResultHandler ofMapConsumer(Supplier> mapSupplier, Consumer> consumer) { return new MapConsumerHandler(mapSupplier, consumer); } static ResultHandler ofSingleValue(String columnName, Class clazz) { return new SingleValueHandler<>(columnName, clazz); } static ResultHandler ofSingleValue(int columnIndex, Class clazz) { return new SingleValueHandler<>(columnIndex, clazz); } T apply(ResultSet rs, Dialect dialect) throws SQLException; default T apply(ResultSet rs) throws SQLException { return apply(rs, StandardDialect.STANDARD_DIALECT); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy