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.collections4.bidimap; 18 19 import java.util.Set; 20 21 import org.apache.commons.collections4.BidiMap; 22 import org.apache.commons.collections4.MapIterator; 23 import org.apache.commons.collections4.map.AbstractMapDecorator; 24 25 /** 26 * Provides a base decorator that enables additional functionality to be added 27 * to a BidiMap via decoration. 28 * <p> 29 * Methods are forwarded directly to the decorated map. 30 * </p> 31 * <p> 32 * This implementation does not perform any special processing with the map views. 33 * Instead it simply returns the set/collection from the wrapped map. This may be 34 * undesirable, for example if you are trying to write a validating implementation 35 * it would provide a loophole around the validation. 36 * But, you might want that loophole, so this class is kept simple. 37 * </p> 38 * 39 * @param <K> the type of the keys in this map 40 * @param <V> the type of the values in this map 41 * @since 3.0 42 */ 43 public abstract class AbstractBidiMapDecorator<K, V> 44 extends AbstractMapDecorator<K, V> implements BidiMap<K, V> { 45 46 /** 47 * Constructor that wraps (not copies). 48 * 49 * @param map the map to decorate, must not be null 50 * @throws NullPointerException if the collection is null 51 */ 52 protected AbstractBidiMapDecorator(final BidiMap<K, V> map) { 53 super(map); 54 } 55 56 /** 57 * Gets the map being decorated. 58 * 59 * @return the decorated map 60 */ 61 @Override 62 protected BidiMap<K, V> decorated() { 63 return (BidiMap<K, V>) super.decorated(); 64 } 65 66 @Override 67 public K getKey(final Object value) { 68 return decorated().getKey(value); 69 } 70 71 @Override 72 public BidiMap<V, K> inverseBidiMap() { 73 return decorated().inverseBidiMap(); 74 } 75 76 @Override 77 public MapIterator<K, V> mapIterator() { 78 return decorated().mapIterator(); 79 } 80 81 @Override 82 public K removeValue(final Object value) { 83 return decorated().removeValue(value); 84 } 85 86 @Override 87 public Set<V> values() { 88 return decorated().values(); 89 } 90 91 }