Coverage Report - org.mule.util.counters.impl.AbstractCounter
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractCounter
87%
13/15
100%
2/2
1.1
 
 1  
 /*
 2  
  * $Id: AbstractCounter.java 8077 2007-08-27 20:15:25Z aperepel $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.Counter;
 14  
 import org.mule.util.counters.CounterFactory.Type;
 15  
 
 16  
 import java.util.ArrayList;
 17  
 import java.util.Collections;
 18  
 import java.util.Iterator;
 19  
 import java.util.List;
 20  
 
 21  
 public abstract class AbstractCounter implements Counter
 22  
 {
 23  
 
 24  
     private final Type type;
 25  
     private final String name;
 26  
     private final List aggregates;
 27  
 
 28  
     public AbstractCounter(String name, Type type)
 29  
     {
 30  38
         super();
 31  38
         this.name = name;
 32  38
         this.type = type;
 33  38
         this.aggregates = Collections.synchronizedList(new ArrayList());
 34  38
     }
 35  
 
 36  
     public Type getType()
 37  
     {
 38  0
         return this.type;
 39  
     }
 40  
 
 41  
     public String getName()
 42  
     {
 43  0
         return this.name;
 44  
     }
 45  
 
 46  
     public abstract double increment();
 47  
 
 48  
     public abstract double incrementBy(double value);
 49  
 
 50  
     public abstract double decrement();
 51  
 
 52  
     public abstract void setRawValue(double value);
 53  
 
 54  
     public abstract double nextValue();
 55  
 
 56  
     protected void addAggregate(AggregateCounter counter)
 57  
     {
 58  26
         this.aggregates.add(counter);
 59  26
     }
 60  
 
 61  
     protected void propagate()
 62  
     {
 63  110
         Iterator it = this.aggregates.iterator();
 64  170
         while (it.hasNext())
 65  
         {
 66  60
             AggregateCounter agg = (AggregateCounter) it.next();
 67  60
             agg.compute();
 68  60
         }
 69  110
     }
 70  
 
 71  
 }