blob: ee708fd46f248f4124648aaf63bf1c69cfd3e4ff [file] [log] [blame]
Stuart McCullochbb014372012-06-07 21:57:32 +00001package aQute.libg.generics;
2
3import java.util.*;
4
5public class Create {
6
7 public static <K,V> Map<K, V> map() {
8 return new LinkedHashMap<K,V>();
9 }
10
11 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 }
14
15 public static <T> List<T> list() {
16 return new ArrayList<T>();
17 }
18
19 public static <T> List<T> list(Class<T> c) {
20 return Collections.checkedList(new ArrayList<T>(),c) ;
21 }
22
23 public static <T> Set<T> set() {
24 return new HashSet<T>();
25 }
26
27 public static <T> Set<T> set(Class<T> c) {
28 return Collections.checkedSet(new HashSet<T>(),c);
29 }
30
31 public static <T> List<T> list(T[] source) {
32 return new ArrayList<T>(Arrays.asList(source));
33 }
34
35 public static <T> Set<T> set(T[]source) {
36 return new HashSet<T>(Arrays.asList(source));
37 }
38
39 public static <K,V> Map<K, V> copy(Map<K,V> source) {
40 return new LinkedHashMap<K,V>(source);
41 }
42
43 public static <T> List<T> copy(List<T> source) {
44 return new ArrayList<T>(source);
45 }
46
47 public static <T> Set<T> copy(Collection<T> source) {
48 if ( source == null )
49 return set();
50 return new HashSet<T>(source);
51 }
52
53
54}