Class DurationMaxValidator
java.lang.Object
org.hibernate.validator.internal.constraintvalidators.hv.time.DurationMaxValidator
- All Implemented Interfaces:
ConstraintValidator<DurationMax,Duration>
public class DurationMaxValidator
extends Object
implements ConstraintValidator<DurationMax,Duration>
Checks that a validated
Duration length is shorter than or equal to the
one specified with the annotation.- Author:
- Marko Bekhta
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidinitialize(DurationMax constraintAnnotation) Initializes the validator in preparation forConstraintValidator.isValid(Object, ConstraintValidatorContext)calls.booleanisValid(Duration value, ConstraintValidatorContext context) Implements the validation logic.
-
Constructor Details
-
DurationMaxValidator
public DurationMaxValidator()
-
-
Method Details
-
initialize
Description copied from interface:ConstraintValidatorInitializes the validator in preparation forConstraintValidator.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.
- Specified by:
initializein interfaceConstraintValidator<DurationMax,Duration> - Parameters:
constraintAnnotation- annotation instance for a given constraint declaration
-
isValid
Description copied from interface:ConstraintValidatorImplements the validation logic. The state ofvaluemust not be altered.This method can be accessed concurrently, thread-safety must be ensured by the implementation.
- Specified by:
isValidin interfaceConstraintValidator<DurationMax,Duration> - Parameters:
value- object to validatecontext- context in which the constraint is evaluated- Returns:
falseifvaluedoes not pass the constraint
-