/
GraphFactory.java
41 lines (34 loc) · 1.47 KB
/
GraphFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package org.javers.core;
import org.javers.core.commit.CommitMetadata;
import org.javers.core.graph.LiveGraph;
import org.javers.core.graph.LiveGraphFactory;
import org.javers.core.metamodel.object.CdoSnapshot;
import org.javers.core.snapshot.GraphShadowFactory;
import org.javers.core.snapshot.GraphSnapshotFactory;
import org.javers.core.snapshot.ShadowGraph;
import java.util.List;
/**
* Facade to all graph factories
*
* @author bartosz walacik
*/
public class GraphFactory {
private final GraphSnapshotFactory graphSnapshotFactory;
private final GraphShadowFactory graphShadowFactory;
private final LiveGraphFactory liveGraphFactory;
public GraphFactory(GraphSnapshotFactory graphSnapshotFactory, GraphShadowFactory graphShadowFactory, LiveGraphFactory liveGraphFactory) {
this.graphSnapshotFactory = graphSnapshotFactory;
this.graphShadowFactory = graphShadowFactory;
this.liveGraphFactory = liveGraphFactory;
}
public LiveGraph createLiveGraph(Object currentVersion) {
return liveGraphFactory.createLiveGraph(currentVersion);
}
public ShadowGraph createLatestShadow(LiveGraph liveGraph){
return graphShadowFactory.createLatestShadow(liveGraph);
}
//capture current state
public List<CdoSnapshot> createGraphSnapshot(LiveGraph currentVersion, ShadowGraph latestShadowGraph, CommitMetadata commitMetadata){
return graphSnapshotFactory.create(currentVersion, latestShadowGraph, commitMetadata);
}
}