Class CloneBuilder

java.lang.Object
cz.cvut.kbss.jopa.sessions.CloneBuilder

public class CloneBuilder extends Object
Builds clones used in transactions for tracking changes.
  • Constructor Details

  • Method Details

    • buildClone

      public Object buildClone(Object original, CloneConfiguration cloneConfiguration)
      Builds clone of the given object.
      Parameters:
      original - Object
      cloneConfiguration - Configuration for the cloning process
      Returns:
      The clone
      Throws:
      NullPointerException - If original is null
    • buildClone

      public Object buildClone(Object cloneOwner, Field clonedField, Object original, Descriptor descriptor)
      Builds clone of the given object.

      This method differs from buildClone(Object, CloneConfiguration) in that it accepts another argument which represents the owner of the built clone. This is useful in situations when we are cloning attributes directly, e.g. when lazily loading a field value.

      Parameters:
      cloneOwner - The owner of the created clone
      clonedField - The field whose value is being cloned
      original - The original to clone
      descriptor - Entity descriptor
      Returns:
      The clone
      Throws:
      NullPointerException - If cloneOwner, original or contextUri is null
    • mergeChanges

      public void mergeChanges(ObjectChangeSet changeSet)
      Merges the changes on clone into the original object.
      Parameters:
      changeSet - Contains changes to merge
    • reset

      public void reset()
      Resets the clone builder.

      Especially resets the visited objects cache to make sure all the clones are built from scratch and are not affected by the previously built ones.

    • removeVisited

      public void removeVisited(Object instance, Descriptor descriptor)
      Removes the specified instance from the clone builder's visited entities cache.
      Parameters:
      instance - The instance to remove (original object).
      descriptor - Instance descriptor