net.sf.jga.fn.logical
Class LogicalOr

java.lang.Object
  extended by net.sf.jga.fn.Functor<R>
      extended by net.sf.jga.fn.BinaryFunctor<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
          extended by net.sf.jga.fn.logical.LogicalOr
All Implemented Interfaces:
java.io.Serializable, Visitable

public class LogicalOr
extends BinaryFunctor<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>

Binary Predicate that returns true when either of Boolean arguments x and y are true.

Note that this functor does not short circuit the evaluation of the second argument. The reason for this is that, by itself, this functor accepts only boolean arguments. When it is used in conjunction with the adaptor functors to implement compound functors, the adaptor cannot know that the functor it is adapting may not need to use both arguments, so the adaptor will fully evaluate both arguments before passing them to the And functor. This would give the illusion that the short circuit logic is broken, when it is in fact unimplementable using the standard functor mechanism.

Copyright © 2002-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface LogicalOr.Visitor
          Interface for classes that may interpret a LogicalOr predicate.
 
Constructor Summary
LogicalOr()
           
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(LogicalOr) method, if it implements the nested Visitor interface.
 java.lang.Boolean fn(java.lang.Boolean x, java.lang.Boolean y)
          Given Boolean arguments x and y, returns true when either x and y are true, otherwise false.
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.BinaryFunctor
bind, bind0th, bind1st, bind2nd, bindNth, compose, compose, composeNth, distribute, eval, generate, generate1st, generate2nd, generateNth
 
Methods inherited from class net.sf.jga.fn.Functor
composeNth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LogicalOr

public LogicalOr()
Method Detail

fn

public java.lang.Boolean fn(java.lang.Boolean x,
                            java.lang.Boolean y)
Given Boolean arguments x and y, returns true when either x and y are true, otherwise false.

Specified by:
fn in class BinaryFunctor<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
x | y

accept

public void accept(Visitor v)
Calls the Visitor's visit(LogicalOr) method, if it implements the nested Visitor interface.

Specified by:
accept in interface Visitable
Overrides:
accept in class Functor<java.lang.Boolean>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2006 David A. Hall. All Rights Reserved.