Package it.unipd.dei.eis.core.common
Class Either<Failure,T>
- java.lang.Object
-
- it.unipd.dei.eis.core.common.Either<Failure,T>
-
- Type Parameters:
Failure- The type of the failureT- The type of the success
public class Either<Failure,T> extends Object
A class that represents an Either type.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <Failure,T>
Either<Failure,T>failure(Failure failure)Creates a new Either (Failure).booleanisFailure()Check if an Either is a Failure.booleanisSuccess()Check if an Either is a Success.static <Failure,T>
Either<Failure,T>success(T success)Creates a new Either (Success).
-
-
-
Method Detail
-
failure
public static <Failure,T> Either<Failure,T> failure(Failure failure)
Creates a new Either (Failure).- Type Parameters:
Failure- The type of the failureT- The type of the success- Parameters:
failure- The failure- Returns:
- The new Either
-
success
public static <Failure,T> Either<Failure,T> success(T success)
Creates a new Either (Success).- Type Parameters:
Failure- The type of the failureT- The type of the success- Parameters:
success- The success- Returns:
- The new Either
-
isFailure
public boolean isFailure()
Check if an Either is a Failure.- Returns:
- true if the Either is a Failure, false otherwise
-
isSuccess
public boolean isSuccess()
Check if an Either is a Success.- Returns:
- true if the Either is a Success, false otherwise
-
-