Imported Upstream version 5.3.21
[platform/upstream/libdb.git] / test / java / compat / src / com / sleepycat / collections / test / serial / TestSerial.java.original
1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2000, 2012 Oracle and/or its affiliates.  All rights reserved.
5  *
6  */
7 package com.sleepycat.collections.test.serial;
8
9 /**
10  * @see StoredClassCatalogTest
11  * @author Mark Hayes
12  */
13 class TestSerial implements java.io.Serializable
14 {
15     static final long serialVersionUID = -3738980000390384920L;
16
17     private int i = 123;
18     private TestSerial other;
19
20     // The following field 's' was added after this class was compiled and
21     // serialized instances were saved in resource files.  This allows testing
22     // that the original stored instances can be deserialized after changing
23     // the class.  The serialVersionUID is needed for this according to Java
24     // serialization rules, and was generated with the serialver tool.
25     //
26     //private String s = "string";
27
28     TestSerial(TestSerial other)
29     {
30         this.other = other;
31     }
32
33     TestSerial getOther()
34     {
35         return other;
36     }
37
38     int getIntField()
39     {
40         return i;
41     }
42
43     String getStringField()
44     {
45         return null; // this returned null before field 's' was added.
46     }
47
48     public boolean equals(Object object)
49     {
50         try
51         {
52             TestSerial o = (TestSerial) object;
53             if ((o.other == null) ? (this.other != null)
54                                   : (!o.other.equals(this.other)))
55                 return false;
56             if (this.i != o.i)
57                 return false;
58             // the following test was not done before field 's' was added
59             /*
60             if ((o.s == null) ? (this.s != null)
61                               : (!o.s.equals(this.s)))
62                 return false;
63             */
64             return true;
65         }
66         catch (ClassCastException e)
67         {
68             return false;
69         }
70     }
71 }