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.increment;
016    
017    import com.liferay.portlet.social.model.SocialEquityValue;
018    
019    /**
020     * @author Zsolt Berentey
021     */
022    public class SocialEquityIncrement implements Increment<SocialEquityValue> {
023    
024            public SocialEquityIncrement(SocialEquityValue value) {
025                    _value = value;
026            }
027    
028            public void decrease(SocialEquityValue delta) {
029                    _value.subtract(delta);
030            }
031    
032            public Increment<SocialEquityValue> decreaseForNew(
033                    SocialEquityValue delta) {
034    
035                    return new SocialEquityIncrement(
036                            new SocialEquityValue(
037                                    _value.getK() - delta.getK(),
038                                    _value.getB() - delta.getB()
039                            )
040                    );
041            }
042    
043            public SocialEquityValue getValue() {
044                    return _value;
045            }
046    
047            public void increase(SocialEquityValue delta) {
048                    _value.add(delta);
049            }
050    
051            public Increment<SocialEquityValue> increaseForNew(
052                    SocialEquityValue delta) {
053    
054                    SocialEquityValue value = new SocialEquityValue(
055                            _value.getK() + delta.getK(), _value.getB() + delta.getB());
056    
057                    return new SocialEquityIncrement(value);
058            }
059    
060            public void setValue(SocialEquityValue value) {
061                    _value = value;
062            }
063    
064            private SocialEquityValue _value;
065    
066    }