Class MoreCollectors


  • public final class MoreCollectors
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.stream.Collector<T,​?,​com.google.common.collect.ImmutableList<T>> toImmutableList()
      Returns a Collector that builds an ImmutableList.
      static <T> java.util.stream.Collector<T,​?,​com.google.common.collect.ImmutableSet<T>> toImmutableSet()
      Returns a Collector that builds an ImmutableSet.
      • Methods inherited from class java.lang.Object

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

      • toImmutableList

        public static <T> java.util.stream.Collector<T,​?,​com.google.common.collect.ImmutableList<T>> toImmutableList()
        Returns a Collector that builds an ImmutableList.

        This Collector behaves similar to Collectors.collectingAndThen(Collectors.toList(), ImmutableList::copyOf) but without building the intermediate list.

        Type Parameters:
        T - the type of the input elements
        Returns:
        a Collector that builds an ImmutableList.
      • toImmutableSet

        public static <T> java.util.stream.Collector<T,​?,​com.google.common.collect.ImmutableSet<T>> toImmutableSet()
        Returns a Collector that builds an ImmutableSet.

        This Collector behaves similar to Collectors.collectingAndThen(Collectors.toList(), ImmutableSet::copyOf) but without building the intermediate list.

        Type Parameters:
        T - the type of the input elements
        Returns:
        a Collector that builds an ImmutableSet.