Class TrimCommonPathRoot
Object
com.owenfeehan.pathpatternfinder.trim.TrimCommonPathRoot
- All Implemented Interfaces:
TrimOperation<Path>
public class TrimCommonPathRoot extends Object implements TrimOperation<Path>
Considers each element of a file-path (between directory separators) as an ordered list and finds
a the maximally constant sublist from the left size.
Only directories are considered. The file-name (the final element in a path) is ignored.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors Constructor Description TrimCommonPathRoot(UnresolvedPatternElementFactory factory, boolean avoidExtensionSplit)
Create for a specific factory. -
Method Summary
-
Constructor Details
-
TrimCommonPathRoot
Create for a specific factory.- Parameters:
factory
- the factory.avoidExtensionSplit
- if true, splits will be avoided in file extensions in the paths (defined as anything after the right-most period)
-
-
Method Details
-
trim
Description copied from interface:TrimOperation
Attempts to trim the list of objects by finding aPattern
.- Specified by:
trim
in interfaceTrimOperation<Path>
- Parameters:
source
- list of objects- Returns:
- if successful, a pattern with the trimmed elements (and what remains to be resolved) as elements, otherwise
Optional.empty()
if unsuccessful
-