Class LazyCollections


  • public final class LazyCollections
    extends Object
    Utility methods for lazily instantiated collections. These are useful for situations when we start off with an empty collection (where Collections.empty() can be reused), but need to add more things.
    • Method Detail

      • lazyAdd

        public static <T> List<T> lazyAdd​(List<T> list,
                                          T obj)
        Add an element to a list, potentially transforming the list.
        Parameters:
        list - Current list
        obj - Object that needs to be added
        Returns:
        new list