001    /**
002     * Copyright (c) 2000-2011 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.portlet.social.model;
016    
017    import java.io.Serializable;
018    
019    /**
020     * @author Brian Wing Shun Chan
021     * @author Zsolt Berentey
022     */
023    public class SocialEquityActionMapping implements Serializable {
024    
025            @Override
026            public SocialEquityActionMapping clone() {
027                    SocialEquityActionMapping equityActionMapping =
028                            new SocialEquityActionMapping();
029    
030                    equityActionMapping.setActionId(_actionId);
031                    equityActionMapping.setClassName(_className);
032                    equityActionMapping.setInformationDailyLimit(_informationDailyLimit);
033                    equityActionMapping.setInformationLifespan(_informationLifespan);
034                    equityActionMapping.setInformationValue(_informationValue);
035                    equityActionMapping.setParticipationDailyLimit(
036                            _participationDailyLimit);
037                    equityActionMapping.setParticipationLifespan(_participationLifespan);
038                    equityActionMapping.setParticipationValue(_participationValue);
039                    equityActionMapping.setUnique(_unique);
040    
041                    return equityActionMapping;
042            }
043    
044            public boolean equals(
045                    SocialEquityActionMapping equityActionMapping, int type) {
046    
047                    if (type == SocialEquitySettingConstants.TYPE_INFORMATION) {
048                            return equals(
049                                    equityActionMapping.getInformationDailyLimit(),
050                                    equityActionMapping.getInformationLifespan(), type,
051                                    equityActionMapping.isUnique(),
052                                    equityActionMapping.getInformationValue());
053                    }
054                    else {
055                            return equals(
056                                    equityActionMapping.getParticipationDailyLimit(),
057                                    equityActionMapping.getParticipationLifespan(), type,
058                                    equityActionMapping.isUnique(),
059                                    equityActionMapping.getParticipationValue());
060                    }
061            }
062    
063            public boolean equals(SocialEquitySetting equitySetting) {
064                    return equals(
065                            equitySetting.getDailyLimit(), equitySetting.getLifespan(),
066                            equitySetting.getType(), equitySetting.isUniqueEntry(),
067                            equitySetting.getValue());
068            }
069    
070            public String getActionId() {
071                    return _actionId;
072            }
073    
074            public String getClassName() {
075                    return _className;
076            }
077    
078            public int getInformationDailyLimit() {
079                    return _informationDailyLimit;
080            }
081    
082            public int getInformationLifespan() {
083                    return _informationLifespan;
084            }
085    
086            public int getInformationValue() {
087                    return _informationValue;
088            }
089    
090            public int getParticipationDailyLimit() {
091                    return _participationDailyLimit;
092            }
093    
094            public int getParticipationLifespan() {
095                    return _participationLifespan;
096            }
097    
098            public int getParticipationValue() {
099                    return _participationValue;
100            }
101    
102            public boolean isUnique() {
103                    return _unique;
104            }
105    
106            public void setActionId(String actionId) {
107                    _actionId = actionId;
108            }
109    
110            public void setClassName(String className) {
111                    _className = className;
112            }
113    
114            public void setInformationDailyLimit(int informationDailyLimit) {
115                    _informationDailyLimit = informationDailyLimit;
116            }
117    
118            public void setInformationLifespan(int informationLifespan) {
119                    _informationLifespan = informationLifespan;
120            }
121    
122            public void setInformationValue(int informationValue) {
123                    _informationValue = informationValue;
124            }
125    
126            public void setParticipationDailyLimit(int participationDailyLimit) {
127                    _participationDailyLimit = participationDailyLimit;
128            }
129    
130            public void setParticipationLifespan(int participationLifespan) {
131                    _participationLifespan = participationLifespan;
132            }
133    
134            public void setParticipationValue(int participationValue) {
135                    _participationValue = participationValue;
136            }
137    
138            public void setUnique(boolean unique) {
139                    _unique = unique;
140            }
141    
142            protected boolean equals(
143                    int dailyLimit, int lifeSpan, int type, boolean unique, int value) {
144    
145                    if (_unique != unique) {
146                            return false;
147                    }
148    
149                    if (type == SocialEquitySettingConstants.TYPE_INFORMATION) {
150                            if ((_informationDailyLimit != dailyLimit) ||
151                                    (_informationLifespan != lifeSpan) ||
152                                    (_informationValue != value)) {
153    
154                                    return false;
155                            }
156                    }
157                    else {
158                            if ((_participationDailyLimit != dailyLimit) ||
159                                    (_participationLifespan != lifeSpan) ||
160                                    (_participationValue != value)) {
161    
162                                    return false;
163                            }
164                    }
165    
166                    return true;
167            }
168    
169            private String _actionId;
170            private String _className;
171            private int _informationDailyLimit;
172            private int _informationLifespan;
173            private int _informationValue;
174            private int _participationDailyLimit;
175            private int _participationLifespan;
176            private int _participationValue;
177            private boolean _unique;
178    
179    }