|
17 | 17 |
|
18 | 18 | @SuppressWarnings("unused") |
19 | 19 | public class DoubleHashMap<K, V1, V2> extends HashMap<K, Doublet<V1, V2>> { |
20 | | - /** |
21 | | - * Associates the specified key with the specified values in this map. |
22 | | - * If the map previously contained a mapping for the key, the old value is replaced. |
23 | | - * |
24 | | - * @param key the key with which the specified values are to be associated |
25 | | - * @param value1 the first value to be associated with the specified key |
26 | | - * @param value2 the second value to be associated with the specified key |
27 | | - */ |
28 | | - public void put(K key, V1 value1, V2 value2) { |
29 | | - super.put(key, new Doublet<>(value1, value2)); |
30 | | - } |
| 20 | + /** |
| 21 | + * Associates the specified key with the specified values in this map. |
| 22 | + * If the map previously contained a mapping for the key, the old value is replaced. |
| 23 | + * |
| 24 | + * @param key the key with which the specified values are to be associated |
| 25 | + * @param value1 the first value to be associated with the specified key |
| 26 | + * @param value2 the second value to be associated with the specified key |
| 27 | + */ |
| 28 | + public void put(K key, V1 value1, V2 value2) { |
| 29 | + super.put(key, new Doublet<>(value1, value2)); |
| 30 | + } |
31 | 31 |
|
32 | | - /** |
33 | | - * Returns the first value to which the specified key is mapped, |
34 | | - * or null if this map contains no mapping for the key. |
35 | | - * |
36 | | - * @param key the key whose associated first value is to be returned |
37 | | - * @return the first value to which the specified key is mapped, or |
38 | | - * null if this map contains no mapping for the key |
39 | | - * @throws NullPointerException if the mapping for the key is null |
40 | | - */ |
41 | | - public V1 getValue1(K key) { |
42 | | - return get(key).getKey(); |
43 | | - } |
| 32 | + /** |
| 33 | + * Returns the first value to which the specified key is mapped, |
| 34 | + * or null if this map contains no mapping for the key. |
| 35 | + * |
| 36 | + * @param key the key whose associated first value is to be returned |
| 37 | + * @return the first value to which the specified key is mapped, or |
| 38 | + * null if this map contains no mapping for the key |
| 39 | + * @throws NullPointerException if the mapping for the key is null |
| 40 | + */ |
| 41 | + public V1 getValue1(K key) { |
| 42 | + return get(key).getKey(); |
| 43 | + } |
44 | 44 |
|
45 | | - /** |
46 | | - * Returns the second value to which the specified key is mapped, |
47 | | - * or null if this map contains no mapping for the key. |
48 | | - * |
49 | | - * @param key the key whose associated second value is to be returned |
50 | | - * @return the second value to which the specified key is mapped, or |
51 | | - * null if this map contains no mapping for the key |
52 | | - * @throws NullPointerException if the mapping for the key is null |
53 | | - */ |
54 | | - public V2 getValue2(K key) { |
55 | | - return get(key).getValue(); |
56 | | - } |
| 45 | + /** |
| 46 | + * Returns the second value to which the specified key is mapped, |
| 47 | + * or null if this map contains no mapping for the key. |
| 48 | + * |
| 49 | + * @param key the key whose associated second value is to be returned |
| 50 | + * @return the second value to which the specified key is mapped, or |
| 51 | + * null if this map contains no mapping for the key |
| 52 | + * @throws NullPointerException if the mapping for the key is null |
| 53 | + */ |
| 54 | + public V2 getValue2(K key) { |
| 55 | + return get(key).getValue(); |
| 56 | + } |
57 | 57 |
|
58 | | - /** |
59 | | - * Returns a collection view of the first values contained in this map. |
60 | | - * The collection is backed by the map, so changes to the map are reflected in the collection. |
61 | | - * |
62 | | - * @return a collection view of the first values contained in this map |
63 | | - */ |
64 | | - public Collection<V1> values1() { |
65 | | - return values().stream().map(Doublet::getKey).collect(Collectors.toList()); |
66 | | - } |
| 58 | + /** |
| 59 | + * Returns a collection view of the first values contained in this map. |
| 60 | + * The collection is backed by the map, so changes to the map are reflected in the collection. |
| 61 | + * |
| 62 | + * @return a collection view of the first values contained in this map |
| 63 | + */ |
| 64 | + public Collection<V1> values1() { |
| 65 | + return values().stream().map(Doublet::getKey).collect(Collectors.toList()); |
| 66 | + } |
67 | 67 |
|
68 | | - /** |
69 | | - * Returns a collection view of the second values contained in this map. |
70 | | - * The collection is backed by the map, so changes to the map are reflected in the collection. |
71 | | - * |
72 | | - * @return a collection view of the second values contained in this map |
73 | | - */ |
74 | | - public Collection<V2> values2() { |
75 | | - return values().stream().map(Doublet::getValue).collect(Collectors.toList()); |
76 | | - } |
| 68 | + /** |
| 69 | + * Returns a collection view of the second values contained in this map. |
| 70 | + * The collection is backed by the map, so changes to the map are reflected in the collection. |
| 71 | + * |
| 72 | + * @return a collection view of the second values contained in this map |
| 73 | + */ |
| 74 | + public Collection<V2> values2() { |
| 75 | + return values().stream().map(Doublet::getValue).collect(Collectors.toList()); |
| 76 | + } |
77 | 77 | } |
78 | | - |
0 commit comments