Skip to content

Package: Change

Change

nameinstructionbranchcomplexitylinemethod
getEntityContext()
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getObjectClass()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.sessions.change;
19:
20: import cz.cvut.kbss.jopa.model.descriptors.Descriptor;
21: import cz.cvut.kbss.jopa.utils.MetamodelUtils;
22:
23: import java.net.URI;
24:
25: /**
26: * Represents a change to an object made during a transaction.
27: */
28: public interface Change {
29:
30: /**
31: * Gets the type of the changed object.
32: *
33: * @return Object type
34: */
35: default Class<?> getObjectClass() {
36: return MetamodelUtils.getEntityClass(getClone().getClass());
37: }
38:
39: /**
40: * Gets the clone with changes.
41: *
42: * @return Clone, never {@code null}
43: */
44: Object getClone();
45:
46: /**
47: * Gets the original object.
48: *
49: * @return Original
50: */
51: Object getOriginal();
52:
53: /**
54: * Gets descriptor of the changed object.
55: *
56: * @return Instance descriptor
57: */
58: Descriptor getDescriptor();
59:
60: /**
61: * Gets identifier of the repository context to which the changed object belongs.
62: *
63: * @return context URI
64: */
65: default URI getEntityContext() {
66: return getDescriptor().getSingleContext().orElse(null);
67: }
68: }