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

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

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

import com.github.davidmoten.rx.jdbc.QueryUpdate.Builder;

import rx.Observable;
import rx.Observable.Transformer;

/**
 * {@link Transformer} corresonding to {@link QueryUpdateOperation}.
 */
final class QueryUpdateTransformer implements Transformer {

    private final Builder builder;
    private final OperatorType operatorType;

    /**
     * Constructor.
     * 
     * @param builder
     * @param operatorType
     */
    QueryUpdateTransformer(final QueryUpdate.Builder builder, final OperatorType operatorType) {
        this.builder = builder;
        this.operatorType = operatorType;
    }

    @Override
    public Observable call(Observable source) {
        if (operatorType == OperatorType.PARAMETER)
            return builder.parameters(source).count();
        else if (operatorType == OperatorType.DEPENDENCY)
            // dependency
            return builder.dependsOn(source).count();
        else
            throw new RuntimeException("does not handle " + operatorType);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy