1 package de.matthias_burbach.mosaique.core.util;
2
3 import java.util.Enumeration;
4 import java.util.Iterator;
5
6 /***
7 * Transforms a {@link java.util.Iterator} to a {@link java.util.Enumeration}.
8 *
9 * @author Matthias Burbach
10 */
11 public class EnumerationAdapter implements Enumeration {
12 /***
13 * The iterator to adapt.
14 */
15 private Iterator iterator;
16
17 /***
18 * @param iterator The iterator to adapt.
19 */
20 public EnumerationAdapter(final Iterator iterator) {
21 this.iterator = iterator;
22 }
23
24
25
26
27 /***
28 * {@inheritDoc}
29 */
30 public boolean hasMoreElements() {
31 return iterator.hasNext();
32 }
33
34
35
36
37 /***
38 * {@inheritDoc}
39 */
40 public Object nextElement() {
41 return iterator.next();
42 }
43 }