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