home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / jgl_1_1 / jgl_1_1.exe / src / BinaryPredicateFunction.java < prev    next >
Encoding:
Java Source  |  1996-09-10  |  1.2 KB  |  39 lines

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. // Portions Copyright(c) 1995, 1996 Hewlett-Packard Company.
  3.  
  4. package jgl;
  5.  
  6. /**
  7.  * BinaryPredicateFunction allows you to use a binary predicate object as a binary
  8.  * function object. Because a function object has to return an object, a true return value 
  9.  * is converted into Boolean.TRUE, and a false return value is converted into Boolean.FALSE.
  10.  * <p>
  11.  * @version 1.1
  12.  * @author ObjectSpace, Inc.
  13.  */
  14.  
  15. public final class BinaryPredicateFunction implements BinaryFunction
  16.   {
  17.   BinaryPredicate myPredicate;
  18.  
  19.   /**
  20.    * Construct myself with a binary predicate object.
  21.    * @param predicate The binary predicate object.
  22.    */
  23.   public BinaryPredicateFunction( BinaryPredicate predicate )
  24.     {
  25.     myPredicate = predicate;
  26.     }
  27.  
  28.   /**
  29.    * Perform my binary predicate on the operand and return the boolean result as an object.
  30.    * @param first The first operand.
  31.    * @param second The second operand.
  32.    * @return predicate( first, second ) converted into an object.
  33.    */
  34.   public Object execute( Object first, Object second )
  35.     {
  36.     return myPredicate.execute( first, second ) ? Boolean.TRUE : Boolean.FALSE;
  37.     }
  38.   }
  39.