1 package org.davidmoten.rx.jdbc.callable.internal;
2
3 import java.sql.ResultSet;
4
5 import javax.annotation.Nonnull;
6
7 import org.davidmoten.rx.jdbc.TransactedCallableBuilder.CallableResultSets3Builder;
8 import org.davidmoten.rx.jdbc.Util;
9 import org.davidmoten.rx.jdbc.tuple.Tuple2;
10 import org.davidmoten.rx.jdbc.tuple.Tuple3;
11 import org.davidmoten.rx.jdbc.tuple.Tuple4;
12 import org.davidmoten.rx.jdbc.tuple.Tuple5;
13 import org.davidmoten.rx.jdbc.tuple.Tuple6;
14 import org.davidmoten.rx.jdbc.tuple.Tuple7;
15 import org.davidmoten.rx.jdbc.tuple.Tuples;
16
17 import com.github.davidmoten.guavamini.Preconditions;
18
19 import io.reactivex.functions.Function;
20
21 public interface TxGetter3<T1, T2> {
22
23 <T3> CallableResultSets3Builder<T1, T2, T3> get(
24 Function<? super ResultSet, ? extends T3> function);
25
26 default <T3> CallableResultSets3Builder<T1, T2, T3> getAs(@Nonnull Class<T3> cls) {
27 Preconditions.checkNotNull(cls, "cls cannot be null");
28 return get(rs -> Util.mapObject(rs, cls, 1));
29 }
30
31 default <A, B> CallableResultSets3Builder<T1, T2, Tuple2<A, B>> getAs(@Nonnull Class<A> cls1,
32 @Nonnull Class<B> cls2) {
33 return get(Tuples.tuple(cls1, cls2));
34 }
35
36 default <A, B, C> CallableResultSets3Builder<T1, T2, Tuple3<A, B, C>> getAs(
37 @Nonnull Class<A> cls1, @Nonnull Class<B> cls2, @Nonnull Class<C> cls3) {
38 return get(Tuples.tuple(cls1, cls2, cls3));
39 }
40
41 default <A, B, C, D> CallableResultSets3Builder<T1, T2, Tuple4<A, B, C, D>> getAs(
42 @Nonnull Class<A> cls1, @Nonnull Class<B> cls2, @Nonnull Class<C> cls3,
43 @Nonnull Class<D> cls4) {
44 return get(Tuples.tuple(cls1, cls2, cls3, cls4));
45 }
46
47 default <A, B, C, D, E> CallableResultSets3Builder<T1, T2, Tuple5<A, B, C, D, E>> getAs(
48 @Nonnull Class<A> cls1, @Nonnull Class<B> cls2, @Nonnull Class<C> cls3,
49 @Nonnull Class<D> cls4, @Nonnull Class<E> cls5) {
50 return get(Tuples.tuple(cls1, cls2, cls3, cls4, cls5));
51 }
52
53 default <A, B, C, D, E, F> CallableResultSets3Builder<T1, T2, Tuple6<A, B, C, D, E, F>> getAs(
54 @Nonnull Class<A> cls1, @Nonnull Class<B> cls2, @Nonnull Class<C> cls3,
55 @Nonnull Class<D> cls4, @Nonnull Class<E> cls5, @Nonnull Class<F> cls6) {
56 return get(Tuples.tuple(cls1, cls2, cls3, cls4, cls5, cls6));
57 }
58
59 default <A, B, C, D, E, F, G> CallableResultSets3Builder<T1, T2, Tuple7<A, B, C, D, E, F, G>> getAs(
60 @Nonnull Class<A> cls1, @Nonnull Class<B> cls2, @Nonnull Class<C> cls3,
61 @Nonnull Class<D> cls4, @Nonnull Class<E> cls5, @Nonnull Class<F> cls6,
62 @Nonnull Class<G> cls7) {
63 return get(Tuples.tuple(cls1, cls2, cls3, cls4, cls5, cls6, cls7));
64 }
65
66 }