1 package org.codehaus.mojo.dashboard.report.plugin.beans;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.util.ArrayList;
20 import java.util.Collections;
21 import java.util.Date;
22 import java.util.List;
23
24 import org.codehaus.mojo.dashboard.report.plugin.beans.comparator.DescAfferentCouplingPackageComparator;
25
26
27
28
29
30
31 public class JDependReportBean extends AbstractReportBean
32 {
33
34
35
36 private double averageAfferentCoupling = 0;
37
38
39
40
41 private int nbPackages = 0;
42
43
44
45
46 private int sumAC = 0;
47
48
49
50
51 private List packages = new ArrayList();
52
53
54
55
56 public JDependReportBean()
57 {
58 }
59
60
61
62
63 public JDependReportBean( Date dateGeneration )
64 {
65 super( dateGeneration );
66 }
67
68 public int getNbPackages()
69 {
70 return nbPackages;
71 }
72
73 public void setNbPackages( int nbPackages )
74 {
75 this.nbPackages = nbPackages;
76 }
77
78 public int getSumAC()
79 {
80 return sumAC;
81 }
82
83 public void setSumAC( int sumAC )
84 {
85 this.sumAC = sumAC;
86 }
87
88 public double getAverageAfferentCoupling()
89 {
90 return averageAfferentCoupling;
91 }
92
93 public void setAverageAfferentCoupling( double averageAfferentCoupling )
94 {
95 this.averageAfferentCoupling = averageAfferentCoupling;
96 }
97
98
99
100
101
102 public void merge( IDashBoardReportBean dashboardReport )
103 {
104 if ( dashboardReport != null && dashboardReport instanceof JDependReportBean )
105 {
106 this.sumAC = this.sumAC + ( (JDependReportBean) dashboardReport ).getSumAC();
107 this.nbPackages = this.nbPackages + ( (JDependReportBean) dashboardReport ).getNbPackages();
108 if ( this.nbPackages == 0 )
109 {
110
111 this.averageAfferentCoupling = 0d;
112 }
113 else
114 {
115 this.averageAfferentCoupling = (double) this.sumAC / this.nbPackages;
116 }
117 this.packages.addAll( ( (JDependReportBean) dashboardReport ).getPackages() );
118
119 }
120 }
121
122 public List getPackages()
123 {
124 Collections.sort( this.packages, new DescAfferentCouplingPackageComparator() );
125 return packages;
126 }
127
128 public void setPackages( List packages )
129 {
130 this.packages = packages;
131 }
132
133
134
135
136
137 public void addPackage( XRefPackageBean pack )
138 {
139 this.packages.add( pack );
140 this.sumAC = this.sumAC + pack.getAfferentCoupling().intValue();
141 this.nbPackages = this.nbPackages + 1;
142 if ( this.nbPackages == 0 )
143 {
144
145 this.averageAfferentCoupling = 0d;
146 }
147 else
148 {
149 this.averageAfferentCoupling = (double) this.sumAC / this.nbPackages;
150 }
151 }
152
153 }