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