public final class FileExistsConstraint extends CheckConstraint<File>
CheckConstraint
implementation that checks
existence of a file or directory.FileExists
,
ConstraintFactory.fileExists()
,
ConstraintFactory.directoryExists()
Modifier and Type | Field and Description |
---|---|
static FileExistsConstraint |
DIRECTORY
FileExistsConstraint single instance that checks existence
of a directory. |
static FileExistsConstraint |
FILE
FileExistsConstraint single instance that checks existence
of a file. |
Modifier and Type | Method and Description |
---|---|
protected <T> boolean |
check(File file,
ValidationContext<T> context)
Checks existence of the specified file or directory.
|
String |
getMessageTemplate(ValidationContext<?> context)
Returns localized error message template.
|
Class<?> |
getType()
Returns
java.io.File type. |
boolean |
isDirectory()
Determines whether file or directory existence should be checked.
|
validate
appendMessageArguments
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
appendMessageArguments
public static final FileExistsConstraint FILE
FileExistsConstraint
single instance that checks existence
of a file.public static final FileExistsConstraint DIRECTORY
FileExistsConstraint
single instance that checks existence
of a directory.public Class<?> getType()
java.io.File
type.java.io.File
type.public boolean isDirectory()
true
if directory existence should be checked;
false
otherwise.public String getMessageTemplate(ValidationContext<?> context)
getMessageTemplate
in interface Constraint<File>
getMessageTemplate
in interface Validation<File>
getMessageTemplate
in class AbstractValidation<File>
context
- Validation context.protected <T> boolean check(File file, ValidationContext<T> context)
Note that if this constraint is configured to check files then checking of existing directory will fail and vise versa.
check
in class CheckConstraint<File>
T
- The type of validated entity.file
- File or directory which existence to be checked.context
- Validation context.true
if the specified file or directory exists;
false
otherwise.Copyright © 2011–2020 FoxLabs. All rights reserved.