boolean isThereMinExclusive = (_minExclusive != null);
boolean isThereMaxInclusive = (_maxInclusive != null);
boolean isThereMaxExclusive = (_maxExclusive != null);
if (isThereMinExclusive && isThereMinInclusive) {
throw new ValidationException("Both minInclusive and minExclusive are defined");
}
if (isThereMaxExclusive && isThereMaxInclusive) {
throw new ValidationException("Both maxInclusive and maxExclusive are defined");
}
if (_fixed != null) {
int comparison = dateTime.compareTo(_fixed);
if (comparison == DateTimeBase.INDETERMINATE) {
String err = dateTime.getClass().getName() + " " + dateTime
+ " comparison to the fixed value " + _fixed
+ " is indeterminate";
throw new ValidationException(err);
} else if (comparison != DateTimeBase.EQUALS) {
String err = dateTime.getClass().getName() + " " + dateTime
+ " is not equal to the fixed value: " + _fixed;
throw new ValidationException(err);
}
}
if (isThereMinInclusive && dateTime.compareTo(_minInclusive) != DateTimeBase.GREATER_THAN
&& !dateTime.equals(_minInclusive)) {
String err = dateTime.getClass().getName() + " " + dateTime
+ " is less than the minimum allowed value: " + _minInclusive;
throw new ValidationException(err);
}
if (isThereMinExclusive && dateTime.compareTo(_minExclusive) != DateTimeBase.GREATER_THAN) {
String err = dateTime.getClass().getName() + " " + dateTime
+ " is less than or equal to the minimum (exclusive) value: " + _minExclusive;
throw new ValidationException(err);
}
if (isThereMaxInclusive && dateTime.compareTo(_maxInclusive) != DateTimeBase.LESS_THAN
&& !dateTime.equals(_maxInclusive)) {
String err = dateTime.getClass().getName() + " " + dateTime
+ " is greater than the maximum allowed value: " + _maxInclusive;
throw new ValidationException(err);
}
if (isThereMaxExclusive && dateTime.compareTo(_maxExclusive) != DateTimeBase.LESS_THAN) {
String err = dateTime.getClass().getName() + " " + dateTime
+ " is greater than or equal to the maximum (exclusive) value: "
+ _maxExclusive;
throw new ValidationException(err);
}
if (hasPattern()) {
super.validate(dateTime.toString(), context);
}