Class FindCommonPathElements
Object
com.owenfeehan.pathpatternfinder.commonpath.FindCommonPathElements
public class FindCommonPathElements extends Object
Finds common (left-most) elements among
Path
s.
Elements are common if they are present (from left to right) among all paths.
The root of the path (e.g. c:\
) is treated as an element, if it is present.
- Author:
- Owen Feehan
-
Method Summary
Modifier and Type Method Description static Optional<PathElements>
findForFilePaths(Iterable<Path> pathsToFiles)
Finds the common (left-most) elements amongPath
s.static Optional<PathElements>
findForFilePaths(Iterable<Path> pathsToFiles, CasedStringComparer comparer)
Finds the common (left-most) elements amongPath
s, with a customizable means via aCasedStringComparer
for comparing strings.static Optional<PathElements>
findForFilePaths(Iterable<Path> pathsToFiles, IOCase ioCase)
Finds the common (left-most) elements amongPath
s, with a customizable means via anIOCase
for comparing strings.
-
Method Details
-
findForFilePaths
Finds the common (left-most) elements amongPath
s.- Parameters:
pathsToFiles
- paths to files- Returns:
- the common path-elements among all of
pathsToFiles
, if any common elements exist. - Throws:
IllegalArgumentException
- ifpathsToFiles
is empty.
-
findForFilePaths
Finds the common (left-most) elements amongPath
s, with a customizable means via anIOCase
for comparing strings.- Parameters:
pathsToFiles
- paths to filesioCase
- whether to be case-sensitive or not in comparisons.- Returns:
- the common path-elements among all of
pathsToFiles
, if any common elements exist. - Throws:
IllegalArgumentException
- ifpathsToFiles
is empty.
-
findForFilePaths
public static Optional<PathElements> findForFilePaths(Iterable<Path> pathsToFiles, CasedStringComparer comparer)Finds the common (left-most) elements amongPath
s, with a customizable means via aCasedStringComparer
for comparing strings.- Parameters:
pathsToFiles
- paths to filescomparer
- how to compare two strings (whether to be case-sensitive or not).- Returns:
- the common path-elements among all of
pathsToFiles
, if any common elements exist. - Throws:
IllegalArgumentException
- ifpathsToFiles
is empty.
-