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 */ 017package org.apache.commons.collections4.bidimap; 018 019import org.apache.commons.collections4.OrderedBidiMap; 020import org.apache.commons.collections4.OrderedMapIterator; 021 022/** 023 * Provides a base decorator that enables additional functionality to be added 024 * to an OrderedBidiMap via decoration. 025 * <p> 026 * Methods are forwarded directly to the decorated map. 027 * <p> 028 * This implementation does not perform any special processing with the map views. 029 * Instead it simply returns the inverse from the wrapped map. This may be 030 * undesirable, for example if you are trying to write a validating implementation 031 * it would provide a loophole around the validation. 032 * But, you might want that loophole, so this class is kept simple. 033 * 034 * @since 3.0 035 * @version $Id: AbstractOrderedBidiMapDecorator.html 972421 2015-11-14 20:00:04Z tn $ 036 */ 037public abstract class AbstractOrderedBidiMapDecorator<K, V> 038 extends AbstractBidiMapDecorator<K, V> 039 implements OrderedBidiMap<K, V> { 040 041 /** 042 * Constructor that wraps (not copies). 043 * 044 * @param map the map to decorate, must not be null 045 * @throws IllegalArgumentException if the collection is null 046 */ 047 protected AbstractOrderedBidiMapDecorator(final OrderedBidiMap<K, V> map) { 048 super(map); 049 } 050 051 /** 052 * Gets the map being decorated. 053 * 054 * @return the decorated map 055 */ 056 @Override 057 protected OrderedBidiMap<K, V> decorated() { 058 return (OrderedBidiMap<K, V>) super.decorated(); 059 } 060 061 //----------------------------------------------------------------------- 062 @Override 063 public OrderedMapIterator<K, V> mapIterator() { 064 return decorated().mapIterator(); 065 } 066 067 public K firstKey() { 068 return decorated().firstKey(); 069 } 070 071 public K lastKey() { 072 return decorated().lastKey(); 073 } 074 075 public K nextKey(final K key) { 076 return decorated().nextKey(key); 077 } 078 079 public K previousKey(final K key) { 080 return decorated().previousKey(key); 081 } 082 083 @Override 084 public OrderedBidiMap<V, K> inverseBidiMap() { 085 return decorated().inverseBidiMap(); 086 } 087 088}