From ca43a27db9692c484032a543a4ba6006ca053e58 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Wed, 16 Jan 2019 10:42:32 -0500 Subject: [PATCH] Revert "Delete ListQueryMapper" This reverts commit 3f4d3121 --- .../moparisthebest/jdbc/ListQueryMapper.java | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 querymapper/src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java diff --git a/querymapper/src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java b/querymapper/src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java new file mode 100644 index 0000000..3b5effc --- /dev/null +++ b/querymapper/src/main/java/com/moparisthebest/jdbc/ListQueryMapper.java @@ -0,0 +1,119 @@ +package com.moparisthebest.jdbc; + +import com.moparisthebest.jdbc.codegen.JdbcMapper; +import com.moparisthebest.jdbc.util.ResultSetIterable; + +import java.lang.reflect.Method; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; +//IFJAVA8_START +import java.util.stream.Stream; +//IFJAVA8_END + +public class ListQueryMapper extends QueryMapper { + + protected final QueryMapper delegate; + protected final boolean closeDelegate; + + public static final String inListReplace = "{inList}"; + + protected ListQueryMapper(Connection conn, String jndiName, Factory factory, final QueryMapper d, ResultSetMapper cm, InList inList, boolean closeDelegate) { + super(d == null ? conn : d.conn, jndiName, factory, d == null ? cm : d.cm, d == null ? inList : d.inList); + this.closeDelegate = closeDelegate; + this.delegate = d; + } + + protected ListQueryMapper(Connection conn, String jndiName, Factory factory, final QueryMapper d, ResultSetMapper cm, InList inList) { + this(conn, jndiName, factory, d, cm, inList, false); + } + + protected ListQueryMapper(Connection conn, String jndiName, Factory factory, QueryMapper delegate, ResultSetMapper cm) { + this(conn, jndiName, factory, delegate, cm, defaultInList); + } + + public ListQueryMapper(InList inList, QueryMapper delegate, boolean closeDelegate) { + this(null, null, null, delegate, null, inList, closeDelegate); + } + + public ListQueryMapper(QueryMapper delegate, InList inList) { + this(null, null, null, delegate, null, inList); + } + + public ListQueryMapper(QueryMapper delegate) { + this(null, null, null, delegate, null, defaultInList); + } + + public ListQueryMapper(Connection conn, InList inList) { + this(conn, null, null, null, null, inList); + } + + public ListQueryMapper(Connection conn, ResultSetMapper cm, InList inList) { + this(conn, null, null, null, cm, inList); + } + + public ListQueryMapper(Connection conn) { + this(conn, defaultInList); + } + + public ListQueryMapper(Connection conn, ResultSetMapper cm) { + this(conn, cm, defaultInList); + } + + public ListQueryMapper(String jndiName, InList inList) { + this(null, jndiName, null, null, null, inList); + } + + public ListQueryMapper(String jndiName, ResultSetMapper cm, InList inList) { + this(null, jndiName, null, null, cm, inList); + } + + public ListQueryMapper(String jndiName) { + this(jndiName, defaultInList); + } + + public ListQueryMapper(String jndiName, ResultSetMapper cm) { + this(jndiName, cm, defaultInList); + } + + public ListQueryMapper(Factory factory, InList inList) { + this(null, null, factory, null, null, inList); + } + + public ListQueryMapper(Factory factory, ResultSetMapper cm, InList inList) { + this(null, null, factory, null, cm, inList); + } + + public ListQueryMapper(Factory factory) { + this(factory, defaultInList); + } + + public ListQueryMapper(Factory factory, ResultSetMapper cm) { + this(factory, cm, defaultInList); + } + + public static ListQueryMapper of(final Factory qmFactory, final InList inList) throws SQLException { + return new ListQueryMapper(inList, qmFactory.create(), true); + } + + public static ListQueryMapper of(final QueryMapper qm, final InList inList) { + return new ListQueryMapper(inList, qm, false); + } + + public static ListQueryMapper of(final Factory qmFactory) throws SQLException { + return of(qmFactory, defaultInList); + } + + public static ListQueryMapper of(final QueryMapper qm) { + return of(qm, defaultInList); + } + + @Override + public void close() { + if(closeDelegate) + delegate.close(); + } +} +