package com.github.davidmoten.rx.jdbc;

import java.sql.ResultSet;

import rx.Observable;
import rx.Observable.Operator;
import rx.Subscriber;
import rx.functions.Func1;

import com.github.davidmoten.rx.OperatorFromOperation;

/**
 * Operator corresponding to the QuerySelectOperation.
 * 
 * @param <T>
 */
public class QuerySelectOperator<T,R> implements Operator<T, R> {

    private final OperatorFromOperation<T, R> operator;

    /**
     * Constructor.
     * 
     * @param builder
     * @param function
     * @param operatorType
     */
    QuerySelectOperator(final QuerySelect.Builder builder, final Func1<ResultSet, T> function,
            final OperatorType operatorType) {
        operator = new OperatorFromOperation<T, R>(new Func1<Observable<R>, Observable<T>>() {

            @SuppressWarnings("rawtypes")
			@Override
            public Observable<T> call(Observable<R> observable) {
                if (operatorType == OperatorType.PARAMETER)
                    return builder.parameters(observable).get(function);
                else if (operatorType==OperatorType.DEPENDENCY)
                    // dependency
                    return builder.dependsOn(observable).get(function);
                else //PARAMETER_LIST
                {
                    @SuppressWarnings("unchecked")
                    Observable<Observable<Object>> obs = (Observable<Observable<Object>>) observable;
                	return obs.flatMap(new Func1<Observable<Object>,Observable<T>>(){
						@Override
						public Observable<T> call(Observable<Object> parameters) {
							return builder.parameters(parameters).get(function);
						}});
                }
            }
        });
    }

    @Override
    public Subscriber<? super R> call(Subscriber<? super T> subscriber) {
        return operator.call(subscriber);
    }
}

@@ -336,16 +336,17 @@
 rator%3CT,
+ 
 R%3E imple
@@ -368,16 +368,16 @@
 T, R%3E %7B%0A
-
 %0A    pri
@@ -796,41 +796,8 @@
     
-@SuppressWarnings(%22rawtypes%22)%0A%09%09%09
 @Ove
@@ -1038,18 +1038,20 @@
 atorType
+ 
 ==
+ 
 Operator
@@ -1196,16 +1196,17 @@
  else //
+ 
 PARAMETE
@@ -1399,17 +1399,20 @@
         
-%09
+    
 return o
@@ -1451,16 +1451,17 @@
 Object%3E,
+ 
 Observab
@@ -1472,32 +1472,69 @@
 %3E%3E()
+ 
 %7B%0A
-%09%09%09%09%09%09@Override%0A%09%09%09%09%09%09
+                        @Override%0A                        
 publ
@@ -1592,15 +1592,36 @@
 ) %7B%0A
-%09%09%09%09%09%09%09
+                            
 retu
@@ -1673,15 +1673,54 @@
 n);%0A
-%09%09%09%09%09%09%7D
+                        %7D%0A                    
 %7D);%0A

remove warning suppression