Coverage Report - org.mule.util.counters.impl.Average
 
Classes in this File Line Coverage Branch Coverage Complexity
Average
0%
0/8
0%
0/2
1
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.util.counters.impl;
 8  
 
 9  
 import org.mule.util.counters.CounterFactory.Type;
 10  
 
 11  
 public class Average extends AggregateCounter
 12  
 {
 13  
 
 14  0
     private double sum = 0;
 15  0
     private long times = 0;
 16  
 
 17  
     public Average(String name, AbstractCounter base)
 18  
     {
 19  0
         super(name, Type.AVERAGE, base);
 20  0
     }
 21  
 
 22  
     public double nextValue()
 23  
     {
 24  0
         return (times > 0) ? sum / times : 0;
 25  
     }
 26  
 
 27  
     public void doCompute()
 28  
     {
 29  0
         this.sum += getBase().nextValue();
 30  0
         this.times++;
 31  0
     }
 32  
 
 33  
 }