org.jutil.predicate
Class And

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

public class And
extends CompositePredicate

A class of predicates that evaluates to the and of a number of other predicates.

For efficiency reasons, the conditional and will be computed.


Field Summary
static java.lang.String CVS_REVISION
           
 
Constructor Summary
And()
          Initialize a new empty And.
And(Predicate first, Predicate second)
          Initialize a new And with the given predicates.
And(Predicate[] predicates)
          Initialize a new And with the given predicates.
 
Method Summary
 boolean eval(java.lang.Object object)
          Evaluate this Predicate for the given object.
 
Methods inherited from class org.jutil.predicate.CompositePredicate
add, clear, getSubPredicates, isValidElement, nbSubPredicates, predicateAt, removeAll, removedPredicateAt
 
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
 

Field Detail

CVS_REVISION

public static final java.lang.String CVS_REVISION
Constructor Detail

And

public And()
Initialize a new empty And.

Specifications:
public behavior
ensures nbSubPredicates() == 0;

And

public And(Predicate first,
           Predicate second)
Initialize a new And with the given predicates.

Parameters:
first - The first predicate.
second - The second predicate.

Specifications:
public behavior
requires first != null;
requires second != null;
ensures predicateAt(1) == first;
ensures predicateAt(2) == second;

And

public And(Predicate[] predicates)
Initialize a new And with the given predicates.

Parameters:
predicates - An array containing the predicates.

Specifications:
public behavior
requires predicates != null;
requires ( \forall int i; i >= 0&&i < predicates.length; predicates[i] != null);
ensures ( \forall int i; i >= 0&&i < predicates.length; getSubPredicates().get(i) == predicates[i]);
ensures nbSubPredicates() == predicates.length;
Method Detail

eval

public boolean eval(java.lang.Object object)
             throws java.lang.Exception
Description copied from interface: Predicate
Evaluate this Predicate for the given object.

Specifications:
     also
public behavior
ensures \result == ( \forall Predicate p; getSubPredicates().contains(p); p.eval(object));

Specifications inherited from overridden method in interface Predicate:
public behavior
ensures \result == true|\result == false;
signals (Exception) !isValidElement(object);