Interface PathValidator
- All Superinterfaces:
ObjectComponent<PathValidator, Path>, ValidatorComponent<PathValidator, Path>
Path.-
Method Summary
Modifier and TypeMethodDescriptionEnsures that the path contains another path.Ensures that the path contains another path.containsAll(Collection<Path> expected) Ensures that the path contains all the paths inexpected.containsAll(Collection<Path> expected, String name) Ensures that the path contains all the paths inexpected.containsAny(Collection<Path> expected) Ensures that the path contains at least one path inexpected.containsAny(Collection<Path> expected, String name) Ensures that the path contains at least one path inexpected.containsExactly(Collection<Path> expected) Ensures that the path contains the same paths asexpected.containsExactly(Collection<Path> expected, String name) Ensures that the path consists of the same paths asexpected.doesNotContain(Path unwanted) Ensures that the path does not containunwanted.doesNotContain(Path unwanted, String name) Ensures that the path does not containunwanted.doesNotContainAll(Collection<Path> unwanted) Allows the path to contain some, but not all, paths from another collection.doesNotContainAll(Collection<Path> unwanted, String name) Allows the path to contain some, but not all, paths from another collection.doesNotContainAny(Collection<Path> unwanted) Ensures that the path does not contain any of the paths inunwanted.doesNotContainAny(Collection<Path> unwanted, String name) Ensures that the path does not contain any of the paths inunwanted.doesNotContainExactly(Collection<Path> unwanted) Ensures that the path andunwantedconsist of different paths.doesNotContainExactly(Collection<Path> unwanted, String name) Ensures that the path andunwantedconsist of different paths.exists()Ensures that the path exists.Ensures that the path is absolute.isDirectory(LinkOption... options) Ensures that the path is a directory.isEmpty()Ensures that the path is empty.Ensures that the path exists and the JVM has sufficient privileges to execute it.Ensures that the path is not empty.isRegularFile(LinkOption... options) Ensures that the path is a regular file.Ensures that the path is relative.Methods declared in interface ObjectComponent
getValue, isEqualTo, isEqualTo, isInstanceOf, isInstanceOf, isNotEqualTo, isNotEqualTo, isNotInstanceOf, isNotInstanceOf, isNotNull, isNull, isReferenceEqualTo, isReferenceNotEqualToMethods declared in interface 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 oroptionsare 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 oroptionsare 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)
-
isExecutable
PathValidator isExecutable()Ensures that the path exists and the JVM has sufficient privileges to execute it.This does not imply that the path is an executable file.
- Returns:
- this
- Throws:
IllegalArgumentException- if the path does not exist, or the JVM does not have sufficient privileges to execute it- See Also:
-
isEmpty
PathValidator isEmpty()Ensures that the path is empty.- Returns:
- this
- Throws:
NullPointerException- if the value isnullIllegalArgumentException- if the path is not empty
-
isNotEmpty
PathValidator isNotEmpty()Ensures that the path is not empty.- Returns:
- this
- Throws:
NullPointerException- if the value isnullIllegalArgumentException- if the path is empty
-
contains
Ensures that the path contains another path.- Parameters:
expected- the other path- Returns:
- this
- Throws:
NullPointerException- if the value orexpectedis nullIllegalArgumentException- if the path does not containexpected
-
contains
Ensures that the path contains another path.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
expected- the other pathname- the name of the expected value- Returns:
- this
- Throws:
NullPointerException- if the value orexpectedis nullIllegalArgumentException- if the path does not containexpected
-
doesNotContain
Ensures that the path does not containunwanted.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
unwanted- the unwanted path- Returns:
- this
- Throws:
NullPointerException- if the value orunwantedare nullIllegalArgumentException- if the path containsunwanted
-
doesNotContain
Ensures that the path does not containunwanted.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
unwanted- the unwanted pathname- the name of the path- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the path contains
unwanted
-
containsExactly
Ensures that the path contains the same paths asexpected.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
expected- the desired paths- Returns:
- this
- Throws:
NullPointerException- if the value orexpectedare nullIllegalArgumentException- if:- the path is missing any path in
expected - the path contains any path that is not in
expected
- the path is missing any path in
-
containsExactly
Ensures that the path consists of the same paths asexpected.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
expected- the desired pathsname- the name of the expected paths- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the path contains any path that is not in
expected
-
doesNotContainExactly
Ensures that the path andunwantedconsist of different paths.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
unwanted- the unwanted paths- Returns:
- this
- Throws:
NullPointerException- if the value orunwantedare nullIllegalArgumentException- if the path consists of the same paths asunwanted
-
doesNotContainExactly
Ensures that the path andunwantedconsist of different paths.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
unwanted- the unwanted elementsname- the name of the unwanted collection- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the path consists of the same paths as
unwanted
-
containsAny
Ensures that the path contains at least one path inexpected.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
expected- the desired paths- Returns:
- this
- Throws:
NullPointerException- if the value orexpectedare nullIllegalArgumentException- if the path does not contain any path inexpected
-
containsAny
Ensures that the path contains at least one path inexpected.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
expected- the desired pathsname- the name of the expected paths- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the path does not contain any path in
expected
-
doesNotContainAny
Ensures that the path does not contain any of the paths inunwanted.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
unwanted- the unwanted paths- Returns:
- this
- Throws:
NullPointerException- if the value orunwantedare nullIllegalArgumentException- if the path contains any of the paths inunwanted
-
doesNotContainAny
Ensures that the path does not contain any of the paths inunwanted.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
unwanted- the unwanted pathsname- the name of the unwanted paths- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the path contains any of the paths in
unwanted
-
containsAll
Ensures that the path contains all the paths inexpected.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
expected- the desired paths- Returns:
- this
- Throws:
NullPointerException- if the value orexpectedare nullIllegalArgumentException- if the path does not contain all the paths inexpected
-
containsAll
Ensures that the path contains all the paths inexpected.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
expected- the desired pathsname- the name of the expected paths- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the path does not contain all the paths in
expected
-
doesNotContainAll
Allows the path to contain some, but not all, paths from another collection.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
unwanted- the unwanted paths- Returns:
- this
- Throws:
NullPointerException- if the value orunwantedare nullIllegalArgumentException- if the path contains all the paths inunwanted
-
doesNotContainAll
Allows the path to contain some, but not all, paths from another collection.Note: This method only verifies direct (one-level deep) descendants and does not perform a recursive check.
- Parameters:
unwanted- the unwanted pathsname- the name of the unwanted paths- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the path contains all the paths in
unwanted
-