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

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

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

import java.util.Optional;

import javaslang.collection.List;
import javaslang.collection.Stream;
import javaslang.control.Either;
import javaslang.control.Either.LeftProjection;
import javaslang.control.Either.RightProjection;
import javaslang.control.Option;
import javaslang.control.Right;
import javaslang.control.Try;
import javaslang.test.Arbitrary;

import com.aol.cyclops.lambda.api.AsAnyM;
import com.aol.cyclops.monad.AnyM;

public class Javaslang {

	public static  AnyM anyM(Arbitrary arbM){
		return AsAnyM.notTypeSafeAnyM(arbM);
	}
	public static  AnyM anyM(Try tryM){
		return AsAnyM.notTypeSafeAnyM(tryM);
	}
	public static  AnyM anyMFailure(Try tryM){
		if(tryM.isFailure())
			return AsAnyM.notTypeSafeAnyM(Try.of(()->tryM.toEither().left().get()));
		return AsAnyM.notTypeSafeAnyM(Optional.empty());
	}
	public static  AnyM anyM(Either tryM){
		return AsAnyM.notTypeSafeAnyM(tryM);
	}
	public static  AnyM anyM(RightProjection tryM){
		if(tryM.toJavaOptional().isPresent())
			return AsAnyM.notTypeSafeAnyM(new Right(tryM.get()));
		else
			return AsAnyM.notTypeSafeAnyM(Optional.empty());
	}
	public static  AnyM anyM(LeftProjection tryM){
		if(tryM.toJavaOptional().isPresent())
			return AsAnyM.notTypeSafeAnyM(new Right(tryM.get()));
		else
			return AsAnyM.notTypeSafeAnyM(Optional.empty());
	}
	public static  AnyM anyM(Option tryM){
		return AsAnyM.notTypeSafeAnyM(tryM);
	}
	public static  AnyM anyM(Stream tryM){
		return AsAnyM.notTypeSafeAnyM(tryM);
	}
	public static  AnyM anyM(List tryM){
		return AsAnyM.notTypeSafeAnyM(tryM);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy