Package: ChangeTrackingIndirectMap
ChangeTrackingIndirectMap
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ChangeTrackingIndirectMap(Object, Field, UnitOfWork, Map) |
|
|
|
|
|
||||||||||||||||||||
clear() |
|
|
|
|
|
||||||||||||||||||||
containsKey(Object) |
|
|
|
|
|
||||||||||||||||||||
containsValue(Object) |
|
|
|
|
|
||||||||||||||||||||
entrySet() |
|
|
|
|
|
||||||||||||||||||||
equals(Object) |
|
|
|
|
|
||||||||||||||||||||
get(Object) |
|
|
|
|
|
||||||||||||||||||||
hashCode() |
|
|
|
|
|
||||||||||||||||||||
isEmpty() |
|
|
|
|
|
||||||||||||||||||||
keySet() |
|
|
|
|
|
||||||||||||||||||||
put(Object, Object) |
|
|
|
|
|
||||||||||||||||||||
putAll(Map) |
|
|
|
|
|
||||||||||||||||||||
remove(Object) |
|
|
|
|
|
||||||||||||||||||||
size() |
|
|
|
|
|
||||||||||||||||||||
toString() |
|
|
|
|
|
||||||||||||||||||||
unwrap() |
|
|
|
|
|
||||||||||||||||||||
values() |
|
|
|
|
|
Coverage
1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.proxy.change;
19:
20: import cz.cvut.kbss.jopa.sessions.UnitOfWork;
21:
22: import java.lang.reflect.Field;
23: import java.util.Collection;
24: import java.util.Map;
25: import java.util.Objects;
26: import java.util.Set;
27:
28: public class ChangeTrackingIndirectMap<K, V> extends ChangeTrackingIndirectCollection<Map<K, V>> implements Map<K, V> {
29:
30: private final Map<K, V> internalMap;
31:
32: public ChangeTrackingIndirectMap(Object owner, Field f, UnitOfWork persistenceContext, Map<K, V> referencedMap) {
33: super(owner, f, persistenceContext);
34: this.internalMap = Objects.requireNonNull(referencedMap);
35: }
36:
37: @Override
38: public Map<K, V> unwrap() {
39: return internalMap;
40: }
41:
42: @Override
43: public int size() {
44: return internalMap.size();
45: }
46:
47: @Override
48: public boolean isEmpty() {
49: return internalMap.isEmpty();
50: }
51:
52: @Override
53: public boolean containsKey(Object key) {
54: return internalMap.containsKey(key);
55: }
56:
57: @Override
58: public boolean containsValue(Object value) {
59: return internalMap.containsValue(value);
60: }
61:
62: @Override
63: public V get(Object key) {
64: return internalMap.get(key);
65: }
66:
67: @Override
68: public V put(K key, V value) {
69: V val = internalMap.put(key, value);
70: persistChange();
71: return val;
72: }
73:
74: @Override
75: public V remove(Object key) {
76: V val = internalMap.remove(key);
77:• if (val != null) {
78: persistChange();
79: }
80: return val;
81: }
82:
83: @Override
84: public void putAll(Map<? extends K, ? extends V> m) {
85: internalMap.putAll(m);
86:• if (!m.isEmpty()) {
87: persistChange();
88: }
89: }
90:
91: @Override
92: public void clear() {
93:• if (!isEmpty()) {
94: internalMap.clear();
95: persistChange();
96: }
97: }
98:
99: @Override
100: public Set<K> keySet() {
101: return internalMap.keySet();
102: }
103:
104: @Override
105: public Collection<V> values() {
106: return internalMap.values();
107: }
108:
109: @Override
110: public Set<java.util.Map.Entry<K, V>> entrySet() {
111: return internalMap.entrySet();
112: }
113:
114: @Override
115: public boolean equals(Object o) {
116:• if (o instanceof Map) {
117:• if (o instanceof ChangeTrackingIndirectMap) {
118: return internalMap.equals(((ChangeTrackingIndirectMap) o).internalMap);
119: }
120: return internalMap.equals(o);
121: }
122: return false;
123: }
124:
125: @Override
126: public int hashCode() {
127: return internalMap.hashCode();
128: }
129:
130: @Override
131: public String toString() {
132: return internalMap.toString();
133: }
134: }