Skip to content

Package: UnitOfWorkChangeSetImpl

UnitOfWorkChangeSetImpl

nameinstructionbranchcomplexitylinemethod
UnitOfWorkChangeSetImpl()
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
addDeletedObjectChangeSet(ObjectChangeSet)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
addNewObjectChangeSet(ObjectChangeSet)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
addObjectChangeSet(ObjectChangeSet)
M: 0 C: 15
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getDeletedObjects()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getExistingObjectChanges(Object)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getExistingObjectsChanges()
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%
getNewObjects()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hasChanges()
M: 1 C: 13
93%
M: 1 C: 5
83%
M: 1 C: 3
75%
M: 0 C: 1
100%
M: 0 C: 1
100%
hasDeleted()
M: 0 C: 8
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hasNew()
M: 0 C: 8
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.sessions.change;
16:
17: import cz.cvut.kbss.jopa.sessions.ObjectChangeSet;
18: import cz.cvut.kbss.jopa.sessions.UnitOfWorkChangeSet;
19:
20: import java.util.*;
21:
22: public class UnitOfWorkChangeSetImpl implements UnitOfWorkChangeSet {
23:
24: private Set<ObjectChangeSet> deletedObjects;
25: private Map<Object, ObjectChangeSet> objectChanges;
26: private Set<ObjectChangeSet> newObjectChanges;
27:
28: public UnitOfWorkChangeSetImpl() {
29: super();
30: this.objectChanges = new HashMap<>();
31: this.deletedObjects = new HashSet<>();
32: this.newObjectChanges = new HashSet<>();
33: }
34:
35: @Override
36: public void addObjectChangeSet(ObjectChangeSet objectChangeSet) {
37:• if (objectChangeSet.isNew()) {
38: addNewObjectChangeSet(objectChangeSet);
39: } else {
40: objectChanges.put(objectChangeSet.getChangedObject(), objectChangeSet);
41: }
42: }
43:
44: @Override
45: public void addDeletedObjectChangeSet(ObjectChangeSet deletedObject) {
46: deletedObjects.add(deletedObject);
47: }
48:
49: @Override
50: public void addNewObjectChangeSet(ObjectChangeSet newObject) {
51: newObject.setNew(true);
52: newObjectChanges.add(newObject);
53: }
54:
55: @Override
56: public Collection<ObjectChangeSet> getExistingObjectsChanges() {
57: return Collections.unmodifiableCollection(objectChanges.values());
58: }
59:
60: @Override
61: public ObjectChangeSet getExistingObjectChanges(Object original) {
62: return objectChanges.get(original);
63: }
64:
65: @Override
66: public Set<ObjectChangeSet> getDeletedObjects() {
67: return this.deletedObjects;
68: }
69:
70: @Override
71: public Set<ObjectChangeSet> getNewObjects() {
72: return this.newObjectChanges;
73: }
74:
75: @Override
76: public boolean hasDeleted() {
77:• return !deletedObjects.isEmpty();
78: }
79:
80: @Override
81: public boolean hasChanges() {
82:• return hasDeleted() || hasNew() || !objectChanges.isEmpty();
83: }
84:
85: @Override
86: public boolean hasNew() {
87:• return !this.newObjectChanges.isEmpty();
88: }
89: }