1 package com.atlassian.util.concurrent;
2
3 import java.util.Comparator;
4 import java.util.HashMap;
5 import java.util.LinkedHashMap;
6 import java.util.Map;
7 import java.util.TreeMap;
8
9 /**
10 * Static factory methods for creating {@link CopyOnWriteMap} and
11 * {@link CopyOnWriteSortedMap} instances.
12 *
13 * @author Jed Wesley-Smith
14 * @deprecated use the static factory methods is {@link CopyOnWriteMap} and
15 * {@link CopyOnWriteSortedMap} directly.
16 */
17 @Deprecated
18 // /CLOVER:OFF
19 public class CopyOnWriteMaps {
20 /**
21 * Creates a new {@link CopyOnWriteMap} with an underlying {@link HashMap}.
22 *
23 * @deprecated use the {@link CopyOnWriteMap#newHashMap()} instead.
24 */
25 @Deprecated
26 public static <K, V> CopyOnWriteMap<K, V> newHashMap() {
27 return CopyOnWriteMap.newHashMap();
28 }
29
30 /**
31 * Creates a new {@link CopyOnWriteMap} with an underlying {@link HashMap}
32 * using the supplied map as the initial values.
33 *
34 * @deprecated use the {@link CopyOnWriteMap#newHashMap(Map)} instead.
35 */
36 @Deprecated
37 public static <K, V> CopyOnWriteMap<K, V> newHashMap(final Map<? extends K, ? extends V> map) {
38 return CopyOnWriteMap.newHashMap(map);
39 }
40
41 /**
42 * Creates a new {@link CopyOnWriteMap} with an underlying
43 * {@link LinkedHashMap}. Iterators for this map will be return elements in
44 * insertion order.
45 *
46 * @deprecated use the {@link CopyOnWriteMap#newLinkedMap()} instead.
47 */
48 @Deprecated
49 public static <K, V> CopyOnWriteMap<K, V> newLinkedMap() {
50 return CopyOnWriteMap.newLinkedMap();
51 }
52
53 /**
54 * Creates a new {@link CopyOnWriteMap} with an underlying
55 * {@link LinkedHashMap} using the supplied map as the initial values.
56 * Iterators for this map will be return elements in insertion order.
57 *
58 * @deprecated use the {@link CopyOnWriteMap#newLinkedMap(Map)} instead.
59 */
60 @Deprecated
61 public static <K, V> CopyOnWriteMap<K, V> newLinkedMap(final Map<? extends K, ? extends V> map) {
62 return CopyOnWriteMap.newLinkedMap(map);
63 }
64
65 //
66 // sorted maps
67 //
68
69 /**
70 * Create a new {@link CopyOnWriteSortedMap} where the underlying map
71 * instances are {@link TreeMap} and the sort uses the key's natural order.
72 *
73 * @deprecated use {@link CopyOnWriteSortedMap#newTreeMap()} instead.
74 */
75 @Deprecated
76 public static <K, V> CopyOnWriteSortedMap<K, V> newTreeMap() {
77 return CopyOnWriteSortedMap.newTreeMap();
78 }
79
80 /**
81 * Create a new {@link CopyOnWriteSortedMap} where the underlying map
82 * instances are {@link TreeMap}, the sort uses the key's natural order and
83 * the initial values are supplied.
84 *
85 * @param map the map to use as the initial values.
86 * @deprecated use {@link CopyOnWriteSortedMap#newTreeMap(Map)} instead.
87 */
88 @Deprecated
89 public static <K, V> CopyOnWriteSortedMap<K, V> newTreeMap(final Map<? extends K, ? extends V> map) {
90 return CopyOnWriteSortedMap.newTreeMap(map);
91 }
92
93 /**
94 * Create a new {@link CopyOnWriteSortedMap} where the underlying map
95 * instances are {@link TreeMap}.
96 *
97 * @param comparator the Comparator to use for ordering the keys.
98 * @deprecated use {@link CopyOnWriteSortedMap#newTreeMap(Comparator)}
99 * instead.
100 */
101 @Deprecated
102 public static <K, V> CopyOnWriteSortedMap<K, V> newTreeMap(final Comparator<? super K> comparator) {
103 return CopyOnWriteSortedMap.newTreeMap(comparator);
104 }
105
106 /**
107 * Create a new {@link CopyOnWriteSortedMap} where the underlying map
108 * instances are {@link TreeMap}, the sort uses the key's natural order and
109 * the initial values are supplied.
110 *
111 * @param map to use as the initial values.
112 * @param comparator for ordering.
113 * @deprecated use {@link CopyOnWriteSortedMap#newTreeMap(Map, Comparator)}
114 * instead.
115 */
116 @Deprecated
117 public static <K, V> CopyOnWriteSortedMap<K, V> newTreeMap(final Map<? extends K, ? extends V> map, final Comparator<? super K> comparator) {
118 return CopyOnWriteSortedMap.newTreeMap(map, comparator);
119 }
120 }
121 // /CLOVER:ON