View Javadoc

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