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