Interface PathValidator
- All Superinterfaces:
ObjectComponent<PathValidator,
,Path> ValidatorComponent<PathValidator,
Path>
public interface PathValidator
extends ValidatorComponent<PathValidator,Path>, ObjectComponent<PathValidator,Path>
Validates the state of a
Path
.-
Method Summary
Modifier and TypeMethodDescriptionEnsures that the path contains another path.Ensures that the path contains another path.exists()
Ensures that the path exists.Ensures that the path is absolute.isDirectory
(LinkOption... options) Ensures that the path is a directory.isRegularFile
(LinkOption... options) Ensures that the path is a regular file.Ensures that the path is relative.Methods declared in interface com.github.cowwoc.requirements10.java.validator.component.ObjectComponent
getValue, isEqualTo, isEqualTo, isInstanceOf, isInstanceOf, isNotEqualTo, isNotEqualTo, isNotInstanceOf, isNotInstanceOf, isNotNull, isNull, isReferenceEqualTo, isReferenceNotEqualTo
Methods declared in interface com.github.cowwoc.requirements10.java.validator.component.ValidatorComponent
and, elseGetFailures, elseThrow, getContext, getContextAsString, getName, getValueOrDefault, validationFailed, withContext
-
Method Details
-
exists
PathValidator exists()Ensures that the path exists.The state of the path may change immediately upon returning from this method. Consequently, special care should be taken when using this method in security-sensitive applications.
- Returns:
- this
- Throws:
NullPointerException
- if the value is nullIllegalArgumentException
- if the path does not exist
-
isAbsolute
PathValidator isAbsolute()Ensures that the path is absolute.- Returns:
- this
- Throws:
NullPointerException
- if the value is nullIllegalArgumentException
- if the path is relative
-
isRelative
PathValidator isRelative()Ensures that the path is relative.- Returns:
- this
- Throws:
NullPointerException
- if the value is nullIllegalArgumentException
- if value refers to an absolute path
-
isDirectory
Ensures that the path is a directory.- Parameters:
options
- options indicating how symbolic links are handled- Returns:
- this
- Throws:
NullPointerException
- if the value oroptions
are nullIllegalArgumentException
- if the path does not exist or is not a directoryIOException
- if an I/O error occurs while reading the file attributes (e.g., the file does not exist or the user lacks the required permissions)
-
isRegularFile
Ensures that the path is a regular file.- Parameters:
options
- options indicating how symbolic links are handled- Returns:
- this
- Throws:
NullPointerException
- if the value oroptions
are nullIllegalArgumentException
- if the path does not exist or is not a fileIOException
- if an I/O error occurs while reading the file attributes (e.g., the file does not exist or the user lacks the required permissions)
-
contains
Ensures that the path contains another path.- Parameters:
expected
- the other path- Returns:
- this
- Throws:
NullPointerException
- if the value orexpected
is nullIllegalArgumentException
- if the path does not containexpected
-
contains
Ensures that the path contains another path.- Parameters:
expected
- the other pathname
- the name of the expected value- Returns:
- this
- Throws:
NullPointerException
- if the value orexpected
is nullIllegalArgumentException
- if the path does not containexpected
-