All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
reactor.rx.BiStreams Maven / Gradle / Ivy
/*
* Copyright (c) 2011-2015 Pivotal Software Inc, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package reactor.rx;
import org.reactivestreams.Publisher;
import reactor.fn.BiFunction;
import reactor.fn.tuple.Tuple2;
import reactor.rx.action.pair.ReduceByKeyAction;
import reactor.rx.action.pair.ScanByKeyAction;
import reactor.rx.stream.MapStream;
import java.util.Map;
/**
* A Streams add-on to work with key/value pairs hydrated in {@link reactor.fn.tuple.Tuple2}.
* Main factories support binding incoming values into arbitrary {@link java.util.Map} stores by key.
*
* @author Stephane Maldini
*/
public class BiStreams extends Streams {
private BiStreams() {
}
/**
*
* @param publisher
* @param accumulator
* @param
* @param
* @return
*/
public static Stream> reduceByKey(Publisher> publisher,
BiFunction accumulator) {
return reduceByKey(publisher, null, null, accumulator);
}
/**
*
* @param publisher
* @param mapStream
* @param accumulator
* @param
* @param
* @return
*/
public static Stream> reduceByKey(Publisher> publisher,
MapStream mapStream,
BiFunction accumulator) {
return reduceByKey(publisher, mapStream, mapStream, accumulator);
}
/**
*
* @param publisher
* @param store
* @param listener
* @param accumulator
* @param
* @param
* @return
*/
public static Stream> reduceByKey(Publisher> publisher,
Map store,
Publisher extends MapStream.Signal> listener,
BiFunction accumulator) {
return reduceByKeyOn(publisher, store, listener, accumulator);
}
/**
*
* @param publisher
* @param store
* @param listener
* @param accumulator
* @param
* @param
* @return
*/
public static Stream> reduceByKeyOn(Publisher> publisher,
Map store,
Publisher extends MapStream.Signal> listener,
BiFunction accumulator) {
ReduceByKeyAction reduceByKeyAction = new ReduceByKeyAction<>(accumulator, store, listener);
publisher.subscribe(reduceByKeyAction);
return reduceByKeyAction;
}
//scan
/**
*
* @param publisher
* @param accumulator
* @param
* @param
* @return
*/
public static Stream> scanByKey(Publisher> publisher,
BiFunction accumulator) {
return scanByKey(publisher, null, null, accumulator);
}
/**
*
* @param publisher
* @param mapStream
* @param accumulator
* @param
* @param
* @return
*/
public static Stream> scanByKey(Publisher> publisher,
MapStream mapStream,
BiFunction accumulator) {
return scanByKey(publisher, mapStream, mapStream, accumulator);
}
/**
*
* @param publisher
* @param store
* @param listener
* @param accumulator
* @param
* @param
* @return
*/
public static Stream> scanByKey(Publisher> publisher,
Map store,
Publisher extends MapStream.Signal> listener,
BiFunction accumulator) {
return scanByKeyOn(publisher, store, listener, accumulator);
}
/**
*
* @param publisher
* @param store
* @param listener
* @param accumulator
* @param
* @param
* @return
*/
public static Stream> scanByKeyOn(Publisher> publisher,
Map store,
Publisher extends MapStream.Signal> listener,
BiFunction accumulator) {
ScanByKeyAction scanByKeyAction = new ScanByKeyAction<>(accumulator, store, listener);
publisher.subscribe(scanByKeyAction);
return scanByKeyAction;
}
}