1 16 package org.apache.commons.collections.iterators; 17 18 import org.apache.commons.collections.MapIterator; 19 import org.apache.commons.collections.Unmodifiable; 20 21 29 public final class UnmodifiableMapIterator implements MapIterator, Unmodifiable { 30 31 32 private MapIterator iterator; 33 34 41 public static MapIterator decorate(MapIterator iterator) { 42 if (iterator == null) { 43 throw new IllegalArgumentException ("MapIterator must not be null"); 44 } 45 if (iterator instanceof Unmodifiable) { 46 return iterator; 47 } 48 return new UnmodifiableMapIterator(iterator); 49 } 50 51 57 private UnmodifiableMapIterator(MapIterator 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 Object getKey() { 72 return iterator.getKey(); 73 } 74 75 public Object getValue() { 76 return iterator.getValue(); 77 } 78 79 public Object setValue(Object value) { 80 throw new UnsupportedOperationException ("setValue() is not supported"); 81 } 82 83 public void remove() { 84 throw new UnsupportedOperationException ("remove() is not supported"); 85 } 86 87 } 88 | Popular Tags |