All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springmodules.validation.util.condition.range.GreaterThanOrEqualsCondition Maven / Gradle / Ivy

The newest version!
package org.springmodules.validation.util.condition.range;

import java.util.Comparator;

/**
 * An {@link AbstractSingleBoundCondition} implementation that checkCalendar whether the checked value is greater than or
 * equals a specific loweer bound.
 *
 * @author Uri Boness
 */
public class GreaterThanOrEqualsCondition extends AbstractSingleBoundCondition {

    /**
     * Constructs a new GreaterThanOrEqualsCondition with a given lower bound.
     *
     * @param lowerBound The lower bound.
     */
    public GreaterThanOrEqualsCondition(Comparable lowerBound) {
        super(lowerBound);
    }

    /**
     * Constructs a new GreaterThanOrEqualsCondition with given lower bound and the comparator to be used to compare the checked value.
     *
     * @param lowerBound The lower bound.
     * @param comparator The comparator.
     */
    public GreaterThanOrEqualsCondition(Object lowerBound, Comparator comparator) {
        super(lowerBound, comparator);
    }

    /**
     * Checks whether the given value is greater than or equals the lower bound associated with this condition.
     *
     * @param value The value to be checked.
     * @param comparator The comparator used to compare the checked value.
     * @return true if the given value is greater than or equals the lower bound, false otherwise.
     */
    protected boolean checkRange(Object value, Comparator comparator) {
        return comparator.compare(value, bound) >= 0;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy