Coverage Report - com.google.code.jetm.maven.data.AggregateSummary
 
Classes in this File Line Coverage Branch Coverage Complexity
AggregateSummary
80%
16/20
N/A
1
 
 1  
 package com.google.code.jetm.maven.data;
 2  
 
 3  
 import java.util.Collections;
 4  
 import java.util.Map;
 5  
 
 6  
 import etm.core.aggregation.Aggregate;
 7  
 
 8  
 /**
 9  
  * A bean to store summary of aggregate data.
 10  
  * 
 11  
  * @author jrh3k5
 12  
  * 
 13  
  */
 14  
 
 15  0
 public class AggregateSummary implements Aggregate, Comparable<AggregateSummary> {
 16  4
     private double min = Double.MAX_VALUE;
 17  4
     private double max = Double.MIN_VALUE;
 18  
     private double total;
 19  
     private long measurements;
 20  
     private String name;
 21  
 
 22  
     /**
 23  
      * Create a summary.
 24  
      * 
 25  
      * @param name
 26  
      *            The name of the summary.
 27  
      */
 28  4
     public AggregateSummary(String name) {
 29  4
         this.name = name;
 30  4
     }
 31  
 
 32  
     /**
 33  
      * Add an aggregate to the summary.
 34  
      * 
 35  
      * @param aggregate
 36  
      *            The {@link Aggregate} to be added to the summary.
 37  
      */
 38  
     public void add(Aggregate aggregate) {
 39  2
         this.min = Math.min(aggregate.getMin(), getMin());
 40  2
         this.max = Math.max(aggregate.getMax(), getMax());
 41  2
         this.total += aggregate.getTotal();
 42  2
         this.measurements += aggregate.getMeasurements();
 43  2
     }
 44  
 
 45  
     /**
 46  
      * {@inheritDoc}
 47  
      */
 48  
     public int compareTo(AggregateSummary o) {
 49  4
         return getName().compareTo(o.getName());
 50  
     }
 51  
 
 52  
     /**
 53  
      * {@inheritDoc}
 54  
      */
 55  
     public double getAverage() {
 56  0
         return getTotal() / getMeasurements();
 57  
     }
 58  
 
 59  
     /**
 60  
      * {@inheritDoc}
 61  
      */
 62  
     @SuppressWarnings("rawtypes")
 63  
     public Map getChilds() {
 64  0
         return Collections.emptyMap();
 65  
     }
 66  
 
 67  
     /**
 68  
      * {@inheritDoc}
 69  
      */
 70  
     public double getMax() {
 71  3
         return max;
 72  
     }
 73  
 
 74  
     /**
 75  
      * {@inheritDoc}
 76  
      */
 77  
     public long getMeasurements() {
 78  1
         return measurements;
 79  
     }
 80  
 
 81  
     /**
 82  
      * {@inheritDoc}
 83  
      */
 84  
     public double getMin() {
 85  3
         return min;
 86  
     }
 87  
 
 88  
     /**
 89  
      * {@inheritDoc}
 90  
      */
 91  
     public String getName() {
 92  9
         return name;
 93  
     }
 94  
 
 95  
     /**
 96  
      * {@inheritDoc}
 97  
      */
 98  
     public double getTotal() {
 99  1
         return total;
 100  
     }
 101  
 
 102  
     /**
 103  
      * {@inheritDoc}
 104  
      */
 105  
     public boolean hasChilds() {
 106  0
         return false;
 107  
     }
 108  
 }