Class FugueCollectors


  • public final class FugueCollectors
    extends java.lang.Object
    Collector instances.
    Since:
    4.8.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  FugueCollectors.Ref<A>
      Mutable reference.
    • Constructor Summary

      Constructors 
      Constructor Description
      FugueCollectors()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <A> java.util.stream.Collector<Option<A>,​?,​java.util.List<A>> flatten()
      Collect the values wrapped within the option.
      static <A,​B,​C>
      java.util.stream.Collector<Option<A>,​?,​C>
      flatten​(java.util.stream.Collector<A,​B,​C> aCollector)
      Collect the values wrapped within the option.
      private static java.util.stream.Collector.Characteristics[] maybeUnorderedCharacteristics​(java.util.stream.Collector<?,​?,​?> delegate)  
      static <L,​R>
      java.util.stream.Collector<Either<L,​R>,​?,​Either<java.util.List<L>,​R>>
      toEitherLeft()
      Collect the left values if there are only lefts, otherwise return the first right encountered.
      static <L,​R,​A,​B>
      java.util.stream.Collector<Either<L,​R>,​?,​Either<B,​R>>
      toEitherLeft​(java.util.stream.Collector<L,​A,​B> lCollector)
      Collect the left values if there are only lefts, otherwise return the first right encountered.
      static <L,​R>
      java.util.stream.Collector<Either<L,​R>,​?,​Either<L,​java.util.List<R>>>
      toEitherRight()
      Collect the right values if there are only rights, otherwise return the first left encountered.
      static <L,​R,​A,​B>
      java.util.stream.Collector<Either<L,​R>,​?,​Either<L,​B>>
      toEitherRight​(java.util.stream.Collector<R,​A,​B> rCollector)
      Collect the right values if there are only rights, otherwise return the first left encountered.
      static <A> java.util.stream.Collector<Try<A>,​?,​Try<java.util.List<A>>> toTrySuccess()
      Collect the right values if there are only successes, otherwise return the first failure encountered.
      static <A,​B,​C>
      java.util.stream.Collector<Try<A>,​?,​Try<C>>
      toTrySuccess​(java.util.stream.Collector<A,​B,​C> aCollector)
      Collect the right values if there are only successes, otherwise return the first failure encountered.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FugueCollectors

        public FugueCollectors()
    • Method Detail

      • toEitherLeft

        public static <L,​R> java.util.stream.Collector<Either<L,​R>,​?,​Either<java.util.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> java.util.stream.Collector<Either<L,​R>,​?,​Either<B,​R>> toEitherLeft​(java.util.stream.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> java.util.stream.Collector<Either<L,​R>,​?,​Either<L,​java.util.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> java.util.stream.Collector<Either<L,​R>,​?,​Either<L,​B>> toEitherRight​(java.util.stream.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> java.util.stream.Collector<Option<A>,​?,​java.util.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> java.util.stream.Collector<Option<A>,​?,​C> flatten​(java.util.stream.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> java.util.stream.Collector<Try<A>,​?,​Try<java.util.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> java.util.stream.Collector<Try<A>,​?,​Try<C>> toTrySuccess​(java.util.stream.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 java.util.stream.Collector.Characteristics[] maybeUnorderedCharacteristics​(java.util.stream.Collector<?,​?,​?> delegate)