org.javers.core.metamodel.object.CdoSnapshot Maven / Gradle / Ivy
package org.javers.core.metamodel.object;
import org.javers.common.validation.Validate;
import org.javers.core.commit.CommitId;
import org.javers.core.commit.CommitMetadata;
import org.javers.core.graph.Cdo;
import org.javers.core.metamodel.property.Property;
import org.javers.core.metamodel.type.ManagedType;
import java.util.List;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import static java.util.Collections.unmodifiableList;
import static org.javers.common.validation.Validate.argumentIsNotNull;
import static org.javers.core.metamodel.object.CdoSnapshotStateBuilder.cdoSnapshotState;
import static org.javers.core.metamodel.object.SnapshotType.*;
/**
* Historical state of a domain object captured as the property->value Map.
* Values and primitives are stored 'by value'.
* Referenced Entities and ValueObjects are stored 'by reference' using {@link GlobalId}
*
* @author bartosz walacik
*/
public final class CdoSnapshot extends Cdo {
private CommitMetadata commitMetadata;
private final CdoSnapshotState state;
private final SnapshotType type;
private final List changed;
private final long version;
private final GlobalId globalId;
/**
* should be assembled by {@link CdoSnapshotBuilder}
*/
CdoSnapshot(GlobalId globalId,
CommitMetadata commitMetadata,
CdoSnapshotState state,
SnapshotType type,
List changed,
ManagedType managedType,
long version) {
super(managedType);
Validate.argumentsAreNotNull(state, commitMetadata, type, managedType, globalId);
this.state = state;
this.commitMetadata = commitMetadata;
this.type = type;
this.changed = changed;
this.version = version;
this.globalId = globalId;
}
/**
* @return {@link Optional#EMPTY}
*/
@Override
public Optional