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