/*
* Hibernate Validator, declare and validate application constraints
*
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
*/
package org.hibernate.validator.internal.constraintvalidators.bv.time.future;
import java.time.temporal.TemporalAccessor;
import javax.validation.constraints.Future;
import org.hibernate.validator.internal.constraintvalidators.bv.time.AbstractJavaTimeValidator;
/**
* Base class for all {@code @Future} validators that are based on the {@code java.time} package.
*
* @author Alaa Nassef
* @author Guillaume Smet
*/
public abstract class AbstractFutureJavaTimeValidator<T extends TemporalAccessor & Comparable<? super T>> extends AbstractJavaTimeValidator<Future, T> {
private boolean isPresentValid;
@Override
public void initialize(Future constraintAnnotation) {
isPresentValid = constraintAnnotation.orPresent();
}
@Override
protected boolean isValid(int result) {
return isPresentValid ? ( result >= 0 ) : ( result > 0 );
}
}