Class Either<Failure,​T>

  • Type Parameters:
    Failure - The type of the failure
    T - The type of the success

    public class Either<Failure,​T>
    extends Object
    A class that represents an Either type.
    • Field Detail

      • failure

        public final Failure failure
        The failure.
      • success

        public final T success
        The success.
    • Constructor Detail

      • Either

        private Either​(Failure failure,
                       T success)
        Creates a new Either.
        Parameters:
        failure - The failure
        success - The 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 failure
        T - 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 failure
        T - 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