All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.davidmoten.rx.jdbc.QueryUpdateOperator Maven / Gradle / Ivy

There is a newer version: 0.7.19
Show newest version
package com.github.davidmoten.rx.jdbc;

import static com.github.davidmoten.rx.OperationToOperator.toOperator;
import rx.Observable;
import rx.Observable.Operator;
import rx.Subscriber;
import rx.functions.Func1;

/**
 * {@link Operator} corresonding to {@link QueryUpdateOperation}.
 */
final class QueryUpdateOperator implements Operator {

    private final Operator operator;

    /**
     * Constructor.
     * 
     * @param builder
     * @param operatorType
     */
    QueryUpdateOperator(final QueryUpdate.Builder builder, final OperatorType operatorType) {
        operator = toOperator(new Func1, Observable>() {
            @Override
            public Observable call(Observable observable) {
                if (operatorType == OperatorType.PARAMETER)
                    return builder.parameters(observable).count();
                else if (operatorType == OperatorType.DEPENDENCY)
                    // dependency
                    return builder.dependsOn(observable).count();
                else
                    throw new RuntimeException("does not handle " + operatorType);
            }
        });
    }

    @Override
    public Subscriber call(Subscriber subscriber) {
        return operator.call(subscriber);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy