-
Notifications
You must be signed in to change notification settings - Fork 14
/
DeleteObjectChangeSet.java
88 lines (71 loc) · 2.01 KB
/
DeleteObjectChangeSet.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package cz.cvut.kbss.jopa.sessions.change;
import cz.cvut.kbss.jopa.model.descriptors.Descriptor;
import cz.cvut.kbss.jopa.sessions.ChangeRecord;
import cz.cvut.kbss.jopa.sessions.ObjectChangeSet;
import java.net.URI;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
/**
* Change set representing object deletion.
* <p>
* Supports only a subset of the {@link ObjectChangeSet} operations relevant for object removal during merge into parent
* session.
*/
public class DeleteObjectChangeSet implements ObjectChangeSet {
private final Object object;
private final Descriptor descriptor;
public DeleteObjectChangeSet(Object object, Descriptor descriptor) {
this.object = Objects.requireNonNull(object);
this.descriptor = Objects.requireNonNull(descriptor);
}
/**
* @throws UnsupportedOperationException This method is not supported
*/
@Override
public void addChangeRecord(ChangeRecord record) {
unsupported();
}
private static void unsupported() {
throw new UnsupportedOperationException("Can't invoke on " + DeleteObjectChangeSet.class.getSimpleName());
}
@Override
public Class<?> getObjectClass() {
return object.getClass();
}
@Override
public Set<ChangeRecord> getChanges() {
return Collections.emptySet();
}
@Override
public boolean hasChanges() {
return false;
}
/**
* @throws UnsupportedOperationException This method is not supported
*/
@Override
public void setNew(boolean isNew) {
unsupported();
}
@Override
public boolean isNew() {
return false;
}
@Override
public Object getCloneObject() {
return object;
}
@Override
public Object getChangedObject() {
return object;
}
@Override
public Descriptor getEntityDescriptor() {
return descriptor;
}
@Override
public URI getEntityContext() {
return descriptor.getContext();
}
}