com.aol.cyclops.functionaljava.FromCyclopsReact Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cyclops-functionaljava Show documentation
Show all versions of cyclops-functionaljava Show documentation
Converters and Comprehenders for FunctionalJava
package com.aol.cyclops.functionaljava;
import com.aol.cyclops.control.Xor;
import com.aol.cyclops.types.MonadicValue;
import fj.data.Either;
import fj.data.Option;
import fj.data.Validation;
public class FromCyclopsReact {
public static fj.data.Stream stream(java.util.stream.Stream s) {
return fj.data.Stream.iteratorStream(s.iterator());
}
public static Option option(MonadicValue value) {
return Option.fromNull(value.orElse(null));
}
public static Either either(Xor value) {
Xor xor = (Xor) value.toXor();
return xor.visit(l -> Either.left(l), r -> Either.right(r));
}
public static Validation validation(Xor value) {
return Validation.validation(either(value));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy