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: 0 C: 44
100%
M: 0 C: 10
100%
M: 0 C: 6
100%
M: 0 C: 13
100%
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) 2020 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: Object attVal = EntityPropertiesUtils.getAttributeValue(at, o);
27:• if (attVal == null) {
28: return;
29: }
30:• if (at.isCollection()) {
31:• for (final Object ox2 : new HashSet<>((Collection<?>) attVal)) {
32:• if (cascaded) {
33: runCascadedForEach(ox2);
34: } else {
35: runNonCascadedForEach(ox2);
36: }
37: }
38: } else {
39:• if (cascaded) {
40: runCascadedForEach(attVal);
41: } else {
42: runNonCascadedForEach(attVal);
43: }
44: }
45: }
46:
47: @Override
48: protected void exploreCascaded(final Attribute<?, ?> at, final Object o) {
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: runForEach(at, o, false);
59: }
60:
61: protected void runNonCascadedForEach(Object ox2) {
62: // nothing
63: }
64: }