Class Either.LeftProjection

    • Constructor Detail

      • LeftProjection

        private LeftProjection()
    • Method Detail

      • get

        public L get()
        Description copied from interface: Maybe
        Get the value if defined. Throw an exception otherwise.
        Specified by:
        get in interface Maybe<L>
        Returns:
        the wrapped value
      • isDefined

        public boolean isDefined()
        Description copied from interface: Maybe
        If the type contains a value return true.
        Specified by:
        isDefined in interface Maybe<L>
        Returns:
        true if this holds a value, false otherwise.
      • on

        public L on​(java.util.function.Function<? super R,​? extends L> f)
        Description copied from interface: Either.Projection
        The value of this projection or the result of the given function on the opposing projection's value.
        Specified by:
        on in interface Either.Projection<L,​R,​L,​R>
        Parameters:
        f - The function to execute if this projection has no value.
        Returns:
        The value of this projection or the result of the given function on the opposing projection's value.
      • map

        public <X> Either<X,​R> map​(java.util.function.Function<? super L,​X> f)
        Map the given function across this projection's value if it has one.
        Type Parameters:
        X - the LHS type
        Parameters:
        f - The function to map across this projection, must not return null
        Returns:
        A new either value after mapping.
      • flatMap

        public <X,​RR extends REither<X,​R> flatMap​(java.util.function.Function<? super L,​Either<X,​RR>> f)
        Binds the given function across this projection's value if it has one.
        Type Parameters:
        X - the LHS type
        RR - The existing RHS or a subtype
        Parameters:
        f - The function to bind across this projection.
        Returns:
        A new either value after binding.
      • sequence

        public <X> Either<X,​R> sequence​(Either<X,​R> e)
        Anonymous bind through this projection.
        Type Parameters:
        X - the LHS type
        Parameters:
        e - The value to bind with.
        Returns:
        An either after binding through this projection.
      • filter

        public <X> Option<Either<L,​X>> filter​(java.util.function.Predicate<? super L> f)
        Returns None if this projection has no value or if the given predicate p does not hold for the value, otherwise, returns a left in Some.
        Type Parameters:
        X - the RHS type
        Parameters:
        f - The predicate function to test on this projection's value.
        Returns:
        None if this projection has no value or if the given predicate p does not hold for the value, otherwise, returns a left in Some.
      • filterOrElse

        public Either<L,​R> filterOrElse​(java.util.function.Predicate<? super L> p,
                                              java.util.function.Supplier<? extends R> orElseSupplier)
        Return a Left if this is a Left and the contained values satisfies the given predicate. If this is a Left but the predicate is not satisfied, return a Right with the value provided by the orElseSupplier. Return a Right if this a Right with the contained value.
        Parameters:
        p - The predicate function to test on the right contained value.
        orElseSupplier - The supplier to execute when is a left, and predicate is unsatisfied
        Returns:
        a new Either that will be either the existing left/right or a right with result of orElseSupplier
        Since:
        4.7.0
      • ap

        public <X> Either<X,​R> ap​(Either<java.util.function.Function<L,​X>,​R> either)
        Function application on this projection's value.
        Type Parameters:
        X - the LHS type
        Parameters:
        either - The either of the function to apply on this projection's value.
        Returns:
        The result of function application within either.
        Since:
        3.0
      • apply

        @Deprecated
        public <X> Either<X,​R> apply​(Either<java.util.function.Function<L,​X>,​R> either)
        Deprecated.
        since 3.0
        Function application on this projection's value.
        Type Parameters:
        X - the LHS type
        Parameters:
        either - The either of the function to apply on this projection's value.
        Returns:
        The result of function application within either.
        See Also:
        ap
      • as

        <X> Either<L,​X> as()
        Coerces our right type as X. Dangerous, isLeft() must be true
        Type Parameters:
        X - the type to coerce to.
        Returns:
        an either with the coerced right type.