fj.data.Java8 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionaljava-java8 Show documentation
Show all versions of functionaljava-java8 Show documentation
Functional Java is an open source library that supports closures for the Java programming language
package fj.data;
import fj.*;
import fj.function.Try0;
import fj.function.Try1;
import fj.function.Try2;
import java.util.Iterator;
import java.util.Optional;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.StreamSupport;
/**
* Created by mperry on 3/06/2014.
*/
public final class Java8 {
private Java8() {
throw new UnsupportedOperationException();
}
public static P1 Supplier_P1(final Supplier s) {
return Java8.Supplier_P1().f(s);
}
public static F, P1> Supplier_P1() {
return s -> P.lazy(u -> s.get());
}
public static Supplier P1_Supplier(final P1 p) {
return Java8.P1_Supplier().f(p);
}
public static F, Supplier> P1_Supplier() {
return (p) -> () -> p._1();
}
public static F Function_F(final Function f) {
return Java8.Function_F().f(f);
}
public static F, F> Function_F() {
return f -> a -> f.apply(a);
}
public static Function F_Function(final F f) {
return Java8.F_Function().f(f);
}
public static F, Function> F_Function() {
return f -> a -> f.f(a);
}
public static F2 BiFunction_F2(final BiFunction f) {
return Java8.BiFunction_F2().f(f);
}
public static F, F2> BiFunction_F2() {
return f -> (a, b) -> f.apply(a, b);
}
public static BiFunction F2_BiFunction(final F2 f) {
return Java8.F2_BiFunction().f(f);
}
public static F, BiFunction> F2_BiFunction() {
return f -> (a, b) -> f.f(a, b);
}
static public Supplier> TryCatch0_Supplier(final Try0 t) {
return Java8.TryCatch0_Supplier().f(t);
}
static public F, Supplier>> TryCatch0_Supplier() {
return t -> () -> Try.f(t)._1();
}
static public Function> TryCatch1_Function(final Try1 t) {
return Java8.TryCatch1_Function().f(t);
}
static public F, Function>> TryCatch1_Function() {
return t -> a -> Try.f(t).f(a);
}
static public BiFunction> TryCatch2_BiFunction(final Try2 t) {
return Java8.TryCatch2_BiFunction().f(t);
}
static public F, BiFunction>> TryCatch2_BiFunction() {
return t -> (a, b) -> Try.f(t).f(a, b);
}
public static java.util.stream.Stream List_JavaStream(List list) {
return Iterable_JavaStream(list);
}
static public Option Optional_Option(final Optional o) {
return Java8.Optional_Option().f(o);
}
static public F, Option> Optional_Option() {
return o -> o.isPresent() ? Option.fromNull(o.get()) : Option.none();
}
static public Optional Option_Optional(final Option o) {
return Java8.Option_Optional().f(o);
}
static public F