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: * *
08: * Idea by Rachel Davies, Original code by various *
09: *****************************************************************************/package org.nanocontainer.aop.defaults;
10:
11: import org.nanocontainer.aop.ComponentPointcut;
12:
13: /**
14: * Component pointcut that matches against a component key.
15: *
16: * @author Stephen Molitor
17: * @version $Revision: 3144 $
18: */
19: public class KeyEqualsComponentPointcut implements ComponentPointcut {
20:
21: private final Object componentKey;
22:
23: /**
24: * Creates a new <code>KeyEqualsComponentPointcut</code> that matches
25: * against <code>componentKey</code>.
26: *
27: * @param componentKey the component key to match against.
28: */
29: public KeyEqualsComponentPointcut(Object componentKey) {
30: if (componentKey == null) {
31: throw new NullPointerException(
32: "componentKey cannot be null");
33: }
34: this .componentKey = componentKey;
35: }
36:
37: /**
38: * Tests to see if the <code>componentKey</code> matches the component key
39: * passed to the constructor.
40: *
41: * @param componentKey the candidate component key to match against.
42: * @return true if <code>componentKey</code> is equivalent to the
43: * component key passed to the constructor, else false.
44: */
45: public boolean picks(Object componentKey) {
46: return this.componentKey.equals(componentKey);
47: }
48:
49: }
|