01 /*
02 * Created on Sep 4, 2007
03 */
04 package com.x8ing.mc.bp;
05
06 import java.util.ArrayList;
07 import java.util.Iterator;
08 import java.util.List;
09
10 /**
11 * List of bugs.
12 *
13 * @author Patrick Heusser
14 */
15 public class BugList {
16
17 private int bugIDCounter = 0;
18
19 /**
20 * type: Bug
21 */
22 private List bugs = new ArrayList();
23
24 public void addBug(Bug bug) {
25 bugs.add(bug);
26 }
27
28 public List getAllBugs() {
29 return bugs;
30 }
31
32 public int getNextBugID() {
33 return ++bugIDCounter;
34 }
35
36 public List getBugsWithState(Bug.BugState[] bugState) {
37 List ret = new ArrayList();
38
39 for (int i = 0; i < bugState.length; i++) {
40 Bug.BugState state = bugState[i];
41 ret.addAll(getBugsWithState(state));
42 }
43
44 return ret;
45 }
46
47 public List getBugsWithState(Bug.BugState bugState) {
48
49 List ret = new ArrayList();
50
51 for (Iterator it = bugs.iterator(); it.hasNext();) {
52 Bug bug = (Bug) it.next();
53 if (bug.getBugState().equals(bugState)) {
54 ret.add(bug);
55 }
56
57 }
58
59 return ret;
60
61 }
62
63 public List getBugsWithStateNew() {
64 return getBugsWithState(Bug.BugState.STATE_BUG_NEW);
65 }
66
67 public List getBugsWithStateFixed() {
68 return getBugsWithState(Bug.BugState.STATE_BUG_FIXED);
69 }
70
71 public List getBugsWithStateDeployed() {
72 return getBugsWithState(Bug.BugState.STATE_BUG_DEPLOYED);
73 }
74
75 public List getBugsWithStateFixLater() {
76 return getBugsWithState(Bug.BugState.STATE_BUG_FIX_LATER);
77 }
78
79 public List getBugsWithStateProductionTestFailed() {
80 return getBugsWithState(Bug.BugState.STATE_BUG_TEST_FAILED);
81 }
82
83 }
|