public class Javers extends Object
JaversBuilder provided with your domain specific configuration.
MappingDocumentation to find out how to map your domain model| Constructor and Description |
|---|
Javers(DiffFactory diffFactory,
TypeMapper typeMapper,
JsonConverter jsonConverter,
CommitFactory commitFactory,
JaversExtendedRepository repository,
SnapshotDiffer snapshotDiffer)
JaVers instance should be constructed by
JaversBuilder |
| Modifier and Type | Method and Description |
|---|---|
Commit |
commit(String author,
Object currentVersion)
Persists current version of given domain objects graph in JaVers repository.
|
Diff |
compare(Object oldVersion,
Object currentVersion)
Easiest way to calculate diff, just provide two versions of the same object graph.
|
Diff |
compare(String author,
Object oldVersion,
Object currentVersion)
Deprecated.
|
List<Change> |
getChangeHistory(GlobalIdDTO globalCdoId,
int limit)
Changes (diff sequence) of given managed class instance (entity or value object),
in reverse chronological order
|
List<Change> |
getChangeHistory(Object localId,
Class entityClass,
int limit)
Changes (diff sequence) of given entity instance,
in reverse chronological order
|
JsonConverter |
getJsonConverter() |
Optional<CdoSnapshot> |
getLatestSnapshot(GlobalIdDTO globalCdoId)
Latest snapshot of given object
or Optional#EMPTY if object is not versioned
|
List<CdoSnapshot> |
getStateHistory(Object localId,
Class entityClass,
int limit)
Snapshots (historical states) of given entity instance,
in reverse chronological order
|
IdBuilder |
idBuilder() |
Diff |
initial(Object newDomainObject)
Initial diff is a kind of snapshot of given domain objects graph.
|
Diff |
initial(String author,
Object newDomainObject)
Deprecated.
use
initial(Object) |
String |
toJson(Diff diff)
Use it alongside with
compare(Object, Object) |
public Javers(DiffFactory diffFactory, TypeMapper typeMapper, JsonConverter jsonConverter, CommitFactory commitFactory, JaversExtendedRepository repository, SnapshotDiffer snapshotDiffer)
JaversBuilderpublic Commit commit(String author, Object currentVersion)
Persists current version of given domain objects graph in JaVers repository. All changes made on versioned objects are recorded, new objects become versioned and its initial state is recorded.
currentVersion - domain object, instance of Entity or ValueObject.
It should be root of an aggregate, tree root
or any node in objects graph from where all other nodes are navigable.
(Javadoc source: ObjectGraphBuilder.buildGraph(Object))public Diff compare(Object oldVersion, Object currentVersion)
Easiest way to calculate diff, just provide two versions of the same object graph. Use it if you don't want to store domain objects history in JaVers repository.
Diffs can be converted to JSON with toJson(Diff) and stored in custom repository
public Diff initial(Object newDomainObject)
compare(Object, Object)public String toJson(Diff diff)
compare(Object, Object)public IdBuilder idBuilder()
public List<CdoSnapshot> getStateHistory(Object localId, Class entityClass, int limit)
localId - id of required instanceentityClass - class of required instancelimit - choose reasonable limitJaversException - ENTITY_EXPECTED if given javaClass is NOT mapped to Entitypublic Optional<CdoSnapshot> getLatestSnapshot(GlobalIdDTO globalCdoId)
public List<Change> getChangeHistory(Object localId, Class entityClass, int limit)
localId - id of required instanceentityClass - class of required instancelimit - choose reasonable limitJaversException - ENTITY_EXPECTED if given javaClass is NOT mapped to Entitypublic List<Change> getChangeHistory(GlobalIdDTO globalCdoId, int limit)
@Deprecated public Diff initial(String author, Object newDomainObject)
initial(Object)author - ignored@Deprecated public Diff compare(String author, Object oldVersion, Object currentVersion)
compare(Object, Object)author - ignoredpublic JsonConverter getJsonConverter()
Copyright © 2014. All rights reserved.