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
013 /**
014 * Constraint that only accepts an adapter whose implementation is the same
015 * class instance as the type represented by this object.
016 *
017 * @author Nick Sieger
018 */
019 @SuppressWarnings("serial")
020 public final class IsExactType extends AbstractConstraint {
021
022 private final Class type;
023
024 /**
025 * Creates a new <code>IsExactType</code> instance.
026 *
027 * @param c the <code>Class</code> to match
028 */
029 public IsExactType(final Class c) {
030 this.type = c;
031 }
032
033 @Override
034 public boolean evaluate(final ComponentAdapter adapter) {
035 return type == adapter.getComponentImplementation();
036 }
037
038 }