|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
IsInstanceOf.java | - | 66.7% | 66.7% | 66.7% |
|
1 |
/* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */
|
|
2 |
package org.jmock.constraint;
|
|
3 |
|
|
4 |
import org.jmock.Constraint;
|
|
5 |
|
|
6 |
/**
|
|
7 |
* Tests whether the value is an instance of a class.
|
|
8 |
*/
|
|
9 |
public class IsInstanceOf implements Constraint { |
|
10 |
private Class _class; |
|
11 |
|
|
12 |
/**
|
|
13 |
* Creates a new instance of IsInstanceOf
|
|
14 |
*
|
|
15 |
* @param theclass The predicate evaluates to true for instances of this class
|
|
16 |
* or one of its subclasses.
|
|
17 |
*/
|
|
18 | 2 |
public IsInstanceOf(Class theclass) {
|
19 | 2 |
_class = theclass;
|
20 |
} |
|
21 |
|
|
22 | 8 |
public boolean eval(Object arg) { |
23 | 8 |
return _class.isInstance(arg); |
24 |
} |
|
25 |
|
|
26 | 0 |
public String toString() {
|
27 | 0 |
return "an instance of <" + _class.getName() + ">"; |
28 |
} |
|
29 |
} |
|
30 |
|
|