|
|||||||||||||||||||
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 | |||||||||||||||
IteratorClosureAdapter.java | - | 0% | 0% | 0% |
|
1 |
package org.codehaus.groovy.runtime;
|
|
2 |
|
|
3 |
import groovy.lang.Closure;
|
|
4 |
import groovy.lang.MetaClass;
|
|
5 |
|
|
6 |
import java.util.ArrayList;
|
|
7 |
import java.util.List;
|
|
8 |
|
|
9 |
/**
|
|
10 |
* A closure which stores calls in a List so that method calls
|
|
11 |
* can be iterated over in a 'yield' style way
|
|
12 |
*
|
|
13 |
* @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
|
|
14 |
* @version $Revision: 1.2 $
|
|
15 |
*/
|
|
16 |
public class IteratorClosureAdapter extends Closure { |
|
17 |
|
|
18 |
private List list = new ArrayList(); |
|
19 |
private MetaClass metaClass = InvokerHelper.getMetaClass(this); |
|
20 |
|
|
21 | 0 |
public IteratorClosureAdapter(Object delegate) {
|
22 | 0 |
super(delegate);
|
23 |
} |
|
24 |
|
|
25 | 0 |
public MetaClass getMetaClass() {
|
26 | 0 |
return metaClass;
|
27 |
} |
|
28 |
|
|
29 | 0 |
public void setMetaClass(MetaClass metaClass) { |
30 | 0 |
this.metaClass = metaClass;
|
31 |
} |
|
32 |
|
|
33 | 0 |
public List asList() {
|
34 | 0 |
return list;
|
35 |
} |
|
36 |
|
|
37 | 0 |
protected Object doCall(Object argument) {
|
38 | 0 |
list.add(argument); |
39 | 0 |
return null; |
40 |
} |
|
41 |
} |
|
42 |
|
|