001    /**
002     * Copyright (c) 2000-2010 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.util;
016    
017    /**
018     * @author Brian Wing Shun Chan
019     */
020    public class LongWrapper
021            extends PrimitiveWrapper implements Comparable<LongWrapper> {
022    
023            public static final Class<?> TYPE = Long.TYPE;
024    
025            public LongWrapper() {
026                    this(0L);
027            }
028    
029            public LongWrapper(long value) {
030                    _value = value;
031            }
032    
033            public int compareTo(LongWrapper longWrapper) {
034                    if (longWrapper == null) {
035                            return 1;
036                    }
037    
038                    if (getValue() > longWrapper.getValue()) {
039                            return 1;
040                    }
041                    else if (getValue() < longWrapper.getValue()) {
042                            return -1;
043                    }
044                    else {
045                            return 0;
046                    }
047            }
048    
049            public long getValue() {
050                    return _value;
051            }
052    
053            public void setValue(long value) {
054                    _value = value;
055            }
056    
057            public long increment() {
058                    return ++_value;
059            }
060    
061            public long decrement() {
062                    return --_value;
063            }
064    
065            private long _value;
066    
067    }