Class PathConstraintProcessor
- java.lang.Object
-
- edu.wisc.library.ocfl.core.path.constraint.PathConstraintProcessor
-
public class PathConstraintProcessor extends Object
A PathConstraintProcessor is used to apply a preconfigured set of constraints to a given path. If the path fails to meet a constraint, aPathConstraintExceptionis thrown.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPathConstraintProcessor.BuilderUse this to construct a new PathConstraintProcessor
-
Constructor Summary
Constructors Constructor Description PathConstraintProcessor(List<PathConstraint> pathConstraints, List<FileNameConstraint> fileNameConstraints, List<PathCharConstraint> charConstraints)Constructs a new PathConstraintProcessor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PathConstraintProcessorappendCharConstraint(PathCharConstraint charConstraint)Adds a new character constraint to the end of the list of character constraintsPathConstraintProcessorappendFileNameConstraint(FileNameConstraint fileNameConstraint)Adds a new filename constraint to the end of the list of filename constraintsPathConstraintProcessorappendPathConstraint(PathConstraint pathConstraint)Adds a new path constraint to the end of the list of path constraintsStringapply(String path)Applies all of the configured constraints on the path.static PathConstraintProcessor.Builderbuilder()Use this to construct a new PathConstraintProcessorPathConstraintProcessorprependCharConstraint(PathCharConstraint charConstraint)Adds a new character constraint to the beginning of the list of character constraintsPathConstraintProcessorprependFileNameConstraint(FileNameConstraint fileNameConstraint)Adds a new filename constraint to the beginning of the list of filename constraintsPathConstraintProcessorprependPathConstraint(PathConstraint pathConstraint)Adds a new path constraint to the beginning of the list of path constraints
-
-
-
Constructor Detail
-
PathConstraintProcessor
public PathConstraintProcessor(List<PathConstraint> pathConstraints, List<FileNameConstraint> fileNameConstraints, List<PathCharConstraint> charConstraints)
Constructs a new PathConstraintProcessor. The builderPathConstraintProcessor.Buildermay also be used.- Parameters:
pathConstraints- list of path constraintsfileNameConstraints- list of filename constraintscharConstraints- list of character constraints
-
-
Method Detail
-
builder
public static PathConstraintProcessor.Builder builder()
Use this to construct a new PathConstraintProcessor- Returns:
- builder
-
apply
public String apply(String path)
Applies all of the configured constraints on the path. If one of them fails, then aPathConstraintExceptionis thrown.- Parameters:
path- the path to apply constraints to- Returns:
- the input path
- Throws:
PathConstraintException- when a constraint fails
-
prependPathConstraint
public PathConstraintProcessor prependPathConstraint(PathConstraint pathConstraint)
Adds a new path constraint to the beginning of the list of path constraints- Parameters:
pathConstraint- constraint to add- Returns:
- this
-
prependFileNameConstraint
public PathConstraintProcessor prependFileNameConstraint(FileNameConstraint fileNameConstraint)
Adds a new filename constraint to the beginning of the list of filename constraints- Parameters:
fileNameConstraint- constraint to add- Returns:
- this
-
prependCharConstraint
public PathConstraintProcessor prependCharConstraint(PathCharConstraint charConstraint)
Adds a new character constraint to the beginning of the list of character constraints- Parameters:
charConstraint- constraint to add- Returns:
- this
-
appendPathConstraint
public PathConstraintProcessor appendPathConstraint(PathConstraint pathConstraint)
Adds a new path constraint to the end of the list of path constraints- Parameters:
pathConstraint- constraint to add- Returns:
- this
-
appendFileNameConstraint
public PathConstraintProcessor appendFileNameConstraint(FileNameConstraint fileNameConstraint)
Adds a new filename constraint to the end of the list of filename constraints- Parameters:
fileNameConstraint- constraint to add- Returns:
- this
-
appendCharConstraint
public PathConstraintProcessor appendCharConstraint(PathCharConstraint charConstraint)
Adds a new character constraint to the end of the list of character constraints- Parameters:
charConstraint- constraint to add- Returns:
- this
-
-