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