blob: 3e071b3b03938e274bd59b30fdc92039f18682ca [file] [log] [blame]
Stuart McCullochbb014372012-06-07 21:57:32 +00001package aQute.libg.generics;
2
3import java.util.*;
4
5public class Create {
Stuart McCullochbb014372012-06-07 21:57:32 +00006
Stuart McCulloch2286f232012-06-15 13:27:53 +00007 public static <K, V> Map<K,V> map() {
8 return new LinkedHashMap<K,V>();
9 }
Stuart McCullochbb014372012-06-07 21:57:32 +000010
Stuart McCulloch2286f232012-06-15 13:27:53 +000011 public static <K, V> Map<K,V> map(Class<K> key, Class<V> value) {
12 return Collections.checkedMap(new LinkedHashMap<K,V>(), key, value);
13 }
Stuart McCullochbb014372012-06-07 21:57:32 +000014
Stuart McCulloch2286f232012-06-15 13:27:53 +000015 public static <T> List<T> list() {
16 return new ArrayList<T>();
17 }
Stuart McCullochbb014372012-06-07 21:57:32 +000018
Stuart McCulloch2286f232012-06-15 13:27:53 +000019 public static <T> List<T> list(Class<T> c) {
20 return Collections.checkedList(new ArrayList<T>(), c);
21 }
Stuart McCullochbb014372012-06-07 21:57:32 +000022
Stuart McCulloch2286f232012-06-15 13:27:53 +000023 public static <T> Set<T> set() {
24 return new HashSet<T>();
25 }
Stuart McCullochbb014372012-06-07 21:57:32 +000026
Stuart McCulloch2286f232012-06-15 13:27:53 +000027 public static <T> Set<T> set(Class<T> c) {
28 return Collections.checkedSet(new HashSet<T>(), c);
29 }
Stuart McCullochbb014372012-06-07 21:57:32 +000030
Stuart McCulloch2286f232012-06-15 13:27:53 +000031 public static <T> List<T> list(T[] source) {
32 return new ArrayList<T>(Arrays.asList(source));
33 }
Stuart McCullochbb014372012-06-07 21:57:32 +000034
Stuart McCulloch2286f232012-06-15 13:27:53 +000035 public static <T> Set<T> set(T[] source) {
36 return new HashSet<T>(Arrays.asList(source));
37 }
Stuart McCullochbb014372012-06-07 21:57:32 +000038
Stuart McCulloch2286f232012-06-15 13:27:53 +000039 public static <K, V> Map<K,V> copy(Map<K,V> source) {
40 return new LinkedHashMap<K,V>(source);
41 }
Stuart McCullochbb014372012-06-07 21:57:32 +000042
Stuart McCulloch2286f232012-06-15 13:27:53 +000043 public static <T> List<T> copy(List<T> source) {
44 return new ArrayList<T>(source);
45 }
Stuart McCullochbb014372012-06-07 21:57:32 +000046
Stuart McCulloch2286f232012-06-15 13:27:53 +000047 public static <T> Set<T> copy(Collection<T> source) {
48 if (source == null)
49 return set();
50 return new HashSet<T>(source);
51 }
52
Stuart McCullochbb014372012-06-07 21:57:32 +000053}