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 Details

    • RegexPathConstraint

      public RegexPathConstraint(boolean mustMatch, Pattern pattern)
  • Method Details

    • 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 interface PathConstraint
      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 interface FileNameConstraint
      Parameters:
      fileName - the filename to validate
      path - the path the filename is part of. This is supplied for context and is not validated