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: *
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.model;
16:
17: import cz.cvut.kbss.jopa.model.metamodel.Attribute;
18: import cz.cvut.kbss.jopa.utils.EntityPropertiesUtils;
19:
20: import java.util.Collection;
21: import java.util.HashSet;
22:
23: public abstract class SimpleOneLevelCascadeExplorer extends OneLevelCascadeExplorer {
24:
25: protected void runForEach(final Attribute<?, ?> at, final Object o, boolean cascaded)
26: throws IllegalAccessException {
27: Object attVal = EntityPropertiesUtils.getAttributeValue(at, o);
28:• if (attVal == null) {
29: return;
30: }
31:• if (at.isCollection()) {
32:• for (final Object ox2 : new HashSet<>((Collection<?>) attVal)) {
33:• if (cascaded) {
34: runCascadedForEach(ox2);
35: } else {
36: runNonCascadedForEach(ox2);
37: }
38: }
39: } else {
40:• if (cascaded) {
41: runCascadedForEach(attVal);
42: } else {
43: runNonCascadedForEach(attVal);
44: }
45: }
46: }
47:
48: @Override
49: protected void exploreCascaded(final Attribute<?, ?> at, final Object o)
50: throws IllegalAccessException {
51: runForEach(at, o, true);
52: }
53:
54: protected void runCascadedForEach(Object ox2) {
55: // nothing
56: }
57:
58: @Override
59: protected void exploreNonCascaded(final Attribute<?, ?> at, final Object o)
60: throws IllegalAccessException {
61: runForEach(at, o, false);
62: }
63:
64: protected void runNonCascadedForEach(Object ox2) {
65: // nothing
66: }
67: }