home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / jgl_1_1 / jgl_1_1.exe / src / BindSecondPredicate.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.  * BindSecondPredicate is a unary predicate object that allows you to apply a binary 
  8.  * predicate to an operand and a predefined value. The reason that it's called 
  9.  * BindSecondPredicate is that the predefined value is always used as the 2nd parameter 
  10.  * to the binary predicate.
  11.  * <p>
  12.  * @see jgl.BindSecond
  13.  * @see jgl.BindFirstPredicate
  14.  * @version 1.1
  15.  * @author ObjectSpace, Inc.
  16.  */
  17.  
  18. public final class BindSecondPredicate 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 2nd parameter.
  27.    */
  28.   public BindSecondPredicate( BinaryPredicate predicate, Object value )
  29.     {
  30.     myPredicate = predicate;
  31.     myObject = value;
  32.     }
  33.  
  34.   /**
  35.    * Perform my binary predicate on the operand using the operand as the 1st parameter
  36.    * and the predefined value 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( object, myObject );
  43.     }
  44.   }
  45.