Class TrimConstantString
Object
com.owenfeehan.pathpatternfinder.trim.TrimConstantString
- All Implemented Interfaces:
TrimOperation<String>
public class TrimConstantString extends Object implements TrimOperation<String>
Looks for a constant common substring (from left-size, as maximal as possible).
This is turned into a Constant pattern-element, and otherwise removing
e.g. input: ["the boy went to school", "the boy went to a party"] pattern: ["the boy went to "]
- Author:
- Owen Feehan
-
Constructor Summary
Constructors Constructor Description TrimConstantString(UnresolvedPatternElementFactory factory, boolean requiresPeriod)
Creates given a factory for creating unresolved pattern-elements. -
Method Summary
-
Constructor Details
-
TrimConstantString
Creates given a factory for creating unresolved pattern-elements.- Parameters:
factory
- the factoryrequiresPeriod
- if true, a constant string will only be trimmed from the right if it includes at least one period (useful to prevent file-extensions) from being broken up.
-
-
Method Details
-
trim
Description copied from interface:TrimOperation
Attempts to trim the list of objects by finding aPattern
.- Specified by:
trim
in interfaceTrimOperation<String>
- 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
-