Class CollectionTools
All public methods accept null varargs arrays or null collection references
and return an empty unmodifiable list in those cases. Individual null elements within
collections or varargs are silently ignored. Empty collections are also skipped.
The internal methods combineAndMap and combineAndMapVarargs are implementation
details and not part of the public API.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>combine(@Nullable Collection<T> @Nullable ... collections) Combines multiple collections into a single list, ignoring anynullcollections, empty collections, ornullelements.static <T> List<T>Combines varargs elements into a single list, ignoring anynullelements.combineFilesToPaths(@Nullable File @Nullable ... files) combineFilesToPaths(@Nullable Collection<File> @Nullable ... collections) combineFilesToStrings(@Nullable File @Nullable ... files) Combines varargsFileelements into a list of normalized absolute path strings.combineFilesToStrings(@Nullable Collection<File> @Nullable ... collections) Combines multipleFilecollections into a list of normalized absolute path strings.combinePathsToFiles(@Nullable Path @Nullable ... paths) combinePathsToFiles(@Nullable Collection<Path> @Nullable ... collections) combinePathsToStrings(@Nullable Path @Nullable ... paths) Combines varargsPathelements into a list of normalized absolute path strings.combinePathsToStrings(@Nullable Collection<Path> @Nullable ... collections) Combines multiplePathcollections into a list of normalized absolute path strings.combineStringsToFiles(@Nullable String @Nullable ... strings) Combines varargs string elements into a list ofFileobjects.combineStringsToFiles(@Nullable Collection<String> @Nullable ... collections) Combines multiple string collections into a list ofFileobjects.combineStringsToPaths(@Nullable String @Nullable ... strings) Combines varargs string elements into a list ofPathobjects.combineStringsToPaths(@Nullable Collection<String> @Nullable ... collections) Combines multiple string collections into a list ofPathobjects.
-
Method Details
-
combine
Combines multiple collections into a single list, ignoring anynullcollections, empty collections, ornullelements.Returns an unmodifiable list. Returns an empty list if the input array is
null.- Type Parameters:
T- the element type- Parameters:
collections- the collections to combine, may benull- Returns:
- an unmodifiable list containing all non-null elements
- Since:
- 1.0
-
combine
Combines varargs elements into a single list, ignoring anynullelements.Returns an unmodifiable list. Returns an empty list if the input array is
null.- Type Parameters:
T- the element type- Parameters:
elements- the elements to combine, may benull- Returns:
- an unmodifiable list containing all non-null elements
- Since:
- 1.0
-
combineFilesToPaths
@SafeVarargs public static List<Path> combineFilesToPaths(@Nullable Collection<File> @Nullable ... collections) Combines multipleFilecollections into a list ofPathobjects.Null collections, empty collections, and null elements are ignored. Returns an unmodifiable list.
- Parameters:
collections- the file collections to combine- Returns:
- an unmodifiable list of paths
- Since:
- 1.0
-
combineFilesToPaths
Combines varargsFileelements into a list ofPathobjects.Null elements are ignored. Returns an unmodifiable list.
- Parameters:
files- the files to combine- Returns:
- an unmodifiable list of paths
- Since:
- 1.0
-
combineFilesToStrings
@SafeVarargs public static List<String> combineFilesToStrings(@Nullable Collection<File> @Nullable ... collections) Combines multipleFilecollections into a list of normalized absolute path strings.Uses
Path.toAbsolutePath()andPath.normalize(). Returns an unmodifiable list.- Parameters:
collections- the file collections to combine- Returns:
- an unmodifiable list of normalized path strings
- Since:
- 1.0
-
combineFilesToStrings
Combines varargsFileelements into a list of normalized absolute path strings.Uses
Path.toAbsolutePath()andPath.normalize(). Returns an unmodifiable list.- Parameters:
files- the files to combine- Returns:
- an unmodifiable list of normalized path strings
- Since:
- 1.0
-
combinePathsToFiles
@SafeVarargs public static List<File> combinePathsToFiles(@Nullable Collection<Path> @Nullable ... collections) Combines multiplePathcollections into a list ofFileobjects.Null collections, empty collections, and null elements are ignored. Returns an unmodifiable list.
- Parameters:
collections- the path collections to combine- Returns:
- an unmodifiable list of files
- Since:
- 1.0
-
combinePathsToFiles
Combines varargsPathelements into a list ofFileobjects.Null elements are ignored. Returns an unmodifiable list.
- Parameters:
paths- the paths to combine- Returns:
- an unmodifiable list of files
- Since:
- 1.0
-
combinePathsToStrings
@SafeVarargs public static List<String> combinePathsToStrings(@Nullable Collection<Path> @Nullable ... collections) Combines multiplePathcollections into a list of normalized absolute path strings.Uses
Path.toAbsolutePath()andPath.normalize(). Returns an unmodifiable list.- Parameters:
collections- the path collections to combine- Returns:
- an unmodifiable list of normalized path strings
- Since:
- 1.0
-
combinePathsToStrings
Combines varargsPathelements into a list of normalized absolute path strings.Uses
Path.toAbsolutePath()andPath.normalize(). Returns an unmodifiable list.- Parameters:
paths- the paths to combine- Returns:
- an unmodifiable list of normalized path strings
- Since:
- 1.0
-
combineStringsToFiles
@SafeVarargs public static List<File> combineStringsToFiles(@Nullable Collection<String> @Nullable ... collections) Combines multiple string collections into a list ofFileobjects.Null collections, empty collections, and null elements are ignored. Returns an unmodifiable list.
- Parameters:
collections- the string collections to combine- Returns:
- an unmodifiable list of files
- Since:
- 1.0
-
combineStringsToFiles
Combines varargs string elements into a list ofFileobjects.Null elements are ignored. Returns an unmodifiable list.
- Parameters:
strings- the strings to combine- Returns:
- an unmodifiable list of files
- Since:
- 1.0
-
combineStringsToPaths
@SafeVarargs public static List<Path> combineStringsToPaths(@Nullable Collection<String> @Nullable ... collections) Combines multiple string collections into a list ofPathobjects.Null collections, empty collections, and null elements are ignored. Returns an unmodifiable list.
- Parameters:
collections- the string collections to combine- Returns:
- an unmodifiable list of paths
- Since:
- 1.0
-
combineStringsToPaths
Combines varargs string elements into a list ofPathobjects.Null elements are ignored. Returns an unmodifiable list.
- Parameters:
strings- the strings to combine- Returns:
- an unmodifiable list of paths
- Since:
- 1.0
-