File D:\maven-qcr-plugin-testsunitaires\qcr4java\h2-1.3.170-sources\target\site\qc\lecode\util\New.java.html

1 /*
2 * Copyright 2004-2011 H2 Group. Multiple-Licensed under the H2 License,
3 * Version 1.0, and under the Eclipse Public License, Version 1.0
4 * (http://h2database.com/html/license.html).
5 * Initial Developer: H2 Group
6 */
7 package org.h2.util;
8
9 import java.util.ArrayList;
10 import java.util.Collection;
11 import java.util.HashMap;
12 import java.util.HashSet;
13
14 /**
15 * This class contains static methods to construct commonly used generic objects
16 * such as ArrayList.
17 */
18 public class New {
19
20 /**
21 * Create a new ArrayList.
22 *
23 * @param <T> the type
24 * @return the object
25 */
26 public static <T> ArrayList<T> arrayList() {
27 return new ArrayList<T>(4);
28 }
29
30 /**
31 * Create a new HashMap.
32 *
33 * @param <K> the key type
34 * @param <V> the value type
35 * @return the object
36 */
37 public static <K, V> HashMap<K, V> hashMap() {
38 return new HashMap<K, V>();
39 }
40
41 /**
42 * Create a new HashMap.
43 *
44 * @param <K> the key type
45 * @param <V> the value type
46 * @param initialCapacity the initial capacity
47 * @return the object
48 */
49 public static <K, V> HashMap<K, V> hashMap(int initialCapacity) {
50 return new HashMap<K, V>(initialCapacity);
51 }
52
53 /**
54 * Create a new HashSet.
55 *
56 * @param <T> the type
57 * @return the object
58 */
59 public static <T> HashSet<T> hashSet() {
60 return new HashSet<T>();
61 }
62
63 /**
64 * Create a new ArrayList.
65 *
66 * @param <T> the type
67 * @param c the collection
68 * @return the object
69 */
70 public static <T> ArrayList<T> arrayList(Collection<T> c) {
71 return new ArrayList<T>(c);
72 }
73
74 /**
75 * Create a new ArrayList.
76 *
77 * @param <T> the type
78 * @param initialCapacity the initial capacity
79 * @return the object
80 */
81 public static <T> ArrayList<T> arrayList(int initialCapacity) {
82 return new ArrayList<T>(initialCapacity);
83 }
84
85 }
86