Package com.globalmentor.collections
Class CollectionBuilder
java.lang.Object
com.globalmentor.collections.CollectionBuilder
Utility methods for building collections using a fluent interface.
- Author:
- Garret Wilson
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E,
C extends Collection<E>>
CaddAll
(C collection, E... elements) Adds all of the specified elements to the specified collection and returns the given collection.static <E,
C extends Collection<E>>
CAppends the contents of an iterable to a collection.static <E,
C extends Collection<E>>
CAdds all of the elements specified by the given iterator to the specified collection and returns the given collection.
-
Constructor Details
-
CollectionBuilder
public CollectionBuilder()
-
-
Method Details
-
addAll
Appends the contents of an iterable to a collection. This method functions identical toList.addAll(Collection)
, except that this method returns the given collection.- Type Parameters:
E
- The type of element contained in the collection.C
- The type of collection.- Parameters:
collection
- The collection to which objects will be added.iterable
- The source of the added objects.- Returns:
- The given collection.
-
addAll
Adds all of the elements specified by the given iterator to the specified collection and returns the given collection.- Type Parameters:
E
- The type of element contained in the collection.C
- The type of collection.- Parameters:
collection
- The collection to which objects will be added.iterator
- The source of the added objects.- Returns:
- The given collection.
-
addAll
Adds all of the specified elements to the specified collection and returns the given collection.- Type Parameters:
E
- The type of element contained in the collection.C
- The type of collection.- Parameters:
collection
- The collection to which objects will be added.elements
- The source of the added objects.- Returns:
- The given collection.
-