All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.picocontainer.gems.constraints.Not Maven / Gradle / Ivy

The newest version!
/*****************************************************************************
 * Copyright (C) PicoContainer Organization. All rights reserved.            *
 * ------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the BSD      *
 * style license a copy of which has been included with this distribution in *
 * the LICENSE.txt file.                                                     *
 *****************************************************************************/

package org.picocontainer.gems.constraints;

import org.picocontainer.ComponentAdapter;
import org.picocontainer.PicoVisitor;

/**
 * Inverts the logical sense of the given constraint.
 *
 * @author Nick Sieger
 */
@SuppressWarnings("serial")
public final class Not extends AbstractConstraint {

	private final Constraint constraint;

    /**
     * Creates a new Not instance.
     * @param con a Constraint value
     */
    public Not(final Constraint con) {
        this.constraint = con;
    }

    @Override
	public boolean evaluate(final ComponentAdapter comp) {
        return ! constraint.evaluate(comp);
    }

    @Override
	public void accept(final PicoVisitor visitor) {
        super.accept(visitor);
        constraint.accept(visitor);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy