public interface Javers
JaversBuilder provided with your domain model configuration.
Javers javers = JaversBuilder.javers().build(); Diff diff = javers.compare(oldVersion, currentVersion);
| Modifier and Type | Method and Description |
|---|---|
Commit |
commit(java.lang.String author,
java.lang.Object currentVersion)
Persists a current state of a given domain object graph
in JaVers repository.
|
Commit |
commitShallowDelete(java.lang.String author,
java.lang.Object deleted)
Marks given object as deleted.
|
Commit |
commitShallowDeleteById(java.lang.String author,
GlobalIdDTO globalId)
The same like
commitShallowDelete(String,Object)
but deleted object is selected using globalId |
Diff |
compare(java.lang.Object oldVersion,
java.lang.Object currentVersion)
JaVers core function,
deeply compares two arbitrary complex object graphs.
|
java.util.List<Change> |
getChangeHistory(GlobalIdDTO globalId,
int limit)
Changes history (diff sequence) of given object,
in reverse chronological order.
|
JsonConverter |
getJsonConverter() |
Optional<CdoSnapshot> |
getLatestSnapshot(GlobalIdDTO globalId)
Latest snapshot of given object
or Optional#EMPTY if object is not versioned.
|
java.util.List<CdoSnapshot> |
getStateHistory(GlobalIdDTO globalId,
int limit)
Snapshots (historical versions) of given object,
in reverse chronological order.
|
IdBuilder |
idBuilder() |
Diff |
initial(java.lang.Object newDomainObject)
Initial diff is a kind of snapshot of given domain object graph.
|
<T> T |
processChangeList(java.util.List<Change> changes,
ChangeProcessor<T> changeProcessor)
Generic purpose method for processing a changes list.
|
java.lang.String |
toJson(Diff diff)
Diff serialized to pretty JSON, useful if you are not using
JaversRepository |
Commit commit(java.lang.String author, java.lang.Object currentVersion)
currentVersion - standalone object or handle to an object graphCommit commitShallowDelete(java.lang.String author, java.lang.Object deleted)
commit(String, Object), this method is shallow
and affects only given object.
deleted - object to be marked as deletedCommit commitShallowDeleteById(java.lang.String author, GlobalIdDTO globalId)
commitShallowDelete(String,Object)
but deleted object is selected using globalIdDiff compare(java.lang.Object oldVersion, java.lang.Object currentVersion)
JaVers core function, deeply compares two arbitrary complex object graphs.
To calculate a diff, just provide two versions of the
same object or handles to two versions of the same object graph.
The handle could be a root of an aggregate, tree root
or any node in an object graph from where all other nodes are navigable.
This function is used for ad-hoc objects comparing.
In order to use data auditing feature, call commit(String, Object).
Diffs can be converted to JSON with toJson(Diff).
Diff initial(java.lang.Object newDomainObject)
compare(Object, Object)java.lang.String toJson(Diff diff)
JaversRepositoryjava.util.List<CdoSnapshot> getStateHistory(GlobalIdDTO globalId, int limit)
javers.getStateHistory(InstanceIdDTO.instanceId("bob", Person.class), 5);
globalId - given object IDlimit - choose reasonable limitOptional<CdoSnapshot> getLatestSnapshot(GlobalIdDTO globalId)
javers.getStateHistory(InstanceIdDTO.instanceId("bob", Person.class), 5);
java.util.List<Change> getChangeHistory(GlobalIdDTO globalId, int limit)
javers.getChangeHistory(InstanceIdDTO.instanceId("bob", Person.class), 5);
globalId - given object IDlimit - choose reasonable limitJsonConverter getJsonConverter()
<T> T processChangeList(java.util.List<Change> changes, ChangeProcessor<T> changeProcessor)
ChangeProcessor.result().
ChangeProcessor.onCommit(CommitMetadata)
is called only for first occurrence ChangeProcessor.onAffectedObject(GlobalId)
is called only for first occurrence
List<Change> changes = javers.getChangeHistory(...); String changeLog = javers.processChangeList(changes, new SimpleTextChangeLog()); System.out.println( changeLog );
SimpleTextChangeLogIdBuilder idBuilder()