|
|||||||||||||||||||
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 | |||||||||||||||
IsEqual.java | 100% | 100% | 100% | 100% |
|
1 |
/* Copyright (c) 2000-2003, jMock.org. See bundled LICENSE.txt */
|
|
2 |
package org.jmock.constraint;
|
|
3 |
|
|
4 |
import org.jmock.Constraint;
|
|
5 |
import org.jmock.dynamic.DynamicUtil;
|
|
6 |
|
|
7 |
import java.util.Arrays;
|
|
8 |
|
|
9 |
/**
|
|
10 |
* Is the value equal to another value, as tested by the
|
|
11 |
* {@link java.lang.Object#equals} method?
|
|
12 |
*/
|
|
13 |
public class IsEqual implements Constraint { |
|
14 |
private Object _object;
|
|
15 |
|
|
16 | 142 |
public IsEqual(Object equalArg) {
|
17 | 142 |
if (equalArg instanceof Object[]) { |
18 | 2 |
_object = Arrays.asList((Object[]) equalArg); |
19 |
} else {
|
|
20 | 140 |
_object = equalArg; |
21 |
} |
|
22 |
} |
|
23 |
|
|
24 | 104 |
public boolean eval(Object arg) { |
25 | 104 |
if (arg instanceof Object[]) { |
26 | 8 |
arg = Arrays.asList((Object[]) arg); |
27 |
} |
|
28 | 104 |
return arg.equals(_object);
|
29 |
} |
|
30 |
|
|
31 | 6 |
public String toString() {
|
32 | 6 |
return " = " + DynamicUtil.proxyToString(_object); |
33 |
} |
|
34 |
|
|
35 | 10 |
public boolean equals(Object anObject) { |
36 | 10 |
return eval(anObject);
|
37 |
} |
|
38 |
} |
|
39 |
|
|