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