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.sampled;
18  
19  import java.io.Serializable;
20  
21  /***
22   * A counter value at a particular time instance
23   * 
24   * @author <a href="mailto:asanoujam@terracottatech.com">Abhishek Sanoujam</a>
25   * @since 1.7
26   */
27  public class TimeStampedCounterValue implements Serializable {
28      private final long counterValue;
29      private final long timestamp;
30  
31      /***
32       * Constructor accepting the value of both timestamp and the counter value.
33       * 
34       * @param timestamp
35       * @param value
36       */
37      public TimeStampedCounterValue(long timestamp, long value) {
38          this.timestamp = timestamp;
39          this.counterValue = value;
40      }
41  
42      /***
43       * Get the counter value
44       * 
45       * @return The counter value
46       */
47      public long getCounterValue() {
48          return this.counterValue;
49      }
50  
51      /***
52       * Get value of the timestamp
53       * 
54       * @return the timestamp associated with the current value
55       */
56      public long getTimestamp() {
57          return this.timestamp;
58      }
59  
60      /***
61       * {@inheritDoc}
62       */
63      @Override
64      public String toString() {
65          return "value: " + this.counterValue + ", timestamp: " + this.timestamp;
66      }
67  
68  }