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