org.jutil.predicate
Class PrimitivePredicate

java.lang.Object
  |
  +--org.jutil.predicate.AbstractPredicate
        |
        +--org.jutil.predicate.PrimitivePredicate
All Implemented Interfaces:
CollectionOperator, Predicate

public abstract class PrimitivePredicate
extends AbstractPredicate

A class of predicates that have no subpredicates.

Since a primitive predicate does not contain any subpredicates, this abstract class implements nbSubPredicates() and getSubPredicates().

Typically, this class will be used as an anonymous inner class as follows:


Predicate myPredicate = new PrimitivePredicate() {
       /oo
        o also public behavior
        o
        o post postcondition;
        o/
       public boolean eval(Object o) throws MyException {
         //calculate boolean value
         //using the given object
       }
   };
 


Field Summary
static java.lang.String CVS_REVISION
           
 
Constructor Summary
PrimitivePredicate()
           
 
Method Summary
 java.util.List getSubPredicates()
          Return the subpredicates of this Predicate.
 int nbSubPredicates()
          See superclass
 
Methods inherited from class org.jutil.predicate.AbstractPredicate
count, equals, exists, filter, forall
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jutil.predicate.Predicate
eval
 
Methods inherited from interface org.jutil.java.collections.CollectionOperator
isValidElement
 

Field Detail

CVS_REVISION

public static final java.lang.String CVS_REVISION
Constructor Detail

PrimitivePredicate

public PrimitivePredicate()
Method Detail

getSubPredicates

public java.util.List getSubPredicates()
Description copied from interface: Predicate
Return the subpredicates of this Predicate.

Specifications:
     also
public behavior
ensures \result .size() == 0;

Specifications inherited from overridden method in interface Predicate:
public behavior
ensures \result != null;
ensures !\result .contains(null);
ensures !\result .contains(this);

nbSubPredicates

public int nbSubPredicates()
See superclass
Specifications inherited from overridden method in class AbstractPredicate:
      --- None ---
Specifications inherited from overridden method in interface Predicate:
public behavior
ensures \result == getSubPredicates().size();