Skip to content

Package: SimpleOneLevelCascadeExplorer

SimpleOneLevelCascadeExplorer

nameinstructionbranchcomplexitylinemethod
SimpleOneLevelCascadeExplorer()
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%
exploreCascaded(Attribute, Object)
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%
exploreNonCascaded(Attribute, Object)
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%
runCascadedForEach(Object)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
runForEach(Attribute, Object, boolean)
M: 4 C: 40
91%
M: 1 C: 9
90%
M: 1 C: 5
83%
M: 1 C: 12
92%
M: 0 C: 1
100%
runNonCascadedForEach(Object)
M: 0 C: 1
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: * <p>
4: * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
5: * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
6: * version.
7: * <p>
8: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
10: * details. You should have received a copy of the GNU General Public License along with this program. If not, see
11: * <http://www.gnu.org/licenses/>.
12: */
13: package cz.cvut.kbss.jopa.model;
14:
15: import cz.cvut.kbss.jopa.model.metamodel.Attribute;
16: import cz.cvut.kbss.jopa.utils.EntityPropertiesUtils;
17:
18: import java.util.Collection;
19: import java.util.HashSet;
20:
21: public abstract class SimpleOneLevelCascadeExplorer extends OneLevelCascadeExplorer {
22:
23: protected void runForEach(final Attribute<?, ?> at, final Object o, boolean cascaded)
24: throws IllegalAccessException {
25: Object attVal = EntityPropertiesUtils.getAttributeValue(at, o);
26:• if (attVal == null) {
27: return;
28: }
29:• if (at.isCollection()) {
30:• for (final Object ox2 : new HashSet<>((Collection<?>) attVal)) {
31:• if (cascaded) {
32: runCascadedForEach(ox2);
33: } else {
34: runNonCascadedForEach(ox2);
35: }
36: }
37: } else {
38:• if (cascaded) {
39: runCascadedForEach(attVal);
40: } else {
41: runNonCascadedForEach(attVal);
42: }
43: }
44: }
45:
46: @Override
47: protected void exploreCascaded(final Attribute<?, ?> at, final Object o)
48: throws IllegalAccessException {
49: runForEach(at, o, true);
50: }
51:
52: protected void runCascadedForEach(Object ox2) {
53: // nothing
54: }
55:
56: @Override
57: protected void exploreNonCascaded(final Attribute<?, ?> at, final Object o)
58: throws IllegalAccessException {
59: runForEach(at, o, false);
60: }
61:
62: protected void runNonCascadedForEach(Object ox2) {
63: // nothing
64: }
65: }