KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > gems > constraints > Not


1 /*****************************************************************************
2  * Copyright (C) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8
9 package org.picocontainer.gems.constraints;
10
11 import org.picocontainer.ComponentAdapter;
12 import org.picocontainer.PicoVisitor;
13
14 /**
15  * Inverts the logical sense of the given constraint.
16  *
17  * @author Nick Sieger
18  * @version 1.1
19  */

20 public class Not extends AbstractConstraint {
21     private Constraint constraint;
22
23     /**
24      * Creates a new <code>Not</code> instance.
25      * @param con a <code>Constraint</code> value
26      */

27     public Not(Constraint con) {
28         this.constraint = con;
29     }
30
31     public boolean evaluate(ComponentAdapter comp) {
32         return ! constraint.evaluate(comp);
33     }
34
35     public void accept(PicoVisitor visitor) {
36         super.accept(visitor);
37         constraint.accept(visitor);
38     }
39 }
40
Popular Tags