1 16 package org.apache.commons.collections.iterators; 17 18 import org.apache.commons.collections.OrderedMapIterator; 19 import org.apache.commons.collections.Unmodifiable; 20 21 29 public final class UnmodifiableOrderedMapIterator implements OrderedMapIterator, Unmodifiable { 30 31 32 private OrderedMapIterator iterator; 33 34 41 public static OrderedMapIterator decorate(OrderedMapIterator iterator) { 42 if (iterator == null) { 43 throw new IllegalArgumentException ("OrderedMapIterator must not be null"); 44 } 45 if (iterator instanceof Unmodifiable) { 46 return iterator; 47 } 48 return new UnmodifiableOrderedMapIterator(iterator); 49 } 50 51 57 private UnmodifiableOrderedMapIterator(OrderedMapIterator iterator) { 58 super(); 59 this.iterator = iterator; 60 } 61 62 public boolean hasNext() { 64 return iterator.hasNext(); 65 } 66 67 public Object next() { 68 return iterator.next(); 69 } 70 71 public boolean hasPrevious() { 72 return iterator.hasPrevious(); 73 } 74 75 public Object previous() { 76 return iterator.previous(); 77 } 78 79 public Object getKey() { 80 return iterator.getKey(); 81 } 82 83 public Object getValue() { 84 return iterator.getValue(); 85 } 86 87 public Object setValue(Object value) { 88 throw new UnsupportedOperationException ("setValue() is not supported"); 89 } 90 91 public void remove() { 92 throw new UnsupportedOperationException ("remove() is not supported"); 93 } 94 95 } 96 | Popular Tags |