KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > aop > defaults > KeyEqualsComponentPointcut


1 /*****************************************************************************
2  * Copyright (c) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Idea by Rachel Davies, Original code by various *
9  *****************************************************************************/

10 package org.nanocontainer.aop.defaults;
11
12 import org.nanocontainer.aop.ComponentPointcut;
13
14 /**
15  * Component pointcut that matches against a component key.
16  *
17  * @author Stephen Molitor
18  * @version $Revision: 3144 $
19  */

20 public class KeyEqualsComponentPointcut implements ComponentPointcut {
21
22     private final Object JavaDoc componentKey;
23
24     /**
25      * Creates a new <code>KeyEqualsComponentPointcut</code> that matches
26      * against <code>componentKey</code>.
27      *
28      * @param componentKey the component key to match against.
29      */

30     public KeyEqualsComponentPointcut(Object JavaDoc componentKey) {
31         if (componentKey == null) {
32             throw new NullPointerException JavaDoc("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 JavaDoc componentKey) {
46         return this.componentKey.equals(componentKey);
47     }
48
49 }
Popular Tags