Skip to content

Package: IndirectMap

IndirectMap

nameinstructionbranchcomplexitylinemethod
IndirectMap()
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
IndirectMap(Object, Field, UnitOfWorkImpl, Map)
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
clear()
M: 0 C: 9
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 4
100%
M: 0 C: 1
100%
containsKey(Object)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
containsValue(Object)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
entrySet()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
equals(Object)
M: 7 C: 13
65%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 2 C: 3
60%
M: 0 C: 1
100%
get(Object)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getReferencedCollection()
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%
hashCode()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isEmpty()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
keySet()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
put(Object, Object)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
putAll(Map)
M: 0 C: 10
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 4
100%
M: 0 C: 1
100%
remove(Object)
M: 0 C: 11
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 4
100%
M: 0 C: 1
100%
size()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
toString()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
values()
M: 0 C: 4
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.adapters;
16:
17: import java.lang.reflect.Field;
18: import java.util.*;
19:
20: import cz.cvut.kbss.jopa.sessions.UnitOfWorkImpl;
21:
22: public class IndirectMap<K, V> extends IndirectCollection<Map<K, V>> implements Map<K, V> {
23:
24: private final Map<K, V> internalMap;
25:
26: /**
27: * No-arg constructor to support clone building
28: */
29: IndirectMap() {
30: this.internalMap = new HashMap<>();
31: }
32:
33: public IndirectMap(Object owner, Field f, UnitOfWorkImpl persistenceContext, Map<K, V> referencedMap) {
34: super(owner, f, persistenceContext);
35: this.internalMap = Objects.requireNonNull(referencedMap);
36: }
37:
38: @Override
39: public Map<K, V> getReferencedCollection() {
40: return internalMap;
41: }
42:
43: @Override
44: public int size() {
45: return internalMap.size();
46: }
47:
48: @Override
49: public boolean isEmpty() {
50: return internalMap.isEmpty();
51: }
52:
53: @Override
54: public boolean containsKey(Object key) {
55: return internalMap.containsKey(key);
56: }
57:
58: @Override
59: public boolean containsValue(Object value) {
60: return internalMap.containsValue(value);
61: }
62:
63: @Override
64: public V get(Object key) {
65: return internalMap.get(key);
66: }
67:
68: @Override
69: public V put(K key, V value) {
70: V val = internalMap.put(key, value);
71: persistChange();
72: return val;
73: }
74:
75: @Override
76: public V remove(Object key) {
77: V val = internalMap.remove(key);
78:• if (val != null) {
79: persistChange();
80: }
81: return val;
82: }
83:
84: @Override
85: public void putAll(Map<? extends K, ? extends V> m) {
86: internalMap.putAll(m);
87:• if (!m.isEmpty()) {
88: persistChange();
89: }
90: }
91:
92: @Override
93: public void clear() {
94:• if (!isEmpty()) {
95: internalMap.clear();
96: persistChange();
97: }
98: }
99:
100: @Override
101: public Set<K> keySet() {
102: return internalMap.keySet();
103: }
104:
105: @Override
106: public Collection<V> values() {
107: return internalMap.values();
108: }
109:
110: @Override
111: public Set<java.util.Map.Entry<K, V>> entrySet() {
112: return internalMap.entrySet();
113: }
114:
115: @Override
116: public boolean equals(Object o) {
117:• if (o instanceof Map) {
118:• if (o instanceof IndirectMap) {
119: return internalMap.equals(((IndirectMap) o).internalMap);
120: }
121: return internalMap.equals(o);
122: }
123: return false;
124: }
125:
126: @Override
127: public int hashCode() {
128: return internalMap.hashCode();
129: }
130:
131: @Override
132: public String toString() {
133: return internalMap.toString();
134: }
135: }