Class FugueCollectors

java.lang.Object
io.atlassian.fugue.FugueCollectors

public final class FugueCollectors extends Object
Collector instances.
Since:
4.8.0
  • Constructor Details

    • FugueCollectors

      public FugueCollectors()
  • Method Details

    • toEitherLeft

      public static <L, R> Collector<Either<L,R>,?,Either<List<L>,R>> toEitherLeft()
      Collect the left values if there are only lefts, otherwise return the first right encountered. Collectors have `foldLeft` semantics. For Spliterator.ORDERED sequences the left-most Either.Right value is returned.
      Type Parameters:
      L - the LHS type
      R - the RHS type
      Returns:
      left biased collector of Either.
      Since:
      4.8.0
    • toEitherLeft

      public static <L, R, A, B> Collector<Either<L,R>,?,Either<B,R>> toEitherLeft(Collector<L,A,B> lCollector)
      Collect the left values if there are only lefts, otherwise return the first right encountered. Collectors have `foldLeft` semantics. For Spliterator.ORDERED sequences the left-most Either.Right value is returned.
      Type Parameters:
      L - the LHS type
      R - the RHS type
      A - the mutable accumulation type of the reduction operation
      B - the result type of the reduction operation
      Parameters:
      lCollector - result collector
      Returns:
      left biased collector of Either.
      Since:
      4.8.0
    • toEitherRight

      public static <L, R> Collector<Either<L,R>,?,Either<L,List<R>>> toEitherRight()
      Collect the right values if there are only rights, otherwise return the first left encountered. Collectors have `foldLeft` semantics. For Spliterator.ORDERED sequences the left-most Either.Left value is returned.
      Type Parameters:
      L - the LHS type
      R - the RHS type
      Returns:
      right biased collector of Either.
      Since:
      4.8.0
    • toEitherRight

      public static <L, R, A, B> Collector<Either<L,R>,?,Either<L,B>> toEitherRight(Collector<R,A,B> rCollector)
      Collect the right values if there are only rights, otherwise return the first left encountered. Collectors have `foldLeft` semantics. For Spliterator.ORDERED sequences the left-most Either.Left value is returned.
      Type Parameters:
      L - the LHS type
      R - the RHS type
      A - the mutable accumulation type of the reduction operation
      B - the result type of the reduction operation
      Parameters:
      rCollector - result collector
      Returns:
      right biased collector of Either.
      Since:
      4.8.0
    • flatten

      public static <A> Collector<Option<A>,?,List<A>> flatten()
      Collect the values wrapped within the option.
      Type Parameters:
      A - the option type
      Returns:
      flattening collector of Option.
      Since:
      4.8.0
    • flatten

      public static <A, B, C> Collector<Option<A>,?,C> flatten(Collector<A,B,C> aCollector)
      Collect the values wrapped within the option.
      Type Parameters:
      A - the option type
      B - the mutable accumulation type of the reduction operation
      C - the result type of the reduction operation
      Parameters:
      aCollector - result collector
      Returns:
      flattening collector of Option.
      Since:
      4.8.0
    • toTrySuccess

      public static <A> Collector<Try<A>,?,Try<List<A>>> toTrySuccess()
      Collect the right values if there are only successes, otherwise return the first failure encountered. Collectors have `foldLeft` semantics. For Spliterator.ORDERED sequences the left-most io.atlassian.fugue.Try.Failure value is returned.
      Type Parameters:
      A - the success type
      Returns:
      success biased collector of Try.
      Since:
      4.8.0
    • toTrySuccess

      public static <A, B, C> Collector<Try<A>,?,Try<C>> toTrySuccess(Collector<A,B,C> aCollector)
      Collect the right values if there are only successes, otherwise return the first failure encountered. Collectors have `foldLeft` semantics. For Spliterator.ORDERED sequences the left-most io.atlassian.fugue.Try.Failure value is returned.
      Type Parameters:
      A - the success type
      B - the mutable accumulation type of the reduction operation
      C - the result type of the reduction operation
      Returns:
      success biased collector of Try.
      Since:
      4.8.0
    • maybeUnorderedCharacteristics

      private static Collector.Characteristics[] maybeUnorderedCharacteristics(Collector<?,?,?> delegate)