package fpeas.either;
import fpeas.function.Function;
public class EitherUtility
{
public static Either left(final A left)
{
return new Either()
{
public R visit(final Function super A, ? extends R> ifA, final Function super B, ? extends R> ifB)
{
return ifA.run(left);
}
};
}
public static Either right(final B right)
{
return new Either()
{
public R visit(final Function super A,? extends R> ifA,final Function super B,? extends R> ifB)
{
return ifB.run(right);
}
};
}
public static Function> left()
{
return new Function>()
{
public Either run(final A a)
{
return left(a);
}
};
}
public static Function> right()
{
return new Function>()
{
public Either run(final B b)
{
return right(b);
}
};
}
}