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.CallableBuilder.CallableResultSets4Builder;
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 Getter4<T1, T2, T3> {
22
23 <T4> CallableResultSets4Builder<T1, T2, T3, T4> get(Function<? super ResultSet, ? extends T4> function);
24
25 default <T4> CallableResultSets4Builder<T1, T2, T3, T4> getAs(@Nonnull Class<T4> cls) {
26 Preconditions.checkNotNull(cls, "cls cannot be null");
27 return get(rs -> Util.mapObject(rs, cls, 1));
28 }
29
30 default <A, B> CallableResultSets4Builder<T1, T2, T3, Tuple2<A, B>> getAs(@Nonnull Class<A> cls1,
31 @Nonnull Class<B> cls2) {
32 return get(Tuples.tuple(cls1, cls2));
33 }
34
35 default <A, B, C> CallableResultSets4Builder<T1, T2, T3, Tuple3<A, B, C>> getAs(@Nonnull Class<A> cls1,
36 @Nonnull Class<B> cls2, @Nonnull Class<C> cls3) {
37 return get(Tuples.tuple(cls1, cls2, cls3));
38 }
39
40 default <A, B, C, D> CallableResultSets4Builder<T1, T2, T3, Tuple4<A, B, C, D>> getAs(@Nonnull Class<A> cls1,
41 @Nonnull Class<B> cls2, @Nonnull Class<C> cls3, @Nonnull Class<D> cls4) {
42 return get(Tuples.tuple(cls1, cls2, cls3, cls4));
43 }
44
45 default <A, B, C, D, E> CallableResultSets4Builder<T1, T2, T3, Tuple5<A, B, C, D, E>> getAs(@Nonnull Class<A> cls1,
46 @Nonnull Class<B> cls2, @Nonnull Class<C> cls3, @Nonnull Class<D> cls4, @Nonnull Class<E> cls5) {
47 return get(Tuples.tuple(cls1, cls2, cls3, cls4, cls5));
48 }
49
50 default <A, B, C, D, E, F> CallableResultSets4Builder<T1, T2, T3, Tuple6<A, B, C, D, E, F>> getAs(
51 @Nonnull Class<A> cls1, @Nonnull Class<B> cls2, @Nonnull Class<C> cls3, @Nonnull Class<D> cls4,
52 @Nonnull Class<E> cls5, @Nonnull Class<F> cls6) {
53 return get(Tuples.tuple(cls1, cls2, cls3, cls4, cls5, cls6));
54 }
55
56 default <A, B, C, D, E, F, G> CallableResultSets4Builder<T1, T2, T3, Tuple7<A, B, C, D, E, F, G>> getAs(
57 @Nonnull Class<A> cls1, @Nonnull Class<B> cls2, @Nonnull Class<C> cls3, @Nonnull Class<D> cls4,
58 @Nonnull Class<E> cls5, @Nonnull Class<F> cls6, @Nonnull Class<G> cls7) {
59 return get(Tuples.tuple(cls1, cls2, cls3, cls4, cls5, cls6, cls7));
60 }
61
62 }