Package: IteratorToEnumerationAdapter

IteratorToEnumerationAdapter

nameinstructionbranchcomplexitylinemethod
IteratorToEnumerationAdapter(Iterator)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
hasMoreElements()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
nextElement()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2012 VMware Inc.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * VMware Inc. - initial contribution
10: *******************************************************************************/
11:
12: package org.eclipse.virgo.util.common;
13:
14: import java.util.Enumeration;
15: import java.util.Iterator;
16:
17: /**
18: * {@link IteratorToEnumerationAdapter} adapts an {@link Iterator} to conform to the {@link Enumeration} interface.
19: * <p />
20: *
21: * <strong>Concurrent Semantics</strong><br />
22: * Thread safe.
23: */
24: public class IteratorToEnumerationAdapter<T> implements Enumeration<T> {
25:
26: private final Iterator<T> iterator;
27:
28: public IteratorToEnumerationAdapter(Iterator<T> iterator) {
29: this.iterator = iterator;
30: }
31:
32: @Override
33: public boolean hasMoreElements() {
34: return iterator.hasNext();
35: }
36:
37: @Override
38: public T nextElement() {
39: return iterator.next();
40: }
41:
42: }