KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > picocontainer > gems > constraints > IsExactType


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
9 package org.picocontainer.gems.constraints;
10
11 import org.picocontainer.ComponentAdapter;
12
13 /**
14  * Constraint that only accepts an adapter whose implementation is the same
15  * class instance as the type represented by this object.
16  *
17  * @author Nick Sieger
18  * @version 1.1
19  */

20 public class IsExactType extends AbstractConstraint {
21     private Class JavaDoc type;
22
23     /**
24      * Creates a new <code>IsExactType</code> instance.
25      *
26      * @param c the <code>Class</code> to match
27      */

28     public IsExactType(Class JavaDoc c) {
29         this.type = c;
30     }
31
32     public boolean evaluate(ComponentAdapter adapter) {
33         return type == adapter.getComponentImplementation();
34     }
35
36 }
37
Popular Tags