KickJava   Java API By Example, From Geeks To Geeks.

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


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 accepts an adapter whose key type is either the
15  * same type or a subtype of the type(s) represented by this object.
16  *
17  * @author Nick Sieger
18  * @author Jörg Schaible
19  * @version 1.1
20  */

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

29     public IsKeyType(Class JavaDoc c) {
30         this.type = c;
31     }
32
33     public boolean evaluate(ComponentAdapter adapter) {
34         return type.isAssignableFrom(adapter.getComponentKey().getClass());
35     }
36
37 }
38
Popular Tags