001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.monitoring.statistics;
016    
017    /**
018     * @author Rajesh Thiagarajan
019     * @author Brian Wing Shun Chan
020     */
021    public class CountStatistics extends BaseStatistics {
022    
023            public CountStatistics(String name) {
024                    super(name);
025            }
026    
027            public void decrementCount() {
028                    _count--;
029    
030                    setLastSampleTime(System.currentTimeMillis());
031            }
032    
033            public long getCount() {
034                    return _count;
035            }
036    
037            public void incrementCount() {
038                    _count++;
039    
040                    setLastSampleTime(System.currentTimeMillis());
041            }
042    
043            @Override
044            public void reset() {
045                    super.reset();
046    
047                    _count = 0;
048            }
049    
050            public void setCount(long count) {
051                    _count = count;
052    
053                    setLastSampleTime(System.currentTimeMillis());
054            }
055    
056            private long _count;
057    
058    }