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

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. // Portions Copyright(c) 1995, 1996 Hewlett-Packard Company.
  3.  
  4. package jgl;
  5.  
  6. /**
  7.  * UnaryCompose is a unary predicate object that returns the result of executing
  8.  * two operations in a specific sequence.
  9.  * <p>
  10.  * @see jgl.UnaryComposePredicate
  11.  * @see jgl.BinaryCompose
  12.  * @version 1.1
  13.  * @author ObjectSpace, Inc.
  14.  */
  15.  
  16. public final class UnaryComposePredicate implements UnaryPredicate
  17.   {
  18.   UnaryPredicate myPredicate;
  19.   UnaryFunction myFunction;
  20.  
  21.   /**
  22.    * Construct myself with a unary predicate object and a unary function object.
  23.    * @param predicate The predicate object.
  24.    * @param function The function object.
  25.    */
  26.   public UnaryComposePredicate( UnaryPredicate predicate, UnaryFunction function )
  27.     {
  28.     myPredicate = predicate;
  29.     myFunction = function;
  30.     }
  31.  
  32.   /**
  33.    * Perform my second unary function on the operand and then return the result of applying 
  34.    * my first unary function object to this result.
  35.    * @param object The operand.
  36.    * @return predicate( function( object ) )
  37.    */
  38.   public boolean execute( Object object )
  39.     {
  40.     return myPredicate.execute( myFunction.execute( object ) );
  41.     }
  42.   }
  43.