Enum CollectionUtil

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<CollectionUtil>

    public enum CollectionUtil
    extends java.lang.Enum<CollectionUtil>
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      SINGLETON  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T applyFactoryModifiers​(T pipelineFactory, java.util.List<java.util.function.Function<T,​T>> modifiers)  
      static <T> java.util.stream.Collector<T,​?,​java.util.List<java.util.List<T>>> batchOf​(int size)  
      static <K,​V>
      V
      computeIfAbsent​(java.util.concurrent.ConcurrentMap<K,​V> map, K key, java.util.function.Function<? super K,​? extends V> mappingFunction)
      ComputeIfAbsent on a ConcurrentHashMap should be a very light weight operation if the key already exists.
      static <K,​V>
      V
      computeIfAbsent​(java.util.concurrent.ConcurrentMap<K,​V> map, K key, java.util.function.Function<? super K,​? extends V> mappingFunction, java.util.function.BiConsumer<K,​V> register)
      Accepts a mapping function to compute the value, and only register when the old value is not set.
      static <T> java.lang.Iterable<T> concat​(java.lang.Iterable<? extends T>... sources)  
      static <T> java.util.Iterator<T> concat​(java.util.Iterator<? extends T>... sources)  
      static <V> V[] deepCloneArray​(V[] array)
      Clones an array with arbitrary levels of nesting.
      static <T> java.lang.Object deepToStringObject​(T... array)  
      static boolean isNotEmpty​(java.util.Collection<?> collection)  
      static <T> CollectionUtil.ListBuilder<T> listBuilder()  
      static <T> java.util.List<T> listOf​(java.util.Collection<T> values)  
      static <T> java.util.List<T> listOf​(T value)  
      static <T> java.util.List<T> listOf​(T... values)  
      static <K,​V>
      CollectionUtil.MapBuilder<K,​V>
      mapBuilder()  
      static <K,​V>
      java.util.Map<K,​V>
      mapOf​(K key, V value)  
      static <K,​V>
      java.util.Map<K,​V>
      mapOf​(K key1, V value1, K key2, V value2)  
      static <K,​V>
      java.util.Map<K,​V>
      mapOf​(K key1, V value1, K key2, V value2, K key3, V value3)  
      static <K,​V>
      java.util.Map<K,​V>
      mapOf​(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4)  
      static <K,​V>
      java.util.Map<K,​V>
      mapOfEntries​(ImmutableMapEntry<K,​V>... values)  
      static <T> CollectionUtil.SetBuilder<T> setBuilder()  
      static <T> java.util.Set<T> setOf​(java.util.Collection<T> values)  
      static <T> java.util.Set<T> setOf​(T value)  
      static <T> java.util.Set<T> setOf​(T... values)  
      static <T> java.util.stream.Stream<T> stream​(java.lang.Iterable<? extends T> iterable)  
      static <T> java.util.stream.Stream<T> stream​(java.util.Iterator<? extends T> iterator)  
      static <T> java.util.stream.Stream<T> stream​(java.util.Spliterator<? extends T> spliterator, boolean parallel)  
      static <T> java.util.stream.Stream<T> stream​(T... source)  
      static CollectionUtil valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static CollectionUtil[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • values

        public static CollectionUtil[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (CollectionUtil c : CollectionUtil.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static CollectionUtil valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • isNotEmpty

        public static boolean isNotEmpty​(java.util.Collection<?> collection)
      • setOf

        public static <T> java.util.Set<T> setOf​(T value)
      • setOf

        @SafeVarargs
        public static <T> java.util.Set<T> setOf​(T... values)
      • setOf

        public static <T> java.util.Set<T> setOf​(java.util.Collection<T> values)
      • listOf

        public static <T> java.util.List<T> listOf​(T value)
      • listOf

        @SafeVarargs
        public static <T> java.util.List<T> listOf​(T... values)
      • listOf

        public static <T> java.util.List<T> listOf​(java.util.Collection<T> values)
      • mapOf

        public static <K,​V> java.util.Map<K,​V> mapOf​(K key,
                                                                 V value)
      • mapOfEntries

        @SafeVarargs
        public static <K,​V> java.util.Map<K,​V> mapOfEntries​(ImmutableMapEntry<K,​V>... values)
      • mapOf

        public static <K,​V> java.util.Map<K,​V> mapOf​(K key1,
                                                                 V value1,
                                                                 K key2,
                                                                 V value2)
      • mapOf

        public static <K,​V> java.util.Map<K,​V> mapOf​(K key1,
                                                                 V value1,
                                                                 K key2,
                                                                 V value2,
                                                                 K key3,
                                                                 V value3)
      • mapOf

        public static <K,​V> java.util.Map<K,​V> mapOf​(K key1,
                                                                 V value1,
                                                                 K key2,
                                                                 V value2,
                                                                 K key3,
                                                                 V value3,
                                                                 K key4,
                                                                 V value4)
      • batchOf

        public static <T> java.util.stream.Collector<T,​?,​java.util.List<java.util.List<T>>> batchOf​(int size)
      • stream

        public static <T> java.util.stream.Stream<T> stream​(java.util.Spliterator<? extends T> spliterator,
                                                            boolean parallel)
      • stream

        public static <T> java.util.stream.Stream<T> stream​(java.lang.Iterable<? extends T> iterable)
      • stream

        public static <T> java.util.stream.Stream<T> stream​(java.util.Iterator<? extends T> iterator)
      • stream

        @SafeVarargs
        public static <T> java.util.stream.Stream<T> stream​(T... source)
      • concat

        @SafeVarargs
        public static <T> java.lang.Iterable<T> concat​(java.lang.Iterable<? extends T>... sources)
      • concat

        @SafeVarargs
        public static <T> java.util.Iterator<T> concat​(java.util.Iterator<? extends T>... sources)
      • deepToStringObject

        @SafeVarargs
        public static <T> java.lang.Object deepToStringObject​(T... array)
      • applyFactoryModifiers

        public static <T> T applyFactoryModifiers​(T pipelineFactory,
                                                  java.util.List<java.util.function.Function<T,​T>> modifiers)
      • computeIfAbsent

        public static <K,​V> V computeIfAbsent​(@Nonnull
                                                    java.util.concurrent.ConcurrentMap<K,​V> map,
                                                    @Nonnull
                                                    K key,
                                                    @Nonnull
                                                    java.util.function.Function<? super K,​? extends V> mappingFunction)
        ComputeIfAbsent on a ConcurrentHashMap should be a very light weight operation if the key already exists. Due to a bug in Java 8 (https://bugs.openjdk.java.net/browse/JDK-8161372), a lock is acquired regardless. This Util rewrites the computeIfAbsent as get and putIfAbsent to avoid the lock if the key already exists.
      • computeIfAbsent

        public static <K,​V> V computeIfAbsent​(@Nonnull
                                                    java.util.concurrent.ConcurrentMap<K,​V> map,
                                                    @Nonnull
                                                    K key,
                                                    @Nonnull
                                                    java.util.function.Function<? super K,​? extends V> mappingFunction,
                                                    java.util.function.BiConsumer<K,​V> register)
        Accepts a mapping function to compute the value, and only register when the old value is not set.
      • deepCloneArray

        public static <V> V[] deepCloneArray​(@Nonnull
                                             V[] array)
        Clones an array with arbitrary levels of nesting.