001 /*****************************************************************************
002 * Copyright (C) PicoContainer Organization. All rights reserved. *
003 * ------------------------------------------------------------------------- *
004 * The software in this package is published under the terms of the BSD *
005 * style license a copy of which has been included with this distribution in *
006 * the LICENSE.txt file. *
007 *****************************************************************************/
008
009 package org.picocontainer.gems.constraints;
010
011 import org.picocontainer.ComponentAdapter;
012 import org.picocontainer.PicoVisitor;
013
014 /**
015 * Inverts the logical sense of the given constraint.
016 *
017 * @author Nick Sieger
018 * @version 1.1
019 */
020 public class Not extends AbstractConstraint {
021 private Constraint constraint;
022
023 /**
024 * Creates a new <code>Not</code> instance.
025 * @param con a <code>Constraint</code> value
026 */
027 public Not(Constraint con) {
028 this.constraint = con;
029 }
030
031 public boolean evaluate(ComponentAdapter comp) {
032 return ! constraint.evaluate(comp);
033 }
034
035 public void accept(PicoVisitor visitor) {
036 super.accept(visitor);
037 constraint.accept(visitor);
038 }
039 }