Skip to contentPackage: UnitOfWorkChangeSet
UnitOfWorkChangeSet
Coverage
1: /*
2: * JOPA
3: * Copyright (C) 2023 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;
19:
20: import java.util.Collection;
21: import java.util.Set;
22:
23: public interface UnitOfWorkChangeSet {
24: /**
25: * Add new ObjectChangeSet to this changeSet.
26: *
27: * @param objectChangeSet ObjectChangeSet
28: */
29: void addObjectChangeSet(ObjectChangeSet objectChangeSet);
30:
31: /**
32: * Add a change set for newly created object. These changes are held in
33: * separate attribute and get special treatment when merged into shared
34: * session cache.
35: *
36: * @param newObject ObjectChangeSet
37: */
38: void addNewObjectChangeSet(ObjectChangeSet newObject);
39:
40: /**
41: * Adds a change set for deleted object.
42: *
43: * @param deletedObject The change set to add
44: */
45: void addDeletedObjectChangeSet(ObjectChangeSet deletedObject);
46:
47: /**
48: * Returns change sets for existing modified objects.
49: * <p>
50: * New object and deleted object change sets are not included.
51: *
52: * @return Collection of change sets
53: */
54: Collection<ObjectChangeSet> getExistingObjectsChanges();
55:
56: /**
57: * Removes change record of the specified original object, if present, cancelling the changes.
58: *
59: * @param original The object whose changes should be removed
60: */
61: void cancelObjectChanges(Object original);
62:
63: /**
64: * Gets changes for the specified original object (if there are any).
65: *
66: * @param original The object for which changes should be found
67: * @return Object change set or null, if the object has no changes
68: */
69: ObjectChangeSet getExistingObjectChanges(Object original);
70:
71: /**
72: * Returns the collection of deleted objects.
73: *
74: * @return Set of change sets
75: */
76: Set<ObjectChangeSet> getDeletedObjects();
77:
78: /**
79: * Returns the collection of change sets for newly created objects.
80: *
81: * @return Set of change sets
82: */
83: Set<ObjectChangeSet> getNewObjects();
84:
85: /**
86: * Returns true if there are deleted objects in this change set.
87: *
88: * @return boolean
89: */
90: boolean hasDeleted();
91:
92: /**
93: * Returns true if this changeSet has any changes.
94: *
95: * @return boolean
96: */
97: boolean hasChanges();
98:
99: /**
100: * Are there any new objects in the change set?
101: *
102: * @return boolean
103: */
104: boolean hasNew();
105: }