Class Either.RightProjection

java.lang.Object
Either<L,R>.io.atlassian.fugue.Either.AbstractProjection<R,L>
io.atlassian.fugue.Either.RightProjection
All Implemented Interfaces:
Effect.Applicant<R>, Either.Projection<R,L,L,R>, Maybe<R>, Iterable<R>
Enclosing class:
Either<L,R>

public final class Either.RightProjection extends Either<L,R>.AbstractProjection<R,L> implements Either.Projection<R,L,L,R>
A right projection of an either value.
Since:
1.0
  • Constructor Details

    • RightProjection

      private RightProjection()
  • Method Details

    • get

      public R get()
      Description copied from interface: Maybe
      Get the value if defined. Throw an exception otherwise.
      Specified by:
      get in interface Maybe<R>
      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<R>
      Returns:
      true if this holds a value, false otherwise.
    • on

      public R on(Function<? super L, ? extends R> 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<R,L,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<L,X> map(Function<? super R, X> f)
      Map the given function across this projection's value if it has one.
      Type Parameters:
      X - the RHS type
      Parameters:
      f - The function to map across this projection.
      Returns:
      A new either value after mapping.
    • flatMap

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

      <X> Either.Left<L,X> toLeft()
    • sequence

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

      public <X> Option<Either<X,R>> filter(Predicate<? super R> f)
      Returns None if this projection has no value or if the given predicate p does not hold for the value, otherwise, returns a right in Some.
      Type Parameters:
      X - the LHS 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 right in Some.
    • filterOrElse

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

      public <X> Either<L,X> ap(Either<L, Function<R,X>> either)
      Function application on this projection's value.
      Type Parameters:
      X - the RHS 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<L,X> apply(Either<L, Function<R,X>> either)
      Deprecated.
      since 3.0 see ap
      Function application on this projection's value.
      Type Parameters:
      X - the RHS type
      Parameters:
      either - The either of the function to apply on this projection's value.
      Returns:
      The result of function application within either.
    • as

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