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

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. // Portions Copyright(c) 1995, 1996 Hewlett-Packard Company.
  3.  
  4. package jgl;
  5.  
  6. /**
  7.  * UnaryPredicateFunction allows you to use a unary predicate object as a unary
  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 UnaryPredicateFunction implements UnaryFunction
  16.   {
  17.   UnaryPredicate myPredicate;
  18.  
  19.   /**
  20.    * Construct myself with a unary predicate object.
  21.    * @param predicate The unary predicate object.
  22.    */
  23.   public UnaryPredicateFunction( UnaryPredicate predicate )
  24.     {
  25.     myPredicate = predicate;
  26.     }
  27.  
  28.   /**
  29.    * Perform my unary predicate on the operand and return the boolean result as an object.
  30.    * @param object The operand.
  31.    * @return predicate( object ) converted into an object.
  32.    */
  33.   public Object execute( Object object )
  34.     {
  35.     return myPredicate.execute( object ) ? Boolean.TRUE : Boolean.FALSE;
  36.     }
  37.   }
  38.