01: /*
02: * $Id: Counter.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;
12:
13: /**
14: * This interface is the interface implemented for all counter types. A Counter can
15: * represent a real counter or a virtual counter that will be computed using one or
16: * more other counters.<br/>
17: * <h3>Real counters</h3>
18: * are counters which represent real values. The user will call methods of such
19: * counters to modify the associated value of the counter.
20: * <h3>Computed counters</h3>
21: * are computed using one or more associated counters. Such counters represent
22: * operations computed on associated counters. Usually, these counters will never be
23: * used directly, but will only used to retrieve the computed values.
24: */
25: public interface Counter {
26:
27: /**
28: * Accessor for the counter type.
29: *
30: * @return the type of the counter
31: */
32: CounterFactory.Type getType();
33:
34: /**
35: * Accessor for the counter's name.
36: *
37: * @return the name of the counter
38: */
39: String getName();
40:
41: /**
42: * Increment the counter's value by 1.0.
43: *
44: * @return the new value of the counter
45: */
46: double increment();
47:
48: /**
49: * Increment the counter's value by the specified amount.
50: *
51: * @param value the amount to increment the counter by
52: * @return the new value of the counter
53: */
54: double incrementBy(double value);
55:
56: /**
57: * Decrement the counter's value by 1.0.
58: *
59: * @return the new value of the counter
60: */
61: double decrement();
62:
63: /**
64: * Set the counter's value to a new value.
65: *
66: * @param value the new value of the counter
67: */
68: void setRawValue(double value);
69:
70: /**
71: * Compute and return the value of the counter.
72: *
73: * @return the value of the counter
74: */
75: double nextValue();
76:
77: }
|