Class Either.Left<L,R>

java.lang.Object
com.github.darksoulq.abyssallib.common.util.Either<L,R>
com.github.darksoulq.abyssallib.common.util.Either.Left<L,R>
Type Parameters:
L - The Left type.
R - The Right type.
Enclosing class:
Either<L,R>

public static final class Either.Left<L,R> extends Either<L,R>
Represents the Left side of the Either.
  • Constructor Details

    • Left

      public Left(L value)
      Parameters:
      value - The non-null value to wrap.
  • Method Details

    • value

      public L value()
      Returns:
      The wrapped value.
    • left

      public Optional<L> left()
      Specified by:
      left in class Either<L,R>
      Returns:
      An Optional containing the Left value if present, otherwise empty.
    • right

      public Optional<R> right()
      Specified by:
      right in class Either<L,R>
      Returns:
      An Optional containing the Right value if present, otherwise empty.
    • leftOrElse

      public L leftOrElse(L def)
      Description copied from class: Either
      Returns the Left value if present, otherwise returns the provided default.
      Specified by:
      leftOrElse in class Either<L,R>
      Parameters:
      def - The default value.
      Returns:
      The Left value or the default.
    • rightOrElse

      public R rightOrElse(R def)
      Description copied from class: Either
      Returns the Right value if present, otherwise returns the provided default.
      Specified by:
      rightOrElse in class Either<L,R>
      Parameters:
      def - The default value.
      Returns:
      The Right value or the default.
    • leftOrThrow

      public L leftOrThrow()
      Description copied from class: Either
      Returns the Left value or throws an exception if this is a Right.
      Specified by:
      leftOrThrow in class Either<L,R>
      Returns:
      The Left value.
    • rightOrThrow

      public R rightOrThrow()
      Description copied from class: Either
      Returns the Right value or throws an exception if this is a Left.
      Specified by:
      rightOrThrow in class Either<L,R>
      Returns:
      The Right value.
    • mapLeft

      public <LL> Either<LL,R> mapLeft(Function<? super L, ? extends LL> f)
      Description copied from class: Either
      Transforms the Left value using the provided function.
      Specified by:
      mapLeft in class Either<L,R>
      Type Parameters:
      LL - The new Left type.
      Parameters:
      f - The transformation function.
      Returns:
      A new Either with the transformed Left or the original Right.
    • mapRight

      public <RR> Either<L,RR> mapRight(Function<? super R, ? extends RR> f)
      Description copied from class: Either
      Transforms the Right value using the provided function.
      Specified by:
      mapRight in class Either<L,R>
      Type Parameters:
      RR - The new Right type.
      Parameters:
      f - The transformation function.
      Returns:
      A new Either with the transformed Right or the original Left.
    • ifLeft

      public void ifLeft(Consumer<? super L> c)
      Description copied from class: Either
      Executes the consumer if this is a Left.
      Specified by:
      ifLeft in class Either<L,R>
      Parameters:
      c - The consumer to execute.
    • ifRight

      public void ifRight(Consumer<? super R> c)
      Description copied from class: Either
      Executes the consumer if this is a Right.
      Specified by:
      ifRight in class Either<L,R>
      Parameters:
      c - The consumer to execute.
    • fold

      public <T> T fold(Function<? super L, ? extends T> lf, Function<? super R, ? extends T> rf)
      Description copied from class: Either
      Reduces the Either to a single value by applying the matching function.
      Specified by:
      fold in class Either<L,R>
      Type Parameters:
      T - The result type.
      Parameters:
      lf - The function to apply to a Left.
      rf - The function to apply to a Right.
      Returns:
      The result of the applied function.
    • toString

      public String toString()
      Overrides:
      toString in class Object