KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > constraint > IsInstanceOf


1 /* Copyright (c) 2002 Nat Pryce. All rights reserved.
2  *
3  * Created on February 10, 2002, 11:35 PM
4  */

5 package com.mockobjects.constraint;
6
7
8 /** Tests whether the value is an instance of a class.
9  */

10 public class IsInstanceOf implements Constraint
11 {
12     private Class JavaDoc _class;
13     
14     /** Creates a new instance of IsInstanceOf
15      *
16      * @param theclass
17      * The predicate evaluates to true for instances of this class
18      * or one of its subclasses.
19      */

20     public IsInstanceOf( Class JavaDoc theclass ) {
21         _class = theclass;
22     }
23     
24     public boolean eval( Object JavaDoc arg ) {
25         return _class.isInstance( arg );
26     }
27     
28     public String JavaDoc toString() {
29         return "an instance of <" + _class.getName() + ">";
30     }
31 }
32
Popular Tags