1 16 package org.apache.commons.collections.bidimap; 17 18 import java.util.Collection ; 19 import java.util.Map ; 20 import java.util.Set ; 21 22 import org.apache.commons.collections.BidiMap; 23 import org.apache.commons.collections.MapIterator; 24 import org.apache.commons.collections.OrderedBidiMap; 25 import org.apache.commons.collections.OrderedMapIterator; 26 import org.apache.commons.collections.Unmodifiable; 27 import org.apache.commons.collections.collection.UnmodifiableCollection; 28 import org.apache.commons.collections.iterators.UnmodifiableOrderedMapIterator; 29 import org.apache.commons.collections.map.UnmodifiableEntrySet; 30 import org.apache.commons.collections.set.UnmodifiableSet; 31 32 40 public final class UnmodifiableOrderedBidiMap 41 extends AbstractOrderedBidiMapDecorator implements Unmodifiable { 42 43 44 private UnmodifiableOrderedBidiMap inverse; 45 46 55 public static OrderedBidiMap decorate(OrderedBidiMap map) { 56 if (map instanceof Unmodifiable) { 57 return map; 58 } 59 return new UnmodifiableOrderedBidiMap(map); 60 } 61 62 69 private UnmodifiableOrderedBidiMap(OrderedBidiMap map) { 70 super(map); 71 } 72 73 public void clear() { 75 throw new UnsupportedOperationException (); 76 } 77 78 public Object put(Object key, Object value) { 79 throw new UnsupportedOperationException (); 80 } 81 82 public void putAll(Map mapToCopy) { 83 throw new UnsupportedOperationException (); 84 } 85 86 public Object remove(Object key) { 87 throw new UnsupportedOperationException (); 88 } 89 90 public Set entrySet() { 91 Set set = super.entrySet(); 92 return UnmodifiableEntrySet.decorate(set); 93 } 94 95 public Set keySet() { 96 Set set = super.keySet(); 97 return UnmodifiableSet.decorate(set); 98 } 99 100 public Collection values() { 101 Collection coll = super.values(); 102 return UnmodifiableCollection.decorate(coll); 103 } 104 105 public Object removeValue(Object value) { 107 throw new UnsupportedOperationException (); 108 } 109 110 public MapIterator mapIterator() { 111 return orderedMapIterator(); 112 } 113 114 public BidiMap inverseBidiMap() { 115 return inverseOrderedBidiMap(); 116 } 117 118 public OrderedMapIterator orderedMapIterator() { 120 OrderedMapIterator it = getOrderedBidiMap().orderedMapIterator(); 121 return UnmodifiableOrderedMapIterator.decorate(it); 122 } 123 124 public OrderedBidiMap inverseOrderedBidiMap() { 125 if (inverse == null) { 126 inverse = new UnmodifiableOrderedBidiMap(getOrderedBidiMap().inverseOrderedBidiMap()); 127 inverse.inverse = this; 128 } 129 return inverse; 130 } 131 132 } 133 | Popular Tags |