Class Either<L,R>

java.lang.Object
com.comphenix.protocol.wrappers.Either<L,R>
Type Parameters:
L - left data type
R - right data type
Direct Known Subclasses:
Either.Left, Either.Right

public abstract class Either<L,R> extends Object
Represents a datatype where either left or right is present. The values are available with a xor semantic. So at most and at least one value will be available.
  • Constructor Details

    • Either

      public Either()
  • Method Details

    • map

      public abstract <T> T map(Function<L,T> leftConsumer, Function<R,T> rightConsumer)
      Type Parameters:
      T - result data type of both transformers
      Parameters:
      leftConsumer - transformer if the left value is present
      rightConsumer - transformer if the right value is present
      Returns:
      result of applying the given functions to the left or right side
    • left

      public abstract Optional<L> left()
      Returns:
      left value if present
    • right

      public abstract Optional<R> right()
      Returns:
      right value if present
    • left

      public static <L, R> Either<L,R> left(L value)
      Type Parameters:
      L - data type of the containing value
      R - right data type
      Parameters:
      value - containing value
      Returns:
      either containing a left value
    • right

      public static <L, R> Either<L,R> right(R value)
      Type Parameters:
      L - left data type
      R - data type of the containing value
      Parameters:
      value - containing value
      Returns:
      either containing a right value