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)
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<CdoSnapshot> |
getStateHistory(Object localId,
Class entityClass,
int limit)
Snapshots (historical states) of 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)
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.
For any versioned object, you can: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_NOT_MAPPED if given javaClass is NOT mapped to Entity@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 - ignoredCopyright © 2014. All rights reserved.