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

com.aol.cyclops.functionaljava.comprehenders.ReaderComprehender Maven / Gradle / Ivy

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

import java.util.function.Function;

import com.aol.cyclops.types.extensability.Comprehender;
import com.aol.cyclops.types.extensability.ValueComprehender;

import fj.data.Reader;

public class ReaderComprehender implements ValueComprehender {

    @Override
    public Object resolveForCrossTypeFlatMap(Comprehender comp, Reader apply) {
        return comp.of(apply.getFunction());
    }

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

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

    @Override
    public Reader of(Object o) {
        return Reader.constant(o);
    }

    @Override
    public Reader empty() {
        return Reader.constant(null);
    }

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy