Coverage details for edu.uci.ics.jung.graph.predicates.ThresholdPredicate

LineHitsSource
1 /*
2  * Copyright (c) 2004, the JUNG Project and the Regents of the University of
3  * California All rights reserved.
4  *
5  * This software is open-source under the BSD license; see either "license.txt"
6  * or http://jung.sourceforge.net/license.txt for a description.
7  *
8  * Created on Aug 9, 2004
9  */
10 package edu.uci.ics.jung.graph.predicates;
11  
12 import org.apache.commons.collections.Predicate;
13  
14 /**
15  * A predicate which passes Numbers whose value satisfies a threshold requirement.
16  *
17  * @author Joshua O'Madadhain
18  */
19 public class ThresholdPredicate implements Predicate
20 {
21     protected double threshold;
22     protected boolean greater_equal;
23     
24     /**
25      * Creates a ThresholdPredicate with the specified threshold value.
26      * If <code>greater_equal</code> is true, only objects whose double
27      * values are greater than or equal to <code>threshold</code> will evaluate to
28      * <code>true</code>; otherwise, only objects whose values are less
29      * than or equal will evaluate to true.
30      *
31      * @param threshold the threshold value
32      * @param greater_equal
33      */
34     public ThresholdPredicate(double threshold, boolean greater_equal)
350    {
360        this.threshold = threshold;
370        this.greater_equal = greater_equal;
380    }
39  
40     /**
41      * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object)
42      */
43     public boolean evaluate(Object arg0)
44     {
450        double value = ((Number)arg0).doubleValue();
460        if (greater_equal && value >= threshold)
470            return true;
480        if (!greater_equal && value <= threshold)
490            return true;
500        return false;
51     }
52 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.