org.beangle.commons.collection.predicates.NumRangePredicate.java Source code

Java tutorial

Introduction

Here is the source code for org.beangle.commons.collection.predicates.NumRangePredicate.java

Source

/* Copyright c 2005-2012.
 * Licensed under GNU  LESSER General Public License, Version 3.
 * http://www.gnu.org/licenses
 */
package org.beangle.commons.collection.predicates;

import org.apache.commons.collections.Predicate;

/**
 * ?
 * 
 * @author chaostone
 */
public class NumRangePredicate implements Predicate {

    private final int floor, upper;

    public NumRangePredicate(final int floor, final int upper) {
        this.floor = floor;
        this.upper = upper;
    }

    /**
     * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object)
     */
    public boolean evaluate(final Object value) {
        if (null == value) {
            return false;
        } else {
            int valueInt = ((Number) value).intValue();
            return valueInt <= upper && valueInt >= floor;
        }
    }

}