public class SizeValidatorForCollection extends Object implements ConstraintValidator<Size,Collection>
Constructor and Description |
---|
SizeValidatorForCollection() |
Modifier and Type | Method and Description |
---|---|
void |
initialize(Size parameters)
Initializes the validator in preparation for
ConstraintValidator.isValid(Object, ConstraintValidatorContext) calls. |
boolean |
isValid(Collection collection,
ConstraintValidatorContext constraintValidatorContext)
Checks the number of entries in a collection.
|
public void initialize(Size parameters)
ConstraintValidator
ConstraintValidator.isValid(Object, ConstraintValidatorContext)
calls.
The constraint annotation for a given constraint declaration
is passed.
This method is guaranteed to be called before any use of this instance for validation.
The default implementation is a no-op.
initialize
in interface ConstraintValidator<Size,Collection>
parameters
- annotation instance for a given constraint declarationpublic boolean isValid(Collection collection, ConstraintValidatorContext constraintValidatorContext)
isValid
in interface ConstraintValidator<Size,Collection>
collection
- the collection to validateconstraintValidatorContext
- context in which the constraint is evaluatedtrue
if the collection is null
or the number of entries in
collection
is between the specified min
and max
values (inclusive),
false
otherwise.Copyright © 2021 JBoss by Red Hat. All rights reserved.