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