Class ImmutableCollectors


  • public class ImmutableCollectors
    extends java.lang.Object
    Set of convenient function regarding a collection immutability. Particularly useful in the conjunction with Stream.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.stream.Collector<T,​java.util.Set<T>,​java.util.Set<T>> toImmutableLinkedSet()
      Creates a Collector of an immutable Set for Stream.collect(Collector).
      static <T> java.util.stream.Collector<T,​java.util.List<T>,​java.util.List<T>> toImmutableList()
      Creates a Collector of an immutable list for Stream.collect(Collector).
      static <T> java.util.stream.Collector<T,​java.util.Set<T>,​java.util.Set<T>> toImmutableSet()
      Creates a Collector of an immutable Set for Stream.collect(Collector).
      • Methods inherited from class java.lang.Object

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

      • ImmutableCollectors

        public ImmutableCollectors()
    • Method Detail

      • toImmutableList

        public static <T> java.util.stream.Collector<T,​java.util.List<T>,​java.util.List<T>> toImmutableList()
        Creates a Collector of an immutable list for Stream.collect(Collector).
        Type Parameters:
        T - type of the immutable list.
        Returns:
        collector for immutable list.
      • toImmutableSet

        public static <T> java.util.stream.Collector<T,​java.util.Set<T>,​java.util.Set<T>> toImmutableSet()
        Creates a Collector of an immutable Set for Stream.collect(Collector).
        Type Parameters:
        T - type of the immutable set.
        Returns:
        collector for immutable set.
      • toImmutableLinkedSet

        public static <T> java.util.stream.Collector<T,​java.util.Set<T>,​java.util.Set<T>> toImmutableLinkedSet()
        Creates a Collector of an immutable Set for Stream.collect(Collector).
        Type Parameters:
        T - type of the immutable linked hash set.
        Returns:
        collector for immutable linked hash set.