View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.collections.iterators;
18  
19  import org.apache.commons.collections.OrderedMapIterator;
20  
21  /**
22   * Provides basic behaviour for decorating an ordered map iterator with extra functionality.
23   * <p>
24   * All methods are forwarded to the decorated map iterator.
25   *
26   * @since 3.0
27   * @version $Id: AbstractOrderedMapIteratorDecorator.java 1429905 2013-01-07 17:15:14Z ggregory $
28   */
29  public class AbstractOrderedMapIteratorDecorator<K, V> implements OrderedMapIterator<K, V> {
30  
31      /** The iterator being decorated */
32      protected final OrderedMapIterator<K, V> iterator;
33  
34      //-----------------------------------------------------------------------
35      /**
36       * Constructor that decorates the specified iterator.
37       *
38       * @param iterator  the iterator to decorate, must not be null
39       * @throws IllegalArgumentException if the collection is null
40       */
41      public AbstractOrderedMapIteratorDecorator(final OrderedMapIterator<K, V> iterator) {
42          super();
43          if (iterator == null) {
44              throw new IllegalArgumentException("OrderedMapIterator must not be null");
45          }
46          this.iterator = iterator;
47      }
48  
49      /**
50       * Gets the iterator being decorated.
51       * 
52       * @return the decorated iterator
53       */
54      protected OrderedMapIterator<K, V> getOrderedMapIterator() {
55          return iterator;
56      }
57  
58      //-----------------------------------------------------------------------
59      
60      /** {@inheritDoc} */
61      public boolean hasNext() {
62          return iterator.hasNext();
63      }
64  
65      /** {@inheritDoc} */
66      public K next() {
67          return iterator.next();
68      }
69  
70      /** {@inheritDoc} */
71      public boolean hasPrevious() {
72          return iterator.hasPrevious();
73      }
74  
75      /** {@inheritDoc} */
76      public K previous() {
77          return iterator.previous();
78      }
79  
80      /** {@inheritDoc} */
81      public void remove() {
82          iterator.remove();
83      }
84      
85      /** {@inheritDoc} */
86      public K getKey() {
87          return iterator.getKey();
88      }
89  
90      /** {@inheritDoc} */
91      public V getValue() {
92          return iterator.getValue();
93      }
94  
95      /** {@inheritDoc} */
96      public V setValue(final V obj) {
97          return iterator.setValue(obj);
98      }
99  
100 }