1
2
3
4
5
6 package mockit;
7
8
9
10
11 public final class ClassWithObjectOverrides implements Cloneable {
12
13
14 private final StringBuilder text;
15
16
17
18
19
20
21
22 public ClassWithObjectOverrides(String text) {
23 this.text = new StringBuilder(text);
24 }
25
26 @Override
27 public boolean equals(Object o) {
28 return o instanceof ClassWithObjectOverrides && text.equals(((ClassWithObjectOverrides) o).text);
29 }
30
31 @Override
32 public int hashCode() {
33 return text.hashCode();
34 }
35
36 @Override
37 public String toString() {
38 return text.toString();
39 }
40
41 @SuppressWarnings("FinalizeDeclaration")
42 @Override
43 protected void finalize() throws Throwable {
44 super.finalize();
45 text.setLength(0);
46 }
47
48 @Override
49 public ClassWithObjectOverrides clone() {
50 ClassWithObjectOverrides theClone = null;
51 try {
52 theClone = (ClassWithObjectOverrides) super.clone();
53 } catch (CloneNotSupportedException ignore) {
54 }
55 return theClone;
56 }
57
58
59
60
61
62
63 int getIntValue() {
64 return -1;
65 }
66
67
68
69
70 void doSomething() {
71 throw new RuntimeException();
72 }
73
74
75
76
77
78
79
80
81
82 int doSomething(Object arg) {
83 return arg.hashCode();
84 }
85 }