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 accepts an adapter of a specific key. 015 * 016 * @author Nick Sieger 017 * @version 1.1 018 */ 019 public class IsKey extends AbstractConstraint { 020 021 private Object key; 022 023 /** 024 * Creates a new <code>IsKey</code> instance. 025 * 026 * @param key the key to match 027 */ 028 public IsKey(Object key) { 029 this.key = key; 030 } 031 032 public boolean evaluate(ComponentAdapter adapter) { 033 return key.equals(adapter.getComponentKey()); 034 } 035 036 }