File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\util\CompoundEnumeration.java.html

1 package hudson.util;
2
3 import java.util.Arrays;
4 import java.util.Enumeration;
5 import java.util.Iterator;
6 import java.util.NoSuchElementException;
7
8 /**
9 * {@link Enumeration} that aggregates multiple {@link Enumeration}s.
10 *
11 * @author Kohsuke Kawaguchi
12 */
13 public class CompoundEnumeration<T> implements Enumeration<T> {
14 private final Iterator<Enumeration<? extends T>> base;
15
16 private Enumeration<? extends T> cur;
17
18 public CompoundEnumeration(Enumeration... e) {
19 this((Iterable)Arrays.asList(e));
20 }
21
22 public CompoundEnumeration(Iterable<Enumeration<? extends T>> e) {
23 this.base = e.iterator();
24 }
25
26 public boolean hasMoreElements() {
27 while (!cur.hasMoreElements() && base.hasNext()) {
28 cur = base.next();
29 }
30 return cur.hasMoreElements();
31 }
32
33 public T nextElement() throws NoSuchElementException {
34 return cur.nextElement();
35 }
36 }
37
38