home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / jgl_1_1 / src / negateinteger.java < prev    next >
Encoding:
Java Source  |  1996-09-10  |  673 b   |  27 lines

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. // Portions Copyright(c) 1995, 1996 Hewlett-Packard Company.
  3.  
  4. package jgl;
  5.  
  6. /**
  7.  * NegateInteger is a unary function object that assumes that its operand is an instance of
  8.  * Integer and returns its negation.
  9.  * <p>
  10.  * @see jgl.BinaryNot
  11.  * @version 1.1
  12.  * @author ObjectSpace, Inc.
  13.  */
  14.  
  15. public final class NegateInteger implements UnaryFunction
  16.   {
  17.   /**
  18.    * Return the negation of my operand.
  19.    * @param object The operand, which must be an instance of Integer.
  20.    * @return -object
  21.    */
  22.   public Object execute( Object object )
  23.     {
  24.     return new Integer( -((Integer) object).intValue() );
  25.     }
  26.   }
  27.