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:
11: /**
12: * Constraint that accepts an adapter of a specific key.
13: *
14: * @author Nick Sieger
15: */
16: public final class IsKey extends AbstractConstraint {
17:
18: private final Object key;
19:
20: /**
21: * Creates a new <code>IsKey</code> instance.
22: *
23: * @param key the key to match
24: */
25: public IsKey(Object key) {
26: this .key = key;
27: }
28:
29: public boolean evaluate(ComponentAdapter adapter) {
30: return key.equals(adapter.getComponentKey());
31: }
32:
33: }
|