public abstract class AbstractInstantBasedTimeValidator<C extends Annotation,T> extends Object implements HibernateConstraintValidator<C,T>
Instant
to be compared to the time reference.Modifier and Type | Field and Description |
---|---|
protected Clock |
referenceClock |
Constructor and Description |
---|
AbstractInstantBasedTimeValidator() |
Modifier and Type | Method and Description |
---|---|
protected abstract Duration |
getEffectiveTemporalValidationTolerance(Duration absoluteTemporalValidationTolerance)
Returns the temporal validation tolerance to apply.
|
protected abstract Instant |
getInstant(T value)
Returns the
Instant measured from Epoch. |
void |
initialize(ConstraintDescriptor<C> constraintDescriptor,
HibernateConstraintValidatorInitializationContext initializationContext)
Initializes the validator in preparation for
ConstraintValidator.isValid(Object, ConstraintValidatorContext) calls. |
protected abstract boolean |
isValid(int result)
Returns whether the result of the comparison between the validated value and the time reference is considered
valid.
|
boolean |
isValid(T value,
ConstraintValidatorContext context)
Implements the validation logic.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initialize
protected Clock referenceClock
public void initialize(ConstraintDescriptor<C> constraintDescriptor, HibernateConstraintValidatorInitializationContext initializationContext)
HibernateConstraintValidator
ConstraintValidator.isValid(Object, ConstraintValidatorContext)
calls.
It is an alternative to ConstraintValidator.initialize(Annotation)
method. Should be used if any additional information
except annotation is needed to initialize a validator.
Note, when using HibernateConstraintValidator
user should only override one of the methods, either
HibernateConstraintValidator.initialize(ConstraintDescriptor, HibernateConstraintValidatorInitializationContext)
or ConstraintValidator.initialize(Annotation)
.
Both methods will be called during initialization, starting with
HibernateConstraintValidator.initialize(ConstraintDescriptor, HibernateConstraintValidatorInitializationContext)
.initialize
in interface HibernateConstraintValidator<C extends Annotation,T>
constraintDescriptor
- a constraint descriptor for a given constraint declarationinitializationContext
- an initialization context for a current ConstraintValidatorFactory
public boolean isValid(T value, ConstraintValidatorContext context)
ConstraintValidator
value
must not be altered.
This method can be accessed concurrently, thread-safety must be ensured by the implementation.
isValid
in interface ConstraintValidator<C extends Annotation,T>
value
- object to validatecontext
- context in which the constraint is evaluatedfalse
if value
does not pass the constraintprotected abstract Duration getEffectiveTemporalValidationTolerance(Duration absoluteTemporalValidationTolerance)
protected abstract boolean isValid(int result)
Copyright © 2019 JBoss by Red Hat. All rights reserved.