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.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            public SocialEquityActionMapping clone() {
026                    SocialEquityActionMapping equityActionMapping =
027                            new SocialEquityActionMapping();
028    
029                    equityActionMapping.setActionId(_actionId);
030                    equityActionMapping.setClassName(_className);
031                    equityActionMapping.setInformationDailyLimit(_informationDailyLimit);
032                    equityActionMapping.setInformationLifespan(_informationLifespan);
033                    equityActionMapping.setInformationUnique(_informationUnique);
034                    equityActionMapping.setInformationValue(_informationValue);
035                    equityActionMapping.setParticipationDailyLimit(
036                            _participationDailyLimit);
037                    equityActionMapping.setParticipationLifespan(_participationLifespan);
038                    equityActionMapping.setParticipationUnique(_participationUnique);
039                    equityActionMapping.setParticipationValue(_participationValue);
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.isInformationUnique(),
052                                    equityActionMapping.getInformationValue());
053                    }
054                    else {
055                            return equals(
056                                    equityActionMapping.getParticipationDailyLimit(),
057                                    equityActionMapping.getParticipationLifespan(), type,
058                                    equityActionMapping.isParticipationUnique(),
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 isInformationUnique() {
103                    return _informationUnique;
104            }
105    
106            public boolean isParticipationUnique() {
107                    return _participationUnique;
108            }
109    
110            public void setActionId(String actionId) {
111                    _actionId = actionId;
112            }
113    
114            public void setClassName(String className) {
115                    _className = className;
116            }
117    
118            public void setInformationDailyLimit(int informationDailyLimit) {
119                    _informationDailyLimit = informationDailyLimit;
120            }
121    
122            public void setInformationLifespan(int informationLifespan) {
123                    _informationLifespan = informationLifespan;
124            }
125    
126            public void setInformationUnique(boolean informationUnique) {
127                    _informationUnique = informationUnique;
128            }
129    
130            public void setInformationValue(int informationValue) {
131                    _informationValue = informationValue;
132            }
133    
134            public void setParticipationDailyLimit(int participationDailyLimit) {
135                    _participationDailyLimit = participationDailyLimit;
136            }
137    
138            public void setParticipationLifespan(int participationLifespan) {
139                    _participationLifespan = participationLifespan;
140            }
141    
142            public void setParticipationUnique(boolean participationUnique) {
143                    _participationUnique = participationUnique;
144            }
145    
146            public void setParticipationValue(int participationValue) {
147                    _participationValue = participationValue;
148            }
149    
150            protected boolean equals(
151                    int dailyLimit, int lifeSpan, int type, boolean unique, int value) {
152    
153                    if (type == SocialEquitySettingConstants.TYPE_INFORMATION) {
154                            if ((_informationDailyLimit != dailyLimit) ||
155                                    (_informationLifespan != lifeSpan) ||
156                                    (_informationUnique == unique) ||
157                                    (_informationValue != value)) {
158    
159                                    return false;
160                            }
161                    }
162                    else {
163                            if ((_participationDailyLimit != dailyLimit) ||
164                                    (_participationLifespan != lifeSpan) ||
165                                    (_participationUnique == unique) ||
166                                    (_participationValue != value)) {
167    
168                                    return false;
169                            }
170                    }
171    
172                    return true;
173            }
174    
175            private String _actionId;
176            private String _className;
177            private int _informationDailyLimit;
178            private int _informationLifespan;
179            private boolean _informationUnique;
180            private int _informationValue;
181            private int _participationDailyLimit;
182            private int _participationLifespan;
183            private boolean _participationUnique;
184            private int _participationValue;
185    
186    }