EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.fzi.se.quality.util]

COVERAGE SUMMARY FOR SOURCE FILE [EMFHelper.java]

nameclass, %method, %block, %line, %
EMFHelper.java0%   (0/1)0%   (0/3)0%   (0/50)0%   (0/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class EMFHelper0%   (0/1)0%   (0/3)0%   (0/50)0%   (0/15)
EMFHelper (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getFirstObjectByType (List, Class): Object 0%   (0/1)0%   (0/19)0%   (0/6)
getObjectsByType (List, Class): List 0%   (0/1)0%   (0/28)0%   (0/8)

1/**
2 *
3 */
4package de.fzi.se.quality.util;
5 
6import java.util.ArrayList;
7import java.util.Collections;
8import java.util.Iterator;
9import java.util.List;
10 
11/**Class with helper function for EMF processing.
12 *
13 * @author groenda
14 */
15public class EMFHelper {
16 
17        /**Gets the first object of a given type from a list.
18         * @param <T> Type of the Object.
19         * @param collection List of objects.
20         * @param c Class of the requested object.
21         * @return The first object in the list of the given type.
22         */
23        @SuppressWarnings("unchecked")
24        public static <T> T getFirstObjectByType(List<?> collection, Class<T> c) {
25                Iterator<?> i = collection.iterator();
26                Object o = null;
27                while ((o = i.next()) != null) {
28                        if (c.isAssignableFrom(o.getClass()))
29                                break;
30                }
31                return (T) o;
32        }
33 
34        /**Gets all objects of a given type from a list.
35         * @param <T> Type of the Object.
36         * @param collection List of objects.
37         * @param c Class of the requested object.
38         * @return The first object in the list of the given type.
39         */
40        @SuppressWarnings("unchecked")
41        public static <T> List<T> getObjectsByType(List<?> collection, Class<T> c) {
42                List<T> list = new ArrayList<T>();
43                Iterator<?> i = collection.iterator();
44                Object o = null;
45                while (i.hasNext()) {
46                        o = i.next();
47                        if (c.isAssignableFrom(o.getClass())) {
48                                list.add((T) o);
49                        }
50                }
51                return Collections.unmodifiableList(list);
52        }
53 
54}

[all classes][de.fzi.se.quality.util]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov