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

com.aol.cyclops.reactor.comprehenders.FluxTValueComprehender Maven / Gradle / Ivy

There is a newer version: 9.0.0-MI7
Show newest version
package com.aol.cyclops.reactor.comprehenders;

import java.util.Iterator;
import java.util.function.Function;
import java.util.function.Predicate;

import com.aol.cyclops.reactor.transformer.FluxTValue;
import com.aol.cyclops.types.extensability.Comprehender;
import com.aol.cyclops.types.mixins.Printable;

import reactor.core.publisher.Flux;

public class FluxTValueComprehender implements Comprehender, Printable {

    @Override
    public Object resolveForCrossTypeFlatMap(Comprehender comp, FluxTValue apply) {

        return apply.isStreamPresent() ? comp.of(apply.get()) : comp.empty();
    }

    @Override
    public Object filter(FluxTValue t, Predicate p) {
        return t.filter(p);
    }

    @Override
    public Object map(FluxTValue t, Function fn) {
        return t.map(r -> fn.apply(r));
    }

    @Override
    public Object flatMap(FluxTValue t, Function fn) {
        return t.flatMapT(r -> fn.apply(r));
    }

    @Override
    public FluxTValue of(Object o) {
        return FluxTValue.of(Flux.just(o));
    }

    @Override
    public FluxTValue empty() {
        return FluxTValue.emptyOptional();
    }

    @Override
    public Class getTargetClass() {
        return FluxTValue.class;
    }

    @Override
    public FluxTValue fromIterator(Iterator o) {
        return FluxTValue.of(Flux.fromIterable(() -> o));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy