org.javers.core.diff.Change Maven / Gradle / Ivy
package org.javers.core.diff;
import org.javers.common.string.PrettyValuePrinter;
import org.javers.core.Javers;
import org.javers.core.commit.CommitMetadata;
import org.javers.core.diff.changetype.NewObject;
import org.javers.core.diff.changetype.ObjectRemoved;
import org.javers.core.diff.changetype.ReferenceChange;
import org.javers.core.diff.changetype.ValueChange;
import org.javers.core.diff.changetype.container.ContainerChange;
import org.javers.core.diff.changetype.container.ListChange;
import org.javers.core.diff.changetype.map.MapChange;
import org.javers.core.metamodel.object.GlobalId;
import org.javers.core.metamodel.object.InstanceId;
import java.io.Serializable;
import java.util.Objects;
import java.util.Optional;
import static org.javers.common.validation.Validate.*;
/**
* Change represents an atomic difference between two objects.
*
*
* There are several types fo change:
* {@link ValueChange}, {@link ReferenceChange}, {@link ListChange}, {@link NewObject}, {@link ObjectRemoved},
* {@link ContainerChange}, {@link MapChange}.
* See the inheritance hierarchy for the complete list.
*
*
* @see Diff
* @author bartosz walacik
*/
public abstract class Change implements Serializable {
private final CommitMetadata commitMetadata; //optional, can't use Optional here, because it isn't Serializable
private final GlobalId affectedCdoId;
private transient Object affectedCdo; //optional
protected Change(GlobalId affectedCdoId, Optional