Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 55e36864dd6875f1bb294f1e946a3a0343fd536a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/***************************************************************************
 * Copyright (c) 2004-2007 Eike Stepper, Germany.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *    Eike Stepper - initial API and implementation
 **************************************************************************/
package org.eclipse.internal.net4j.util;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
 * Implementation note: {@link AbstractDelegatingMap} does not necessarily
 * preserve the "modifyable view" contract of {@link Map#entrySet()} as well as
 * of {@link Map#keySet()}, i.e. they might be disconnected sets and
 * modifications applied to them might not be applied to their underlying
 * {@link AbstractDelegatingMap}.
 * <p>
 * 
 * @author Eike Stepper
 */
public abstract class AbstractDelegatingMap<K, V> implements Map<K, V>
{
  protected AbstractDelegatingMap()
  {
  }

  protected AbstractDelegatingMap(Map<? extends K, ? extends V> t)
  {
    putAll(t);
  }

  public void clear()
  {
    delegatedClear();
  }

  public boolean containsKey(Object key)
  {
    return delegatedContainsKey(key);
  }

  public boolean containsValue(Object value)
  {
    return delegatedContainsValue(value);
  }

  public Set<Entry<K, V>> entrySet()
  {
    return delegatedEntrySet();
  }

  public V get(Object key)
  {
    return delegatedGet(key);
  }

  public boolean isEmpty()
  {
    return delegatedIsEmpty();
  }

  public Set<K> keySet()
  {
    return delegatedKeySet();
  }

  public V put(K key, V value)
  {
    return delegatedPut(key, value);
  }

  public void putAll(Map<? extends K, ? extends V> t)
  {
    delegatedPutAll(t);
  }

  public V remove(Object key)
  {
    return delegatedRemove(key);
  }

  public int size()
  {
    return delegatedSize();
  }

  public Collection<V> values()
  {
    return delegatedValues();
  }

  @Override
  public boolean equals(Object obj)
  {
    return delegatedEquals(obj);
  }

  @Override
  public int hashCode()
  {
    return delegatedHashCode();
  }

  @Override
  public String toString()
  {
    return delegatedToString();
  }

  protected void delegatedClear()
  {
    getDelegate().clear();
  }

  protected boolean delegatedContainsKey(Object key)
  {
    return getDelegate().containsKey(key);
  }

  protected boolean delegatedContainsValue(Object value)
  {
    return getDelegate().containsValue(value);
  }

  protected Set<Entry<K, V>> delegatedEntrySet()
  {
    return getDelegate().entrySet();
  }

  protected V delegatedGet(Object key)
  {
    return getDelegate().get(key);
  }

  protected boolean delegatedIsEmpty()
  {
    return getDelegate().isEmpty();
  }

  protected Set<K> delegatedKeySet()
  {
    return getDelegate().keySet();
  }

  protected V delegatedPut(K key, V value)
  {
    return getDelegate().put(key, value);
  }

  protected void delegatedPutAll(Map<? extends K, ? extends V> t)
  {
    getDelegate().putAll(t);
  }

  protected V delegatedRemove(Object key)
  {
    return getDelegate().remove(key);
  }

  protected int delegatedSize()
  {
    return getDelegate().size();
  }

  protected Collection<V> delegatedValues()
  {
    return getDelegate().values();
  }

  protected boolean delegatedEquals(Object obj)
  {
    return getDelegate().equals(obj);
  }

  protected int delegatedHashCode()
  {
    return getDelegate().hashCode();
  }

  protected String delegatedToString()
  {
    return getDelegate().toString();
  }

  protected abstract Map<K, V> getDelegate();
}

Back to the top