public final class FileSizeConstraint extends CheckConstraint<File>
CheckConstraint
implementation that checks
whether size of a file is within allowed minimum and maximum bounds.FileSize
,
ConstraintFactory.fileSize(long, long)
Modifier and Type | Method and Description |
---|---|
boolean |
appendMessageArguments(ValidationContext<?> context,
Map<String,Object> arguments)
Appends
minSize and maxSize arguments that
contain minimum and maximum allowed file size respectively. |
protected <T> boolean |
check(File value,
ValidationContext<T> context)
Checks whether size of the specified file is within allowed minimum and
maximum bounds.
|
long |
getMaxSize()
Returns maximum allowed file size.
|
String |
getMessageTemplate(ValidationContext<?> context)
Returns localized error message template.
|
long |
getMinSize()
Returns minimum allowed file size.
|
Class<?> |
getType()
Returns
java.io.File type. |
validate
public Class<?> getType()
java.io.File
type.java.io.File
type.public long getMinSize()
public long getMaxSize()
public String getMessageTemplate(ValidationContext<?> context)
getMessageTemplate
in interface Constraint<File>
getMessageTemplate
in interface Validation<File>
getMessageTemplate
in class AbstractValidation<File>
context
- Validation context.public boolean appendMessageArguments(ValidationContext<?> context, Map<String,Object> arguments)
minSize
and maxSize
arguments that
contain minimum and maximum allowed file size respectively.appendMessageArguments
in interface Constraint<File>
appendMessageArguments
in interface Validation<File>
appendMessageArguments
in class AbstractValidation<File>
context
- Validation context.arguments
- Arguments to be substituted into the error message
template.true
.protected <T> boolean check(File value, ValidationContext<T> context)
check
in class CheckConstraint<File>
T
- The type of validated entity.value
- File which size to be checked.context
- Validation context.true
if size of the specified file is within
allowed minimum and maximum bounds; false
otherwise.Copyright © 2011–2020 FoxLabs. All rights reserved.