| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AbstractIteratorDecorator |
|
| 1.4;1.4 |
| 1 | /* | |
| 2 | ||
| 3 | dsh-graph Directed graph interface and implementation. | |
| 4 | Copyright (c) 2004-2013 held jointly by the individual authors. | |
| 5 | ||
| 6 | This library is free software; you can redistribute it and/or modify it | |
| 7 | under the terms of the GNU Lesser General Public License as published | |
| 8 | by the Free Software Foundation; either version 3 of the License, or (at | |
| 9 | your option) any later version. | |
| 10 | ||
| 11 | This library is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or | |
| 13 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | |
| 14 | License for more details. | |
| 15 | ||
| 16 | You should have received a copy of the GNU Lesser General Public License | |
| 17 | along with this library; if not, write to the Free Software Foundation, | |
| 18 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
| 19 | ||
| 20 | > http://www.fsf.org/licensing/licenses/lgpl.html | |
| 21 | > http://www.opensource.org/licenses/lgpl-license.php | |
| 22 | ||
| 23 | */ | |
| 24 | package org.dishevelled.graph.impl; | |
| 25 | ||
| 26 | import java.util.Iterator; | |
| 27 | ||
| 28 | /** | |
| 29 | * Abstract iterator that decorates an instance of <code>Iterator</code>. | |
| 30 | * | |
| 31 | * @param <E> iterator element type | |
| 32 | * @author Michael Heuer | |
| 33 | * @version $Revision$ $Date$ | |
| 34 | */ | |
| 35 | abstract class AbstractIteratorDecorator<E> | |
| 36 | implements Iterator<E> | |
| 37 | { | |
| 38 | /** Iterator this decorator decorates. */ | |
| 39 | private final Iterator<E> iterator; | |
| 40 | ||
| 41 | ||
| 42 | /** | |
| 43 | * Create a new abstract iterator that decorates the specified iterator. | |
| 44 | * | |
| 45 | * @param iterator iterator to decorate, must not be null | |
| 46 | */ | |
| 47 | protected AbstractIteratorDecorator(final Iterator<E> iterator) | |
| 48 | 0 | { |
| 49 | 0 | if (iterator == null) |
| 50 | { | |
| 51 | 0 | throw new IllegalArgumentException("iterator must not be null"); |
| 52 | } | |
| 53 | 0 | this.iterator = iterator; |
| 54 | 0 | } |
| 55 | ||
| 56 | ||
| 57 | /** | |
| 58 | \ * Return a reference to the iterator this decorator decorates. | |
| 59 | * | |
| 60 | * @return a reference to the iterator this decorator decorates | |
| 61 | */ | |
| 62 | protected final Iterator<E> getIterator() | |
| 63 | { | |
| 64 | 0 | return iterator; |
| 65 | } | |
| 66 | ||
| 67 | /** {@inheritDoc} */ | |
| 68 | public boolean hasNext() | |
| 69 | { | |
| 70 | 0 | return iterator.hasNext(); |
| 71 | } | |
| 72 | ||
| 73 | /** {@inheritDoc} */ | |
| 74 | public E next() | |
| 75 | { | |
| 76 | 0 | return iterator.next(); |
| 77 | } | |
| 78 | ||
| 79 | /** {@inheritDoc} */ | |
| 80 | public void remove() | |
| 81 | { | |
| 82 | 0 | iterator.remove(); |
| 83 | 0 | } |
| 84 | } |