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