View Javadoc

1   /***
2    *  Copyright 2003-2010 Terracotta, Inc.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  
17  package net.sf.ehcache.util.counter;
18  
19  /***
20   * Config for a simple Counter
21   * 
22   * @author <a href="mailto:asanoujam@terracottatech.com">Abhishek Sanoujam</a>
23   * @since 1.7
24   * 
25   */
26  public class CounterConfig {
27  
28      private final long initialValue;
29  
30      /***
31       * Creates a config with the initial value
32       * 
33       * @param initialValue
34       */
35      public CounterConfig(long initialValue) {
36          this.initialValue = initialValue;
37      }
38  
39      /***
40       * Gets the initial value
41       * 
42       * @return the initial value of counters created by this config
43       */
44      public final long getInitialValue() {
45          return initialValue;
46      }
47  
48      /***
49       * Creates and returns a Counter based on the initial value
50       * 
51       * @return The counter created by this config
52       */
53      public Counter createCounter() {
54          return new CounterImpl(initialValue);
55      }
56  }