EMMA Coverage Report (generated Mon Aug 23 17:21:34 CEST 2010)
[all classes][dmg.util]

COVERAGE SUMMARY FOR SOURCE FILE [CollectionFactory.java]

nameclass, %method, %block, %line, %
CollectionFactory.java100% (1/1)33%  (3/9)34%  (12/35)30%  (3/10)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CollectionFactory100% (1/1)33%  (3/9)34%  (12/35)30%  (3/10)
CollectionFactory (): void 0%   (0/1)0%   (0/3)0%   (0/2)
newArrayList (): List 0%   (0/1)0%   (0/4)0%   (0/1)
newHashSet (): Set 0%   (0/1)0%   (0/4)0%   (0/1)
newLinkedBlockingQueue (): BlockingQueue 0%   (0/1)0%   (0/4)0%   (0/1)
newTreeMap (): SortedMap 0%   (0/1)0%   (0/4)0%   (0/1)
newTreeSet (): SortedSet 0%   (0/1)0%   (0/4)0%   (0/1)
newConcurrentHashMap (): Map 100% (1/1)100% (4/4)100% (1/1)
newCopyOnWriteArrayList (): List 100% (1/1)100% (4/4)100% (1/1)
newHashMap (): Map 100% (1/1)100% (4/4)100% (1/1)

1package dmg.util;
2 
3import java.util.Map;
4import java.util.List;
5import java.util.Set;
6import java.util.SortedSet;
7import java.util.SortedMap;
8import java.util.HashMap;
9import java.util.HashSet;
10import java.util.TreeMap;
11import java.util.TreeSet;
12import java.util.ArrayList;
13import java.util.concurrent.CopyOnWriteArrayList;
14import java.util.concurrent.ConcurrentHashMap;
15import java.util.concurrent.BlockingQueue;
16import java.util.concurrent.LinkedBlockingQueue;
17 
18/**
19 * Utility class containing static factory methods for common Java
20 * collections. Using the factory methods avoids the problem that Java
21 * does not support type inference for constructors. The following would
22 * give a compiler warning:
23 *
24 *    List<String> l = new ArrayList();
25 *
26 * however using the factory method avoids the warning:
27 *
28 *    List<String> l = CollectionFactory.newArrayList();
29 *
30 * The alternative would be to use:
31 *
32 *    List<String> l = new ArrayList<String>();
33 *
34 * This does however violate the DRY principle, as the type needs to
35 * be repeated.
36 */
37public class CollectionFactory
38{
39    private CollectionFactory()
40    {
41    }
42 
43    public static <K,V> Map<K,V> newHashMap()
44    {
45        return new HashMap<K,V>();
46    }
47 
48    public static <K,V> SortedMap<K,V> newTreeMap()
49    {
50        return new TreeMap<K,V>();
51    }
52 
53    public static <K,V> Map<K,V> newConcurrentHashMap()
54    {
55        return new ConcurrentHashMap<K,V>();
56    }
57 
58    public static <V> Set<V> newHashSet()
59    {
60        return new HashSet<V>();
61    }
62 
63    public static <V> SortedSet<V> newTreeSet()
64    {
65        return new TreeSet<V>();
66    }
67 
68    public static <V> List<V> newArrayList()
69    {
70        return new ArrayList<V>();
71    }
72 
73    public static <V> List<V> newCopyOnWriteArrayList()
74    {
75        return new CopyOnWriteArrayList<V>();
76    }
77 
78    public static <V> BlockingQueue<V> newLinkedBlockingQueue()
79    {
80        return new LinkedBlockingQueue<V>();
81    }
82}

[all classes][dmg.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov