equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
28 * of TypeSafeEnum are singletons. |
28 * of TypeSafeEnum are singletons. |
29 */ |
29 */ |
30 import java.io.*; |
30 import java.io.*; |
31 |
31 |
32 public class TypeSafeEnum implements Serializable, ObjectInputValidation { |
32 public class TypeSafeEnum implements Serializable, ObjectInputValidation { |
|
33 private static final long serialVersionUID = 1L; |
|
34 |
33 private static int numWriteObject = 0; |
35 private static int numWriteObject = 0; |
34 private static int numReadObject = 0; |
36 private static int numReadObject = 0; |
35 |
37 |
36 |
38 |
37 private String value; |
39 private String value; |
45 static int numReadResolve = 0; |
47 static int numReadResolve = 0; |
46 static int numWriteReplace = 0; |
48 static int numWriteReplace = 0; |
47 static boolean verbose = false; |
49 static boolean verbose = false; |
48 |
50 |
49 |
51 |
50 private Object writeReplace() throws IOException { |
52 private Object writeReplace() { |
51 numWriteReplace++; |
53 numWriteReplace++; |
52 if (verbose) { |
54 if (verbose) { |
53 System.out.println("TypeSafeEnum.writeReplace() " + |
55 System.out.println("TypeSafeEnum.writeReplace() " + |
54 this.toString()); |
56 this.toString()); |
55 } |
57 } |
56 return this; |
58 return this; |
57 } |
59 } |
58 |
60 |
59 private Object readResolve() throws IOException { |
61 private Object readResolve() { |
60 numReadResolve++; |
62 numReadResolve++; |
61 if (verbose) { |
63 if (verbose) { |
62 System.out.println("readResolve called on " + this.toString()); |
64 System.out.println("readResolve called on " + this.toString()); |
63 } |
65 } |
64 if (value.equals(FIRST.value)) { |
66 if (value.equals(FIRST.value)) { |