Coverage Report - net.admin4j.vo.DataMeasurementSummaryVO
 
Classes in this File Line Coverage Branch Coverage Complexity
DataMeasurementSummaryVO
100%
44/44
N/A
1
DataMeasurementSummaryVO$SummaryType
100%
1/1
N/A
1
 
 1  
 /*
 2  
  * This software is licensed under the Apache License, Version 2.0
 3  
  * (the "License") agreement; you may not use this file except in compliance with
 4  
  * the License.  You may obtain a copy of the License at
 5  
  * 
 6  
  *      http://www.apache.org/licenses/LICENSE-2.0
 7  
  * 
 8  
  * Unless required by applicable law or agreed to in writing, software
 9  
  * distributed under the License is distributed on an "AS IS" BASIS,
 10  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 11  
  * See the License for the specific language governing permissions and
 12  
  * limitations under the License.
 13  
  */
 14  
 package net.admin4j.vo;
 15  
 
 16  
 import java.util.Date;
 17  
 import java.util.List;
 18  
 
 19  
 import net.admin4j.util.NumberUtils;
 20  
 
 21  
 /**
 22  
  * Summarizes measurements taken by Task Timers.
 23  
  * @author D. Ashmore
 24  
  * @since 1.0
 25  
  */
 26  109
 public class DataMeasurementSummaryVO extends BaseVO {
 27  
     
 28  
     private static final long serialVersionUID = -7268348308380468547L;
 29  
     private String label;
 30  
     private SummaryType summaryType;
 31  
     private Number minimum;
 32  
     private Number maximum;
 33  
     private Number total;
 34  
     private Long nbrDataItems;
 35  
     private Double average;
 36  
     private Double variance;
 37  
     private Double standardDeviation;
 38  
     private Date firstObservationDate;
 39  
     private Date lastObservationDate;
 40  
     
 41  109
     public static enum SummaryType {SUMMARY, ROLLING_TIME, ROLLING_NBR_OBS};
 42  
     
 43  
     public Number getMinimum() {
 44  12
         return minimum;
 45  
     }
 46  
     
 47  
     public void setMinimum(Number minimum) {
 48  79
         this.minimum = minimum;
 49  79
     }
 50  
     
 51  
     public Number getMaximum() {
 52  12
         return maximum;
 53  
     }
 54  
     
 55  
     public void setMaximum(Number maximum) {
 56  79
         this.maximum = maximum;
 57  79
     }
 58  
     
 59  
     public Number getTotal() {
 60  12
         return total;
 61  
     }
 62  
     
 63  
     public void setTotal(Number total) {
 64  82
         this.total = total;
 65  82
     }
 66  
     
 67  
     public Long getNbrDataItems() {
 68  66
         return nbrDataItems;
 69  
     }
 70  
     
 71  
     public void setNbrDataItems(Long nbrDataItems) {
 72  82
         this.nbrDataItems = nbrDataItems;
 73  82
     }
 74  
     
 75  
     public Double getAverage() {
 76  64
         return average;
 77  
     }
 78  
     
 79  
     public void setAverage(Double average) {
 80  79
         this.average = average;
 81  79
     }
 82  
     
 83  
     public Double getVariance() {
 84  64
         return variance;
 85  
     }
 86  
     
 87  
     public void setVariance(Double variance) {
 88  79
         this.variance = variance;
 89  79
     }
 90  
     
 91  
     public Double getStandardDeviation() {
 92  12
         return standardDeviation;
 93  
     }
 94  
     
 95  
     public void setStandardDeviation(Double standardDeviation) {
 96  79
         this.standardDeviation = standardDeviation;
 97  79
     }
 98  
     
 99  
     public static DataMeasurementSummaryVO fromValueList(List<Number> valueList) {
 100  15
         DataMeasurementSummaryVO summary = new DataMeasurementSummaryVO();
 101  
         
 102  15
         summary.setMinimum(NumberUtils.min(valueList));
 103  15
         summary.setMaximum(NumberUtils.max(valueList));
 104  15
         summary.setNbrDataItems(Long.valueOf(valueList.size()));
 105  15
         summary.setAverage(NumberUtils.average(valueList).doubleValue());
 106  15
         summary.setTotal(NumberUtils.sum(valueList));
 107  15
         summary.setStandardDeviation(NumberUtils.standardDeviation(valueList).doubleValue());
 108  15
         summary.setVariance(NumberUtils.variance(valueList).doubleValue());
 109  
         
 110  15
         return summary;
 111  
     }
 112  
 
 113  
     public String getLabel() {
 114  66
         return label;
 115  
     }
 116  
 
 117  
     public void setLabel(String label) {
 118  134
         this.label = label;
 119  134
     }
 120  
 
 121  
     public SummaryType getSummaryType() {
 122  18
         return summaryType;
 123  
     }
 124  
 
 125  
     public void setSummaryType(SummaryType summaryType) {
 126  88
         this.summaryType = summaryType;
 127  88
     }
 128  
 
 129  
     public Date getFirstObservationDate() {
 130  12
         return firstObservationDate;
 131  
     }
 132  
 
 133  
     public void setFirstObservationDate(Date firstObservationDate) {
 134  70
         this.firstObservationDate = firstObservationDate;
 135  70
     }
 136  
 
 137  
     public Date getLastObservationDate() {
 138  12
         return lastObservationDate;
 139  
     }
 140  
 
 141  
     public void setLastObservationDate(Date lastObservationDate) {
 142  70
         this.lastObservationDate = lastObservationDate;
 143  70
     }
 144  
 
 145  
 }