001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.commons.collections.bidimap; 018 019 import org.apache.commons.collections.BidiMap; 020 import org.apache.commons.collections.MapIterator; 021 import org.apache.commons.collections.map.AbstractMapDecorator; 022 023 /** 024 * Provides a base decorator that enables additional functionality to be added 025 * to a BidiMap via decoration. 026 * <p> 027 * Methods are forwarded directly to the decorated map. 028 * <p> 029 * This implementation does not perform any special processing with the map views. 030 * Instead it simply returns the set/collection from the wrapped map. This may be 031 * undesirable, for example if you are trying to write a validating implementation 032 * it would provide a loophole around the validation. 033 * But, you might want that loophole, so this class is kept simple. 034 * 035 * @since Commons Collections 3.0 036 * @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $ 037 * 038 * @author Stephen Colebourne 039 */ 040 public abstract class AbstractBidiMapDecorator 041 extends AbstractMapDecorator implements BidiMap { 042 043 /** 044 * Constructor that wraps (not copies). 045 * 046 * @param map the map to decorate, must not be null 047 * @throws IllegalArgumentException if the collection is null 048 */ 049 protected AbstractBidiMapDecorator(BidiMap map) { 050 super(map); 051 } 052 053 /** 054 * Gets the map being decorated. 055 * 056 * @return the decorated map 057 */ 058 protected BidiMap getBidiMap() { 059 return (BidiMap) map; 060 } 061 062 //----------------------------------------------------------------------- 063 public MapIterator mapIterator() { 064 return getBidiMap().mapIterator(); 065 } 066 067 public Object getKey(Object value) { 068 return getBidiMap().getKey(value); 069 } 070 071 public Object removeValue(Object value) { 072 return getBidiMap().removeValue(value); 073 } 074 075 public BidiMap inverseBidiMap() { 076 return getBidiMap().inverseBidiMap(); 077 } 078 079 }