class LongTermIntervalAndLongTermIntervalTypeValidator implements ConstraintValidator<LongTermIntervalAndLongTermIntervalType, Configuration> {

    @Override
    public boolean isValid(final Configuration value, final ConstraintValidatorContext context) {
        if (value == null) {
            return true;
        }
        // If LongTermHistoryInterval or LongTermHistoryIntervalType is not
        // present, the other must be not present as well.
        if (value.getLongTermHistoryInterval() == null && value.getLongTermHistoryIntervalType() == null) {
            return true;
        }
        // And, the value of long term history interval must be among the
        // permitted values, defined by the ranges:
        // - from 1 to 30 for long term history interval type DAYS.
        // - from 1 to 12 for long term history interval type MONTHS.
        final Integer interval = value.getLongTermHistoryInterval();
        final LongTermIntervalType type = value.getLongTermHistoryIntervalType();
        return this.checkRanges(interval, type);
    }

}