|
|||||||||||||||||||
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 | |||||||||||||||
ElementsInnerProxyList.java | 50% | 77.8% | 85.7% | 72.7% |
|
1 |
// Copyright 2004 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.AbstractList;
|
|
18 |
import java.util.List;
|
|
19 |
|
|
20 |
/**
|
|
21 |
* Implements a {@link java.util.List} as a proxy to an actual list of
|
|
22 |
* elements, provided by an extension point. The proxy is unmodifiable
|
|
23 |
* and will work with the extension point to generate the real list
|
|
24 |
* of elements in a just-in-time manner.
|
|
25 |
*
|
|
26 |
* @author Howard Lewis Ship
|
|
27 |
*/
|
|
28 |
public final class ElementsInnerProxyList extends AbstractList |
|
29 |
{ |
|
30 |
private List _inner;
|
|
31 |
private ConfigurationPointImpl _point;
|
|
32 |
private ElementsProxyList _outer;
|
|
33 |
|
|
34 | 523 |
ElementsInnerProxyList(ConfigurationPointImpl point, ElementsProxyList outer) |
35 |
{ |
|
36 | 523 |
_point = point; |
37 | 523 |
_outer = outer; |
38 |
|
|
39 | 523 |
_outer.setInner(this);
|
40 |
} |
|
41 |
|
|
42 | 519 |
private synchronized List inner() |
43 |
{ |
|
44 | 519 |
if (_inner == null) |
45 |
{ |
|
46 | 519 |
_inner = _point.constructElements(); |
47 |
|
|
48 |
// Replace ourselves in the outer proxy with the actual list.
|
|
49 | 516 |
_outer.setInner(_inner); |
50 |
} |
|
51 |
|
|
52 | 516 |
return _inner;
|
53 |
} |
|
54 |
|
|
55 | 1 |
public Object get(int index) |
56 |
{ |
|
57 | 1 |
return inner().get(index);
|
58 |
} |
|
59 |
|
|
60 | 517 |
public int size() |
61 |
{ |
|
62 | 517 |
return inner().size();
|
63 |
} |
|
64 |
|
|
65 | 1 |
public boolean equals(Object o) |
66 |
{ |
|
67 | 1 |
if (this == o) |
68 | 0 |
return true; |
69 |
|
|
70 | 1 |
if (o == null) |
71 | 0 |
return false; |
72 |
|
|
73 | 1 |
return inner().equals(o);
|
74 |
} |
|
75 |
|
|
76 | 0 |
public int hashCode() |
77 |
{ |
|
78 | 0 |
return inner().hashCode();
|
79 |
} |
|
80 |
|
|
81 | 2 |
public synchronized String toString() |
82 |
{ |
|
83 | 2 |
if (_inner != null) |
84 | 0 |
return _inner.toString();
|
85 |
|
|
86 | 2 |
return "<Element List Proxy for " + _point.getExtensionPointId() + ">"; |
87 |
} |
|
88 |
|
|
89 |
} |
|
90 |
|
|