All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.javers.shadow.Shadow Maven / Gradle / Ivy

There is a newer version: 7.6.3
Show newest version
package org.javers.shadow;

import org.javers.common.validation.Validate;
import org.javers.core.commit.CommitId;
import org.javers.core.commit.CommitMetadata;
import org.javers.core.metamodel.object.CdoSnapshot;
import org.javers.repository.api.JaversRepository;

/**
 * Shadow is a historical version of a domain object restored
 * from a snapshot loaded from {@link JaversRepository}.
 * 

* * Shadows objects are of the same type domain objects. * For example, a Shadow of a Person object is an instance of the Person class. *

* * Shadows class is a thin wrapper for a Shadow object and {@link CommitMetadata} * * @param type of a domain object * @author bartosz.walacik */ public class Shadow { private final CdoSnapshot cdoSnapshot; private final CommitMetadata rootCommitMetadata; private final T it; Shadow(CommitMetadata rootCommitMetadata, CdoSnapshot cdoSnapshot, T shadow) { Validate.argumentsAreNotNull(rootCommitMetadata, cdoSnapshot, shadow); this.cdoSnapshot = cdoSnapshot; this.rootCommitMetadata = rootCommitMetadata; this.it = shadow; } /** * Root commit metadata */ public CommitMetadata getCommitMetadata() { return rootCommitMetadata; } /** * Root commit Id */ public CommitId getCommitId() { return rootCommitMetadata.getId(); } public CdoSnapshot getCdoSnapshot() { return cdoSnapshot; } /** * Shadow object per se */ public T get() { return it; } @Override public String toString() { return "Shadow{" + "it=" + it + ", commitMetadata=" + getCommitMetadata() + '}'; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy