Class CbCollections

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> List<T> copyToUnmodifiableList​(Collection<T> c)
      Returns a new unmodifiable list with the same contents as the given collection.
      static <T> Set<T> copyToUnmodifiableSet​(Collection<T> c)
      Returns a new unmodifiable set with the same contents as the given collection.
      static boolean isNullOrEmpty​(String s)  
      static boolean isNullOrEmpty​(Collection<?> c)  
      static boolean isNullOrEmpty​(Map<?,​?> m)  
      static <T> List<T> listOf​(T... items)
      Returns an unmodifiable list containing the given items.
      static <K,​V>
      Map<K,​V>
      mapOf()
      Returns an unmodifiable empty map.
      static <K,​V>
      Map<K,​V>
      mapOf​(K key1, V value1)
      Returns an unmodifiable map containing the given key/value pairs.
      static <K,​V>
      Map<K,​V>
      mapOf​(K key1, V value1, K key2, V value2)
      Returns an unmodifiable map containing the given key/value pairs.
      static <K,​V>
      Map<K,​V>
      mapOf​(K key1, V value1, K key2, V value2, K key3, V value3)
      Returns an unmodifiable map containing the given key/value pairs.
      static <K,​V>
      Map<K,​V>
      mapOf​(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4)
      Returns an unmodifiable map containing the given key/value pairs.
      static <K,​V>
      Map<K,​V>
      mapOf​(K key1, V value1, K key2, V value2, K key3, V value3, K key4, V value4, K key5, V value5)
      Returns an unmodifiable map containing the given key/value pairs.
      static <T> Set<T> setOf​(T... items)
      Returns an unmodifiable set containing the given items.
      static <K,​V1,​V2>
      Map<K,​V2>
      transformValues​(Map<K,​V1> map, Function<V1,​V2> transformer)  
    • Method Detail

      • copyToUnmodifiableList

        public static <T> List<T> copyToUnmodifiableList​(Collection<T> c)
        Returns a new unmodifiable list with the same contents as the given collection.
        Parameters:
        c - may be null, in which case an empty list is returned.
      • copyToUnmodifiableSet

        public static <T> Set<T> copyToUnmodifiableSet​(Collection<T> c)
        Returns a new unmodifiable set with the same contents as the given collection.
        Parameters:
        c - may be null, in which case an empty set is returned.
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(Collection<?> c)
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(Map<?,​?> m)
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(String s)
      • listOf

        @SafeVarargs
        public static <T> List<T> listOf​(T... items)
        Returns an unmodifiable list containing the given items.
        Throws:
        NullPointerException - if any item is null
      • mapOf

        public static <K,​V> Map<K,​V> mapOf()
        Returns an unmodifiable empty map.
      • mapOf

        public static <K,​V> Map<K,​V> mapOf​(K key1,
                                                       V value1)
        Returns an unmodifiable map containing the given key/value pairs.
        Throws:
        NullPointerException - if any key or value is null
        InvalidArgumentException - if there are duplicate keys
      • mapOf

        public static <K,​V> Map<K,​V> mapOf​(K key1,
                                                       V value1,
                                                       K key2,
                                                       V value2)
        Returns an unmodifiable map containing the given key/value pairs.
        Throws:
        NullPointerException - if any key or value is null
        InvalidArgumentException - if there are duplicate keys
      • mapOf

        public static <K,​V> Map<K,​V> mapOf​(K key1,
                                                       V value1,
                                                       K key2,
                                                       V value2,
                                                       K key3,
                                                       V value3)
        Returns an unmodifiable map containing the given key/value pairs.
        Throws:
        NullPointerException - if any key or value is null
        InvalidArgumentException - if there are duplicate keys
      • mapOf

        public static <K,​V> Map<K,​V> mapOf​(K key1,
                                                       V value1,
                                                       K key2,
                                                       V value2,
                                                       K key3,
                                                       V value3,
                                                       K key4,
                                                       V value4)
        Returns an unmodifiable map containing the given key/value pairs.
        Throws:
        NullPointerException - if any key or value is null
        InvalidArgumentException - if there are duplicate keys
      • mapOf

        public static <K,​V> Map<K,​V> mapOf​(K key1,
                                                       V value1,
                                                       K key2,
                                                       V value2,
                                                       K key3,
                                                       V value3,
                                                       K key4,
                                                       V value4,
                                                       K key5,
                                                       V value5)
        Returns an unmodifiable map containing the given key/value pairs.
        Throws:
        NullPointerException - if any key or value is null
        InvalidArgumentException - if there are duplicate keys
      • transformValues

        public static <K,​V1,​V2> Map<K,​V2> transformValues​(Map<K,​V1> map,
                                                                            Function<V1,​V2> transformer)