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

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. // Portions Copyright(c) 1995, 1996 Hewlett-Packard Company.
  3.  
  4. package jgl;
  5.  
  6. /**
  7.  * BindFirstPredicate is a unary predicate object that allows you to apply a binary 
  8.  * predicate to a predefined value and an operand. The reason that it's called 
  9.  * BindFirstPredicate is that the predefined value is always used as the 1st parameter 
  10.  * to the binary predicate.
  11.  * <p>
  12.  * @see jgl.BindFirst
  13.  * @see jgl.BindSecondPredicate
  14.  * @version 1.1
  15.  * @author ObjectSpace, Inc.
  16.  */
  17.  
  18. public final class BindFirstPredicate implements UnaryPredicate
  19.   {
  20.   BinaryPredicate myPredicate;
  21.   Object myObject;
  22.  
  23.   /**
  24.    * Construct myself with a binary predicate object and a predefined value.
  25.    * @param predicate The binary predicate object.
  26.    * @param value The object to use as the 1st parameter.
  27.    */
  28.   public BindFirstPredicate( BinaryPredicate predicate, Object value )
  29.     {
  30.     myPredicate = predicate;
  31.     myObject = value;
  32.     }
  33.  
  34.   /**
  35.    * Perform my binary predicate on the operand using the predefined value as the 1st
  36.    * parameter and the operand as the 2nd parameter.
  37.    * @param object The operand.
  38.    * @return predicate( value, object )
  39.    */
  40.   public boolean execute( Object object )
  41.     {
  42.     return myPredicate.execute( myObject, object );
  43.     }
  44.   }
  45.