View Javadoc
1   package mockit;
2   
3   /**
4    * The Class ClassWithObjectOverrides.
5    */
6   public final class ClassWithObjectOverrides implements Cloneable {
7   
8       /** The text. */
9       private final StringBuilder text;
10  
11      /**
12       * Instantiates a new class with object overrides.
13       *
14       * @param text
15       *            the text
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       * Gets the int value.
55       *
56       * @return the int value
57       */
58      int getIntValue() {
59          return -1;
60      }
61  
62      /**
63       * Do something.
64       */
65      void doSomething() {
66          throw new RuntimeException();
67      }
68  
69      /**
70       * Do something.
71       *
72       * @param arg
73       *            the arg
74       *
75       * @return the int
76       */
77      int doSomething(Object arg) {
78          return arg.hashCode();
79      }
80  }