wyvern.lib.predicates
Class OrPredicate

java.lang.Object
  extended bywyvern.lib.predicates.OrPredicate
All Implemented Interfaces:
Predicate, PrintablePredicate

public class OrPredicate
extends java.lang.Object
implements Predicate, PrintablePredicate

This predicate combines N other predicates with an OR operation. It returns true if any of the sub-predicates returns true.

Version:
1.0, Feb 09, 1998
Author:
Steve Yegge

Constructor Summary
OrPredicate(Predicate p1, Predicate p2)
          Constructs a new OrPredicate
 
Method Summary
 OrPredicate add(Predicate p)
          Adds another predicate to the chain.
 java.util.List getPredicates()
          Returns both (or all) of the predicates being OR-ed together.
 boolean predicate(GameObject obj)
          Returns true if both sub-predicates return true for the object.
 java.lang.String print()
          Prints an English-like description of the predicate, e.g.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OrPredicate

public OrPredicate(Predicate p1,
                   Predicate p2)
Constructs a new OrPredicate

Method Detail

add

public OrPredicate add(Predicate p)
Adds another predicate to the chain.

Parameters:
p - another Predicate to to check
Returns:
this object, for ease of chaining, e.g. myOrPredicate.add(p1).add(p2).add(p3)

getPredicates

public java.util.List getPredicates()
Returns both (or all) of the predicates being OR-ed together.


predicate

public boolean predicate(GameObject obj)
Returns true if both sub-predicates return true for the object.

Specified by:
predicate in interface Predicate
Parameters:
obj - the object to predicate upon
Returns:
true if it passes the test

toString

public java.lang.String toString()

print

public java.lang.String print()
Description copied from interface: PrintablePredicate
Prints an English-like description of the predicate, e.g. "NOT name like 'bob'", or "quantity < 100 AND item is cursed"

Specified by:
print in interface PrintablePredicate