Skip to content

Package: OneLevelRemoveCascadeExplorer

OneLevelRemoveCascadeExplorer

nameinstructionbranchcomplexitylinemethod
OneLevelRemoveCascadeExplorer(Consumer)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
exploreCascaded(Attribute, Object)
M: 1 C: 40
98%
M: 1 C: 7
88%
M: 1 C: 4
80%
M: 1 C: 10
91%
M: 0 C: 1
100%

Coverage

1: package cz.cvut.kbss.jopa.model;
2:
3: import cz.cvut.kbss.jopa.model.metamodel.Attribute;
4: import cz.cvut.kbss.jopa.proxy.lazy.LazyLoadingProxy;
5: import cz.cvut.kbss.jopa.utils.EntityPropertiesUtils;
6: import cz.cvut.kbss.jopa.utils.JOPALazyUtils;
7:
8: import java.util.Collection;
9: import java.util.HashSet;
10: import java.util.function.Consumer;
11:
12: public class OneLevelRemoveCascadeExplorer extends OneLevelCascadeExplorer {
13:
14: private final Consumer<Object> removeOperation;
15:
16: public OneLevelRemoveCascadeExplorer(Consumer<Object> removeOperation) {
17: this.removeOperation = removeOperation;
18: }
19:
20: @Override
21: protected void exploreCascaded(Attribute<?, ?> at, Object o) {
22: Object attVal = EntityPropertiesUtils.getAttributeValue(at, o);
23:• if (attVal == null) {
24: return;
25: }
26:• if (JOPALazyUtils.isLazyLoadingProxy(attVal)) {
27: attVal = ((LazyLoadingProxy<?>) attVal).triggerLazyLoading();
28: }
29:• if (at.isCollection()) {
30:• for (final Object ox2 : new HashSet<>((Collection<?>) attVal)) {
31: removeOperation.accept(ox2);
32: }
33: } else {
34: removeOperation.accept(attVal);
35: }
36: }
37: }