Debian Codegraph @

lang/java/src/com/sleepycat/persist/evolve/Mutation.java

raw
1 /*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002, 2013 Oracle and/or its affiliates. All rights reserved.
5 *
6 */
7
8 package com.sleepycat.persist.evolve;
9
10 import java.io.Serializable;
11
12 /**
13 * The base class for all mutations.
14 *
15 * @see com.sleepycat.persist.evolve Class Evolution
16 * @author Mark Hayes
17 */
18 public abstract class Mutation implements Serializable {
19
20 private static final long serialVersionUID = -8094431582953129268L;
21
22 private String className;
23 private int classVersion;
24 private String fieldName;
25
26 Mutation(String className, int classVersion, String fieldName) {
27 this.className = className;
28 this.classVersion = classVersion;
29 this.fieldName = fieldName;
30 }
31
32 /**
33 * Returns the class to which this mutation applies.
34 */
35 public String getClassName() {
36 return className;
37 }
38
39 /**
40 * Returns the class version to which this mutation applies.
41 */
42 public int getClassVersion() {
43 return classVersion;
44 }
45
46 /**
47 * Returns the field name to which this mutation applies, or null if this
48 * mutation applies to the class itself.
49 */
50 public String getFieldName() {
51 return fieldName;
52 }
53
54 /**
55 * Returns true if the class name, class version and field name are equal
56 * in this object and given object.
57 */
58 @Override
59 public boolean equals(Object other) {
60 if (other instanceof Mutation) {
61 Mutation o = (Mutation) other;
62 return className.equals(o.className) &&
63 classVersion == o.classVersion &&
64 ((fieldName != null) ? fieldName.equals(o.fieldName)
65 : (o.fieldName == null));
66 } else {
67 return false;
68 }
69 }
70
71 @Override
72 public int hashCode() {
73 return className.hashCode() +
74 classVersion +
75 ((fieldName != null) ? fieldName.hashCode() : 0);
76 }
77
78 @Override
79 public String toString() {
80 return "Class: " + className + " Version: " + classVersion +
81 ((fieldName != null) ? (" Field: " + fieldName) : "");
82 }
83 }