Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: edu/ucsb/ccs/jaqual/standard/Not.java


1   package edu.ucsb.ccs.jaqual.standard;
2   
3   import edu.ucsb.ccs.jaqual.Assertion;
4   
5   /**
6    * Assertion that negates another assertion.
7    *
8    * <p>Example use:
9    * <pre>
10   *   ForAll.in(elements).ensure(new Not(new Equal(0)));
11   * </pre>
12   *
13   * @author Parker Abercrombie
14   * @version $Id: Not.java,v 1.1 2002/07/11 20:01:55 parkera Exp $
15   */
16  
17  public class Not implements Assertion {
18  
19    /**
20     * The assertion to negate.
21     */
22    protected Assertion assertion;
23  
24    /**
25     * Create a new assertion.
26     *
27     * @param a an assertion to negate.
28     */ 
29    public Not (Assertion a) {
30      assertion = a;
31    }
32  
33    /**
34     * Test an object by applying the inner assertion, and negating the
35     * result.
36     *
37     * @param o the object to test.
38     *
39     * @return the opposite of the result of the inner assertion.
40     */
41    public boolean eval (Object o) {
42      return !assertion.eval(o);
43    }
44  }