Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ClassFileIterator |
|
| 2.5;2.5 |
1 | /* | |
2 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
3 | * you may not use this file except in compliance with the License. | |
4 | * You may obtain a copy of the License at | |
5 | * | |
6 | * http://www.apache.org/licenses/LICENSE-2.0 | |
7 | * | |
8 | * Unless required by applicable law or agreed to in writing, software | |
9 | * distributed under the License is distributed on an "AS IS" BASIS, | |
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
11 | * See the License for the specific language governing permissions and | |
12 | * limitations under the License. | |
13 | */ | |
14 | package org.apache.commons.classscan.builtin; | |
15 | ||
16 | import java.util.Iterator; | |
17 | import java.util.NoSuchElementException; | |
18 | ||
19 | import org.apache.commons.classscan.ClassFile; | |
20 | ||
21 | 0 | public abstract class ClassFileIterator implements Iterator<ClassFile> { |
22 | ||
23 | private ClassFile prefetch; | |
24 | ||
25 | abstract ClassFile getNext(); | |
26 | ||
27 | @Override | |
28 | public boolean hasNext() { | |
29 | 0 | if(prefetch==null) { |
30 | 0 | prefetch= getNext(); |
31 | } | |
32 | 0 | return prefetch!=null; |
33 | } | |
34 | ||
35 | @Override | |
36 | public ClassFile next() { | |
37 | 0 | if(prefetch!=null) { |
38 | 0 | ClassFile rc= prefetch; |
39 | 0 | prefetch= null; |
40 | 0 | return rc; |
41 | } | |
42 | 0 | ClassFile rc= getNext(); |
43 | 0 | if(rc==null) { |
44 | 0 | throw new NoSuchElementException(); |
45 | } | |
46 | 0 | return rc; |
47 | } | |
48 | ||
49 | @Override | |
50 | public void remove() { | |
51 | 0 | throw new UnsupportedOperationException(); |
52 | } | |
53 | } |