Debian Codegraph @

lang/java/src/com/sleepycat/persist/evolve/Deleter.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 /**
11 * A mutation for deleting an entity class or field.
12 *
13 * <p><strong>WARNING:</strong> The data for the deleted class or field will be
14 * destroyed and will be recoverable only by restoring from backup. If you
15 * wish to convert the instance data to a different type or format, use a
16 * {@link Conversion} mutation instead.</p>
17 *
18 * <p>For example, to delete a field:</p>
19 *
20 * <pre class="code">
21 * package my.package;
22 *
23 * // The old class. Version 0 is implied.
24 * //
25 * {@literal @Entity}
26 * class Person {
27 * String name;
28 * String favoriteColors;
29 * }
30 *
31 * // The new class. A new version number must be assigned.
32 * //
33 * {@literal @Entity(version=1)}
34 * class Person {
35 * String name;
36 * }
37 *
38 * // Add the mutation for deleting a field.
39 * //
40 * Mutations mutations = new Mutations();
41 *
42 * mutations.addDeleter(new Deleter(Person.class.getName(), 0,
43 * "favoriteColors");
44 *
45 * // Configure the mutations as described {@link Mutations here}.</pre>
46 *
47 * <p>To delete an entity class:</p>
48 *
49 * <pre class="code">
50 * package my.package;
51 *
52 * // The old class. Version 0 is implied.
53 * //
54 * {@literal @Entity}
55 * class Statistics {
56 * ...
57 * }
58 *
59 * // Add the mutation for deleting a class.
60 * //
61 * Mutations mutations = new Mutations();
62 *
63 * mutations.addDeleter(new Deleter("my.package.Statistics", 0));
64 *
65 * // Configure the mutations as described {@link Mutations here}.</pre>
66 *
67 * @see com.sleepycat.persist.evolve Class Evolution
68 * @author Mark Hayes
69 */
70 public class Deleter extends Mutation {
71
72 private static final long serialVersionUID = 446348511871654947L;
73
74 /**
75 * Creates a mutation for deleting an entity class.
76 */
77 public Deleter(String className, int classVersion) {
78 super(className, classVersion, null);
79 }
80
81 /**
82 * Creates a mutation for deleting the given field from all instances of
83 * the given class version.
84 */
85 public Deleter(String declaringClass, int declaringClassVersion,
86 String fieldName) {
87 super(declaringClass, declaringClassVersion, fieldName);
88 }
89
90 @Override
91 public String toString() {
92 return "[Deleter " + super.toString() + ']';
93 }
94 }