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

org.nustaq.reallive.server.MapSpore Maven / Gradle / Ivy

There is a newer version: 5.2.1
Show newest version
package org.nustaq.reallive.server;

import org.nustaq.kontraktor.Spore;
import org.nustaq.reallive.api.RLFunction;
import org.nustaq.reallive.api.RLPredicate;
import org.nustaq.reallive.api.Record;

/**
 * Created by ruedi on 06.03.17.
 *
 * should be option of filterspore, but cannot because of fixed types ..
 */
public class MapSpore extends Spore {

    private final RLFunction mapFun;
    private final RLPredicate filter; // may modify record (gets patchable private copy

    public MapSpore(RLPredicate filter, RLFunction mapFun ) {
        this.filter = filter;
        this.mapFun = mapFun;
    }

    @Override
    public void remote(Record input) {
        if ( filter != null && ! filter.test(input) ) {
            return;
        }
        stream( mapFun.apply(input) );
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy