01: /*
02: * $Id: Number.java 8077 2007-08-27 20:15:25Z aperepel $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.util.counters.impl;
12:
13: import org.mule.util.counters.CounterFactory.Type;
14:
15: public class Number extends AbstractCounter {
16:
17: private double value = 0.0;
18:
19: public Number(String name) {
20: super (name, Type.NUMBER);
21: }
22:
23: public synchronized double increment() {
24: this .value++;
25: propagate();
26: return this .value;
27: }
28:
29: public synchronized double incrementBy(double value) {
30: this .value += value;
31: propagate();
32: return this .value;
33: }
34:
35: public synchronized double decrement() {
36: this .value--;
37: propagate();
38: return this .value;
39: }
40:
41: public synchronized void setRawValue(double value) {
42: this .value = value;
43: propagate();
44: }
45:
46: public synchronized double nextValue() {
47: return this.value;
48: }
49:
50: }
|