|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ElementsInnerProxyMap.java | 12.5% | 47.1% | 50% | 38.7% |
|
1 |
// Copyright 2004, 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.hivemind.impl;
|
|
16 |
|
|
17 |
import java.util.AbstractMap;
|
|
18 |
import java.util.Map;
|
|
19 |
import java.util.Set;
|
|
20 |
|
|
21 |
/**
|
|
22 |
* Implements a {@link java.util.Map}as a proxy to an actual map of elements, provided by an
|
|
23 |
* extension point. The proxy is unmodifiable and will work with the extension point to generate the
|
|
24 |
* real map of elements in a just-in-time manner.
|
|
25 |
*
|
|
26 |
* @author Knut Wannheden
|
|
27 |
* @since 1.1
|
|
28 |
*/
|
|
29 |
public final class ElementsInnerProxyMap extends AbstractMap |
|
30 |
{ |
|
31 |
private Map _inner;
|
|
32 |
|
|
33 |
private ConfigurationPointImpl _point;
|
|
34 |
|
|
35 |
private ElementsProxyMap _outer;
|
|
36 |
|
|
37 | 110 |
ElementsInnerProxyMap(ConfigurationPointImpl point, ElementsProxyMap outer) |
38 |
{ |
|
39 | 110 |
_point = point; |
40 | 110 |
_outer = outer; |
41 |
|
|
42 | 110 |
_outer.setInner(this);
|
43 |
} |
|
44 |
|
|
45 | 109 |
public Set entrySet()
|
46 |
{ |
|
47 | 109 |
return inner().entrySet();
|
48 |
} |
|
49 |
|
|
50 | 109 |
private synchronized Map inner() |
51 |
{ |
|
52 | 109 |
if (_inner == null) |
53 |
{ |
|
54 | 109 |
_inner = _point.constructMapElements(); |
55 |
|
|
56 |
// Replace ourselves in the outer proxy with the actual list.
|
|
57 | 109 |
_outer.setInner(_inner); |
58 |
} |
|
59 |
|
|
60 | 109 |
return _inner;
|
61 |
} |
|
62 |
|
|
63 | 0 |
public boolean equals(Object o) |
64 |
{ |
|
65 | 0 |
if (this == o) |
66 | 0 |
return true; |
67 |
|
|
68 | 0 |
if (o == null) |
69 | 0 |
return false; |
70 |
|
|
71 | 0 |
return inner().equals(o);
|
72 |
} |
|
73 |
|
|
74 | 0 |
public int hashCode() |
75 |
{ |
|
76 | 0 |
return inner().hashCode();
|
77 |
} |
|
78 |
|
|
79 | 0 |
public synchronized String toString() |
80 |
{ |
|
81 | 0 |
if (_inner != null) |
82 | 0 |
return _inner.toString();
|
83 |
|
|
84 | 0 |
return "<Element Map Proxy for " + _point.getExtensionPointId() + ">"; |
85 |
} |
|
86 |
|
|
87 |
} |
|