Class CollectionTools
All public methods accept null varargs arrays or null collection references
and will return an empty list in those cases. Individual null elements within
collections or varargs are also silently ignored.
combineAndMap(Collection[], Function) and
combineAndMapVarargs(Object[], Function) are intentionally package-private
implementation details and are not part of the public API.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>combine(@Nullable Collection<T>... collections) Combines multiple collections into a single list, ignoring anynullcollections ornullelements.static <T> List<T>combine(@Nullable T... elements) Combines varargs elements into a single list, ignoring anynullelements.combineFilesToPaths(@Nullable File... files) combineFilesToPaths(@Nullable Collection<File>... collections) combineFilesToStrings(@Nullable File... files) Combines varargsFileelements into a single list of normalized absolute path strings, ignoring anynullelements.combineFilesToStrings(@Nullable Collection<File>... collections) Combines multipleFilecollections into a single list of normalized absolute path strings, ignoring anynullcollections ornullelements.combinePathsToFiles(@Nullable Path... paths) combinePathsToFiles(@Nullable Collection<Path>... collections) combinePathsToStrings(@Nullable Path... paths) Combines varargsPathelements into a single list of path strings, ignoring anynullelements.combinePathsToStrings(@Nullable Collection<Path>... collections) Combines multiplePathcollections into a single list of path strings, ignoring anynullcollections ornullelements.combineStringsToFiles(@Nullable String... strings) Combines varargs string elements into a single list ofFileobjects, ignoring anynullelements.combineStringsToFiles(@Nullable Collection<String>... collections) Combines multiple string collections into a single list ofFileobjects, ignoring anynullcollections ornullelements.combineStringsToPaths(@Nullable String... strings) Combines varargs string elements into a single list ofPathobjects, ignoring anynullelements.combineStringsToPaths(@Nullable Collection<String>... collections) Combines multiple string collections into a single list ofPathobjects, ignoring anynullcollections ornullelements.
-
Method Details
-
combine
Combines multiple collections into a single list, ignoring anynullcollections ornullelements.- Type Parameters:
T- the type of elements- Parameters:
collections- the collections to combine; may benull- Returns:
- a new list containing all non-null elements from all non-null collections,
or an empty list if
collectionsisnull - Since:
- 1.0
-
combine
Combines varargs elements into a single list, ignoring anynullelements.- Type Parameters:
T- the type of elements- Parameters:
elements- the elements to combine; may benull, and individual elements may also benull(they are silently dropped)- Returns:
- a new list containing all non-null elements,
or an empty list if
elementsisnull - Since:
- 1.0
-
combineFilesToPaths
@SafeVarargs public static List<Path> combineFilesToPaths(@Nullable @Nullable Collection<File>... collections) Combines multipleFilecollections into a single list ofPathobjects, ignoring anynullcollections ornullelements.- Parameters:
collections- the collections of files to combine; may benull- Returns:
- a new list of
Pathobjects for all non-null files from all non-null collections, or an empty list ifcollectionsisnull - Since:
- 1.0
- See Also:
-
combineFilesToPaths
- Parameters:
files- the files to combine; may benull, and individual elements may also benull(they are silently dropped)- Returns:
- a new list of
Pathobjects for all non-null files, or an empty list iffilesisnull - Since:
- 1.0
- See Also:
-
combineFilesToStrings
@SafeVarargs public static List<String> combineFilesToStrings(@Nullable @Nullable Collection<File>... collections) Combines multipleFilecollections into a single list of normalized absolute path strings, ignoring anynullcollections ornullelements.Uses
Path.toAbsolutePath()followed byPath.normalize()to resolve relative paths and eliminate redundant..and.segments. This is more robust thanFile.getAbsolutePath(), which does not normalize the path.- Parameters:
collections- the collections of files to combine; may benull- Returns:
- a new list of normalized absolute path strings for all non-null files from all
non-null collections, or an empty list if
collectionsisnull - Since:
- 1.0
- See Also:
-
combineFilesToStrings
Combines varargsFileelements into a single list of normalized absolute path strings, ignoring anynullelements.Uses
Path.toAbsolutePath()followed byPath.normalize()to resolve relative paths and eliminate redundant..and.segments. This is more robust thanFile.getAbsolutePath(), which does not normalize the path.- Parameters:
files- the files to combine; may benull, and individual elements may also benull(they are silently dropped)- Returns:
- a new list of normalized absolute path strings for all non-null files,
or an empty list if
filesisnull - Since:
- 1.0
- See Also:
-
combinePathsToFiles
@SafeVarargs public static List<File> combinePathsToFiles(@Nullable @Nullable Collection<Path>... collections) Combines multiplePathcollections into a single list ofFileobjects, ignoring anynullcollections ornullelements.- Parameters:
collections- the collections of paths to combine; may benull- Returns:
- a new list of
Fileobjects for all non-null paths from all non-null collections, or an empty list ifcollectionsisnull - Since:
- 1.0
- See Also:
-
combinePathsToFiles
- Parameters:
paths- the paths to combine; may benull, and individual elements may also benull(they are silently dropped)- Returns:
- a new list of
Fileobjects for all non-null paths, or an empty list ifpathsisnull - Since:
- 1.0
- See Also:
-
combinePathsToStrings
@SafeVarargs public static List<String> combinePathsToStrings(@Nullable @Nullable Collection<Path>... collections) Combines multiplePathcollections into a single list of path strings, ignoring anynullcollections ornullelements.- Parameters:
collections- the collections of paths to combine; may benull- Returns:
- a new list of path strings for all non-null paths from all
non-null collections, or an empty list if
collectionsisnull - Since:
- 1.0
- See Also:
-
combinePathsToStrings
Combines varargsPathelements into a single list of path strings, ignoring anynullelements.- Parameters:
paths- the paths to combine; may benull, and individual elements may also benull(they are silently dropped)- Returns:
- a new list of path strings for all non-null paths,
or an empty list if
pathsisnull - Since:
- 1.0
- See Also:
-
combineStringsToFiles
@SafeVarargs public static List<File> combineStringsToFiles(@Nullable @Nullable Collection<String>... collections) Combines multiple string collections into a single list ofFileobjects, ignoring anynullcollections ornullelements.- Parameters:
collections- the collections of strings to combine; may benull- Returns:
- a new list of
Fileobjects for all non-null strings from all non-null collections, or an empty list ifcollectionsisnull - Since:
- 1.0
- See Also:
-
combineStringsToFiles
Combines varargs string elements into a single list ofFileobjects, ignoring anynullelements.- Parameters:
strings- the strings to combine; may benull, and individual elements may also benull(they are silently dropped)- Returns:
- a new list of
Fileobjects for all non-null strings, or an empty list ifstringsisnull - Since:
- 1.0
- See Also:
-
combineStringsToPaths
@SafeVarargs public static List<Path> combineStringsToPaths(@Nullable @Nullable Collection<String>... collections) Combines multiple string collections into a single list ofPathobjects, ignoring anynullcollections ornullelements.- Parameters:
collections- the collections of strings to combine; may benull- Returns:
- a new list of
Pathobjects for all non-null strings from all non-null collections, or an empty list ifcollectionsisnull - Since:
- 1.0
- See Also:
-
combineStringsToPaths
Combines varargs string elements into a single list ofPathobjects, ignoring anynullelements.- Parameters:
strings- the strings to combine; may benull, and individual elements may also benull(they are silently dropped)- Returns:
- a new list of
Pathobjects for all non-null strings, or an empty list ifstringsisnull - Since:
- 1.0
- See Also:
-