Renamer (Oracle - Berkeley DB Java Edition API)
Date: 2014-12-16

com.sleepycat.persist.evolve

## Class Renamer

- java.lang.Object
- - com.sleepycat.persist.evolve.Mutation
  - - com.sleepycat.persist.evolve.Renamer

- All Implemented Interfaces:
    Serializable

      public class Renamer
      extends Mutation

  A mutation for renaming a class or field without changing the instance or field value. For example:

        package my.package;

        // The old class.  Version 0 is implied.
        //
        @Entity
        class Person {
            String name;
        }

        // The new class.  A new version number must be assigned.
        //
        @Entity(version=1)
        class Human {
            String fullName;
        }

        // Add the mutations.
        //
        Mutations mutations = new Mutations();

        mutations.addRenamer(new Renamer("my.package.Person", 0,
                                         Human.class.getName()));

        mutations.addRenamer(new Renamer("my.package.Person", 0,
                                         "name", "fullName"));

        // Configure the mutations as described here.

  In a replicated environment, renaming an entity class or secondary key field may require handling the `DatabasePreemptedException` during the upgrade process. See Upgrading a Replication Group for more information.

  Author:
    Mark Hayes
  See Also:
    `Class Evolution`, Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Renamer(String fromClass, int fromVersion, String toClass)` Creates a mutation for renaming the class of all instances of the given class version.
    `Renamer(String declaringClass, int declaringClassVersion, String fromField, String toField)` Creates a mutation for renaming the given field for all instances of the given class version.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object other)` Returns true if the new class name is equal in this object and given object, and if the `Mutation.equals(java.lang.Object)` method returns true.
    `String` | `getNewName()` Returns the new class or field name specified in the constructor.
    `int` | `hashCode()`
    `String` | `toString()`

    - ### Methods inherited from class com.sleepycat.persist.evolve.Mutation

      `getClassName, getClassVersion, getFieldName`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Renamer

          public Renamer(String fromClass,
                 int fromVersion,
                 String toClass)

      Creates a mutation for renaming the class of all instances of the given class version.

    - #### Renamer

          public Renamer(String declaringClass,
                 int declaringClassVersion,
                 String fromField,
                 String toField)

      Creates a mutation for renaming the given field for all instances of the given class version.

  - ### Method Detail

    - #### getNewName

          public String getNewName()

      Returns the new class or field name specified in the constructor.

    - #### equals

          public boolean equals(Object other)

      Returns true if the new class name is equal in this object and given object, and if the `Mutation.equals(java.lang.Object)` method returns true.
      Overrides:
        `equals` in class `Mutation`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Mutation`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Mutation`

Copyright (c) 2004, 2014 Oracle and/or its affiliates. All rights reserved.