1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package eu.ehri.project.persistence;
21
22
23 import java.util.Optional;
24
25
26
27
28
29 public final class Mutation<T> {
30 private final T node;
31 private final MutationState state;
32 private final Optional<Bundle> prior;
33
34 public Mutation(T node, MutationState state, Optional<Bundle> prior) {
35 this.node = node;
36 this.state = state;
37 this.prior = prior;
38 }
39
40 public Mutation(T node, MutationState state) {
41 this(node, state, Optional.empty());
42 }
43
44 public Mutation(T node, MutationState state, Bundle bundle) {
45 this(node, state, Optional.ofNullable(bundle));
46 }
47
48 public T getNode() {
49 return node;
50 }
51
52 public Optional<Bundle> getPrior() {
53 return this.prior;
54 }
55
56 public MutationState getState() {
57 return state;
58 }
59
60 public boolean hasChanged() {
61 return state != MutationState.UNCHANGED;
62 }
63
64 public boolean created() {
65 return state == MutationState.CREATED;
66 }
67
68 public boolean updated() {
69 return state == MutationState.UPDATED;
70 }
71 }