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.SortedMap;
20 import java.util.TreeMap;
21
22 import org.apache.commons.collections4.OrderedBidiMap;
23
24 /**
25 * Test class for AbstractOrderedBidiMapDecorator.
26 *
27 * @param <K> the type of the keys in this map
28 * @param <V> the type of the values in this map
29 */
30 public abstract class AbstractOrderedBidiMapDecoratorTest<K, V>
31 extends AbstractOrderedBidiMapTest<K, V> {
32
33 /**
34 * Simple class to actually test.
35 */
36 private static final class TestOrderedBidiMap<K, V> extends AbstractOrderedBidiMapDecorator<K, V> {
37
38 private TestOrderedBidiMap<V, K> inverse;
39
40 TestOrderedBidiMap() {
41 super(new DualTreeBidiMap<>());
42 }
43
44 TestOrderedBidiMap(final OrderedBidiMap<K, V> map) {
45 super(map);
46 }
47
48 @Override
49 public OrderedBidiMap<V, K> inverseBidiMap() {
50 if (inverse == null) {
51 inverse = new TestOrderedBidiMap<>(decorated().inverseBidiMap());
52 inverse.inverse = this;
53 }
54 return inverse;
55 }
56 }
57
58 @Override
59 public boolean isAllowNullKey() {
60 return false;
61 }
62
63 @Override
64 public boolean isAllowNullValueGet() {
65 return false;
66 }
67
68 @Override
69 public boolean isAllowNullValuePut() {
70 return false;
71 }
72
73 @Override
74 public boolean isSetValueSupported() {
75 return true;
76 }
77
78 @Override
79 public SortedMap<K, V> makeConfirmedMap() {
80 return new TreeMap<>();
81 }
82
83 /**
84 * {@inheritDoc}
85 */
86 @Override
87 public OrderedBidiMap<K, V> makeObject() {
88 return new TestOrderedBidiMap<>();
89 }
90 }