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

com.aol.cyclops.javaslang.FromFunctionalJava Maven / Gradle / Ivy

There is a newer version: 8.4.2
Show newest version
package com.aol.cyclops.javaslang;

import javaslang.Function1;
import javaslang.Function2;
import javaslang.Function3;
import javaslang.Function4;
import javaslang.Function5;
import javaslang.Function6;
import javaslang.Function7;
import javaslang.Function8;
import javaslang.Tuple1;
import javaslang.Tuple2;
import javaslang.Tuple3;
import javaslang.Tuple4;
import javaslang.Tuple5;
import javaslang.Tuple6;
import javaslang.Tuple7;
import javaslang.Tuple8;
import javaslang.control.Either;
import javaslang.control.Left;
import javaslang.control.Option;
import javaslang.control.Right;
import fj.F;
import fj.F2;
import fj.F3;
import fj.F4;
import fj.F5;
import fj.F6;
import fj.F7;
import fj.F8;
import fj.P1;
import fj.P2;
import fj.P3;
import fj.P4;
import fj.P5;
import fj.P6;
import fj.P7;
import fj.P8;


public class FromFunctionalJava {
	public static   Function1 f1(F fn){
		return (t) -> fn.f(t);
	}
	public static   Function2 f2(F2 fn){
		return (t,x) -> fn.f(t,x);
	}
	public static   Function3 f3(F3 fn){
		return (t1,t2,t3) -> fn.f(t1,t2,t3);
	}
	public static   Function4 f4(F4 fn){
		return (t1,t2,t3,t4) -> fn.f(t1,t2,t3,t4);
	}
	public static   Function5 f5(F5 fn){
		return (t1,t2,t3,t4,t5) -> fn.f(t1,t2,t3,t4,t5);
	}
	public static   Function6 f6(F6 fn){
		return (t1,t2,t3,t4,t5,t6) -> fn.f(t1,t2,t3,t4,t5,t6);
	}
	public static   Function7 f7(F7 fn){
		return (t1,t2,t3,t4,t5,t6,t7) -> fn.f(t1,t2,t3,t4,t5,t6,t7);
	}
	public static   Function8 f8(F8 fn){
		return (t1,t2,t3,t4,t5,t6,t7,t8) -> fn.f(t1,t2,t3,t4,t5,t6,t7,t8);
	}
	public static Option option(fj.data.Option o){
		if(o.isNone())
			return Option.none();
		return Option.of(o.some());
	}
	public static Either either(fj.data.Either e){
		if(e.isLeft())
			return new Left(e.left().value()); 
		else
			return new Right(e.right().value());
	}
	
	public static  Tuple1 tuple(P1 t){
		return new Tuple1(t._1());
	}
	public static  Tuple2 tuple(P2 t){
		return new Tuple2(t._1(),t._2());
	}
	public static  Tuple3 tuple(P3 t){
		return new Tuple3(t._1(),t._2(),t._3());
	}
	public static  Tuple4 tuple(P4 t){
		return new Tuple4(t._1(),t._2(),t._3(),t._4());
	}
	public static  Tuple5 tuple(P5 t){
		return new Tuple5(t._1(),t._2(),t._3(),t._4(),t._5());
	}
	public static  Tuple6 tuple(P6 t){
		return new Tuple6(t._1(),t._2(),t._3(),t._4(),t._5(),t._6());
	}
	public static  Tuple7 tuple(P7 t){
		return new Tuple7(t._1(),t._2(),t._3(),t._4(),t._5(),t._6(),t._7());
	}
	public static  Tuple8 tuple(P8 t){
		return new Tuple8(t._1(),t._2(),t._3(),t._4(),t._5(),t._6(),t._7(),t._8());
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy