Package: IndirectCollection
IndirectCollection
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
IndirectCollection() |
|
|
|
|
|
||||||||||||||||||||
IndirectCollection(Object, Field, UnitOfWorkImpl) |
|
|
|
|
|
||||||||||||||||||||
persistChange() |
|
|
|
|
|
||||||||||||||||||||
static {...} |
|
|
|
|
|
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.adapters;
16:
17: import cz.cvut.kbss.jopa.sessions.UnitOfWorkImpl;
18:
19: import java.lang.reflect.Field;
20:
21: public abstract class IndirectCollection<T> {
22:
23: protected final Object owner;
24: protected final Field field;
25: protected final UnitOfWorkImpl persistenceContext;
26:
27: protected IndirectCollection() {
28: owner = null;
29: field = null;
30: persistenceContext = null;
31: }
32:
33: /**
34: * Create new indirect collection from the specified data.
35: * <p>
36: * The owner can be null, the persistence context not.
37: *
38: * @param owner Owner of the indirect collection
39: * @param f The field holding this collection
40: * @param persistenceContext Persistence context the owner belongs to
41: * @throws NullPointerException If the persistence context is null
42: */
43: protected IndirectCollection(Object owner, Field f, UnitOfWorkImpl persistenceContext) {
44:• if (persistenceContext == null) {
45: throw new NullPointerException("Null passed in as persistenceContext.");
46: }
47: this.owner = owner;
48: this.field = f;
49: this.persistenceContext = persistenceContext;
50: }
51:
52: protected void persistChange() {
53:• assert persistenceContext != null;
54:• if (persistenceContext.isInTransaction() && !persistenceContext.isInCommit()) {
55: persistenceContext.attributeChanged(owner, field);
56: }
57: }
58:
59: /**
60: * The returned type is determined by the instance type parameter.
61: *
62: * @return The collection wrapped in this indirect collection
63: */
64: public abstract T getReferencedCollection();
65: }