Class AbstractMaxValidator<T>
java.lang.Object
org.hibernate.validator.internal.constraintvalidators.bv.number.bound.AbstractMaxValidator<T>
- All Implemented Interfaces:
ConstraintValidator<Max,T>
- Direct Known Subclasses:
MaxValidatorForBigDecimal,MaxValidatorForBigInteger,MaxValidatorForByte,MaxValidatorForCharSequence,MaxValidatorForDouble,MaxValidatorForFloat,MaxValidatorForInteger,MaxValidatorForLong,MaxValidatorForNumber,MaxValidatorForShort
Check that the number being validated is less than or equal to the maximum
value specified.
- Author:
- Alaa Nassef, Hardy Ferentschik, Xavier Sosnovsky, Marko Bekhta
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract intvoidinitialize(Max maxValue) Initializes the validator in preparation forConstraintValidator.isValid(Object, ConstraintValidatorContext)calls.booleanisValid(T value, ConstraintValidatorContext constraintValidatorContext) Implements the validation logic.
-
Field Details
-
maxValue
protected long maxValue
-
-
Constructor Details
-
AbstractMaxValidator
public AbstractMaxValidator()
-
-
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<Max,T> - Parameters:
maxValue- 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<Max,T> - Parameters:
value- object to validateconstraintValidatorContext- context in which the constraint is evaluated- Returns:
falseifvaluedoes not pass the constraint
-
compare
-