01: /*****************************************************************************
02: * Copyright (C) PicoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: *****************************************************************************/package org.picocontainer.gems.constraints;
08:
09: import org.picocontainer.ComponentAdapter;
10: import org.picocontainer.PicoVisitor;
11:
12: /**
13: * Inverts the logical sense of the given constraint.
14: *
15: * @author Nick Sieger
16: */
17: public final class Not extends AbstractConstraint {
18: private final Constraint constraint;
19:
20: /**
21: * Creates a new <code>Not</code> instance.
22: * @param con a <code>Constraint</code> value
23: */
24: public Not(Constraint con) {
25: this .constraint = con;
26: }
27:
28: public boolean evaluate(ComponentAdapter comp) {
29: return !constraint.evaluate(comp);
30: }
31:
32: public void accept(PicoVisitor visitor) {
33: super.accept(visitor);
34: constraint.accept(visitor);
35: }
36: }
|