View Javadoc
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.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 Getter3<T1, T2> {
22  
23      <T3> CallableResultSets3Builder<T1, T2, T3> get(Function<? super ResultSet, ? extends T3> function);
24  
25      default <T3> CallableResultSets3Builder<T1, T2, T3> getAs(@Nonnull Class<T3> cls) {
26          Preconditions.checkNotNull(cls, "cls cannot be null");
27          return get(rs -> Util.mapObject(rs, cls, 1));
28      }
29  
30      default <A, B> CallableResultSets3Builder<T1, T2, 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> CallableResultSets3Builder<T1, T2, 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> CallableResultSets3Builder<T1, T2, 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> CallableResultSets3Builder<T1, T2, 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> CallableResultSets3Builder<T1, T2, 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> CallableResultSets3Builder<T1, T2, 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  }