View Javadoc
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 Number extends AbstractCounter
12  {
13  
14      private double value = 0.0;
15  
16      public Number(String name)
17      {
18          super(name, Type.NUMBER);
19      }
20  
21      public synchronized double increment()
22      {
23          this.value++;
24          propagate();
25          return this.value;
26      }
27  
28      public synchronized double incrementBy(double value)
29      {
30          this.value += value;
31          propagate();
32          return this.value;
33      }
34  
35      public synchronized double decrement()
36      {
37          this.value--;
38          propagate();
39          return this.value;
40      }
41  
42      public synchronized void setRawValue(double value)
43      {
44          this.value = value;
45          propagate();
46      }
47  
48      public synchronized double nextValue()
49      {
50          return this.value;
51      }
52  
53  }