Package io.ocfl.core.path.constraint
Class RegexPathConstraint
- java.lang.Object
-
- io.ocfl.core.path.constraint.RegexPathConstraint
-
- All Implemented Interfaces:
FileNameConstraint
,PathConstraint
public class RegexPathConstraint extends Object implements PathConstraint, FileNameConstraint
Validates that a path or filename does or does not match a regex
-
-
Constructor Summary
Constructors Constructor Description RegexPathConstraint(boolean mustMatch, Pattern pattern)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(String path)
Validates that a path meets a defined constraintvoid
apply(String fileName, String path)
Validates that a filename meets a defined constraintstatic RegexPathConstraint
mustContain(Pattern pattern)
Creates a new constraint that validates paths do match the regexstatic RegexPathConstraint
mustNotContain(Pattern pattern)
Creates a new constraint that validates paths do not match the regex
-
-
-
Constructor Detail
-
RegexPathConstraint
public RegexPathConstraint(boolean mustMatch, Pattern pattern)
-
-
Method Detail
-
mustNotContain
public static RegexPathConstraint mustNotContain(Pattern pattern)
Creates a new constraint that validates paths do not match the regex- Parameters:
pattern
- the regex that paths must not match- Returns:
- constraint
-
mustContain
public static RegexPathConstraint mustContain(Pattern pattern)
Creates a new constraint that validates paths do match the regex- Parameters:
pattern
- the regex that paths must match- Returns:
- constraint
-
apply
public void apply(String path)
Description copied from interface:PathConstraint
Validates that a path meets a defined constraint- Specified by:
apply
in interfacePathConstraint
- Parameters:
path
- the path to validate
-
apply
public void apply(String fileName, String path)
Validates that a filename meets a defined constraint- Specified by:
apply
in interfaceFileNameConstraint
- Parameters:
fileName
- the filename to validatepath
- the path the filename is part of. This is supplied for context and is not validated
-
-