001// --------------------------------------------------------------------------------
002// Copyright 2002-2024 Echo Three, LLC
003//
004// Licensed under the Apache License, Version 2.0 (the "License");
005// you may not use this file except in compliance with the License.
006// You may obtain a copy of the License at
007//
008//     http://www.apache.org/licenses/LICENSE-2.0
009//
010// Unless required by applicable law or agreed to in writing, software
011// distributed under the License is distributed on an "AS IS" BASIS,
012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013// See the License for the specific language governing permissions and
014// limitations under the License.
015// --------------------------------------------------------------------------------
016// Generated File -- DO NOT EDIT BY HAND
017// --------------------------------------------------------------------------------
018
019/**
020 * ClubItemValue.java
021 */
022
023package com.echothree.model.data.club.server.value;
024
025import com.echothree.model.data.club.common.pk.ClubItemPK;
026
027import com.echothree.model.data.club.server.factory.ClubItemFactory;
028
029import com.echothree.model.data.club.common.pk.ClubPK;
030import com.echothree.model.data.club.common.pk.ClubItemTypePK;
031import com.echothree.model.data.item.common.pk.ItemPK;
032
033import com.echothree.util.common.exception.PersistenceCloneException;
034import com.echothree.util.common.exception.PersistenceNotNullException;
035
036import com.echothree.util.server.persistence.BaseValue;
037
038import java.io.Serializable;
039
040public class ClubItemValue
041        extends BaseValue<ClubItemPK>
042        implements Cloneable, Serializable {
043    
044    private ClubPK clubPK;
045    private boolean clubPKHasBeenModified = false;
046    private ClubItemTypePK clubItemTypePK;
047    private boolean clubItemTypePKHasBeenModified = false;
048    private ItemPK itemPK;
049    private boolean itemPKHasBeenModified = false;
050    private Long subscriptionTime;
051    private boolean subscriptionTimeHasBeenModified = false;
052    private Long fromTime;
053    private boolean fromTimeHasBeenModified = false;
054    private Long thruTime;
055    private boolean thruTimeHasBeenModified = false;
056    
057    private transient Integer _hashCode = null;
058    private transient String _stringValue = null;
059    
060    private void constructFields(ClubPK clubPK, ClubItemTypePK clubItemTypePK, ItemPK itemPK, Long subscriptionTime, Long fromTime, Long thruTime)
061            throws PersistenceNotNullException {
062        checkForNull(clubPK);
063        this.clubPK = clubPK;
064        checkForNull(clubItemTypePK);
065        this.clubItemTypePK = clubItemTypePK;
066        checkForNull(itemPK);
067        this.itemPK = itemPK;
068        this.subscriptionTime = subscriptionTime;
069        checkForNull(fromTime);
070        this.fromTime = fromTime;
071        checkForNull(thruTime);
072        this.thruTime = thruTime;
073    }
074    
075    /** Creates a new instance of ClubItemValue */
076    public ClubItemValue(ClubItemPK clubItemPK, ClubPK clubPK, ClubItemTypePK clubItemTypePK, ItemPK itemPK, Long subscriptionTime, Long fromTime, Long thruTime)
077            throws PersistenceNotNullException {
078        super(clubItemPK);
079        constructFields(clubPK, clubItemTypePK, itemPK, subscriptionTime, fromTime, thruTime);
080    }
081    
082    /** Creates a new instance of ClubItemValue */
083    public ClubItemValue(ClubPK clubPK, ClubItemTypePK clubItemTypePK, ItemPK itemPK, Long subscriptionTime, Long fromTime, Long thruTime)
084            throws PersistenceNotNullException {
085        super();
086        constructFields(clubPK, clubItemTypePK, itemPK, subscriptionTime, fromTime, thruTime);
087    }
088    
089   @Override
090   public ClubItemFactory getBaseFactoryInstance() {
091        return ClubItemFactory.getInstance();
092    }
093    
094    @Override
095    public ClubItemValue clone() {
096        Object result;
097        
098        try {
099            result = super.clone();
100        } catch (CloneNotSupportedException cnse) {
101            // This shouldn't happen, fail when it does.
102            throw new PersistenceCloneException(cnse);
103        }
104        
105        return (ClubItemValue)result;
106    }
107    
108   @Override
109    public ClubItemPK getPrimaryKey() {
110        if(_primaryKey == null) {
111            _primaryKey = new ClubItemPK(entityId);
112        }
113        
114        return _primaryKey;
115    }
116    
117    private void clearHashAndString() {
118        _hashCode = null;
119        _stringValue = null;
120    }
121    
122    @Override
123    public int hashCode() {
124        if(_hashCode == null) {
125            int hashCode = 17;
126            
127            hashCode = 37 * hashCode + ((entityId != null) ? entityId.hashCode() : 0);
128            
129            hashCode = 37 * hashCode + ((clubPK != null) ? clubPK.hashCode() : 0);
130            hashCode = 37 * hashCode + ((clubItemTypePK != null) ? clubItemTypePK.hashCode() : 0);
131            hashCode = 37 * hashCode + ((itemPK != null) ? itemPK.hashCode() : 0);
132            hashCode = 37 * hashCode + ((subscriptionTime != null) ? subscriptionTime.hashCode() : 0);
133            hashCode = 37 * hashCode + ((fromTime != null) ? fromTime.hashCode() : 0);
134            hashCode = 37 * hashCode + ((thruTime != null) ? thruTime.hashCode() : 0);
135            
136            _hashCode = hashCode;
137        }
138        
139        return _hashCode;
140    }
141    
142    @Override
143    public String toString() {
144        if(_stringValue == null) {
145            StringBuilder stringValue = new StringBuilder("{");
146            
147            stringValue.append("entityId=").append(getEntityId());
148            
149            stringValue.append(", clubPK=").append(getClubPK());
150            stringValue.append(", clubItemTypePK=").append(getClubItemTypePK());
151            stringValue.append(", itemPK=").append(getItemPK());
152            stringValue.append(", subscriptionTime=").append(getSubscriptionTime());
153            stringValue.append(", fromTime=").append(getFromTime());
154            stringValue.append(", thruTime=").append(getThruTime());
155            
156            stringValue.append('}');
157            
158            _stringValue = stringValue.toString();
159        }
160        return _stringValue;
161    }
162    
163    @Override
164    public boolean equals(Object other) {
165        if(this == other)
166            return true;
167        
168        if(!hasIdentity())
169            return false;
170        
171        if(other instanceof  ClubItemValue) {
172            ClubItemValue that = (ClubItemValue)other;
173            
174            if(!that.hasIdentity())
175                return false;
176            
177            Long thisEntityId = getEntityId();
178            Long thatEntityId = that.getEntityId();
179            
180            boolean objectsEqual = thisEntityId.equals(thatEntityId);
181            if(objectsEqual)
182                objectsEqual = objectsEqual && isIdentical(that);
183            
184            return objectsEqual;
185        } else {
186            return false;
187        }
188    }
189    
190    public boolean isIdentical(Object other) {
191        if(other instanceof ClubItemValue) {
192            ClubItemValue that = (ClubItemValue)other;
193            boolean objectsEqual = true;
194            
195            
196            if(objectsEqual) {
197                ClubPK thisClubPK = getClubPK();
198                ClubPK thatClubPK = that.getClubPK();
199                
200                if(thisClubPK == null) {
201                    objectsEqual = objectsEqual && (thatClubPK == null);
202                } else {
203                    objectsEqual = objectsEqual && thisClubPK.equals(thatClubPK);
204                }
205            }
206            
207            if(objectsEqual) {
208                ClubItemTypePK thisClubItemTypePK = getClubItemTypePK();
209                ClubItemTypePK thatClubItemTypePK = that.getClubItemTypePK();
210                
211                if(thisClubItemTypePK == null) {
212                    objectsEqual = objectsEqual && (thatClubItemTypePK == null);
213                } else {
214                    objectsEqual = objectsEqual && thisClubItemTypePK.equals(thatClubItemTypePK);
215                }
216            }
217            
218            if(objectsEqual) {
219                ItemPK thisItemPK = getItemPK();
220                ItemPK thatItemPK = that.getItemPK();
221                
222                if(thisItemPK == null) {
223                    objectsEqual = objectsEqual && (thatItemPK == null);
224                } else {
225                    objectsEqual = objectsEqual && thisItemPK.equals(thatItemPK);
226                }
227            }
228            
229            if(objectsEqual) {
230                Long thisSubscriptionTime = getSubscriptionTime();
231                Long thatSubscriptionTime = that.getSubscriptionTime();
232                
233                if(thisSubscriptionTime == null) {
234                    objectsEqual = objectsEqual && (thatSubscriptionTime == null);
235                } else {
236                    objectsEqual = objectsEqual && thisSubscriptionTime.equals(thatSubscriptionTime);
237                }
238            }
239            
240            if(objectsEqual) {
241                Long thisFromTime = getFromTime();
242                Long thatFromTime = that.getFromTime();
243                
244                if(thisFromTime == null) {
245                    objectsEqual = objectsEqual && (thatFromTime == null);
246                } else {
247                    objectsEqual = objectsEqual && thisFromTime.equals(thatFromTime);
248                }
249            }
250            
251            if(objectsEqual) {
252                Long thisThruTime = getThruTime();
253                Long thatThruTime = that.getThruTime();
254                
255                if(thisThruTime == null) {
256                    objectsEqual = objectsEqual && (thatThruTime == null);
257                } else {
258                    objectsEqual = objectsEqual && thisThruTime.equals(thatThruTime);
259                }
260            }
261            
262            return objectsEqual;
263        } else {
264            return false;
265        }
266    }
267    
268    @Override
269    public boolean hasBeenModified() {
270        return clubPKHasBeenModified || clubItemTypePKHasBeenModified || itemPKHasBeenModified || subscriptionTimeHasBeenModified || fromTimeHasBeenModified || thruTimeHasBeenModified;
271    }
272    
273    @Override
274    public void clearHasBeenModified() {
275        clubPKHasBeenModified = false;
276        clubItemTypePKHasBeenModified = false;
277        itemPKHasBeenModified = false;
278        subscriptionTimeHasBeenModified = false;
279        fromTimeHasBeenModified = false;
280        thruTimeHasBeenModified = false;
281    }
282    
283    public ClubPK getClubPK() {
284        return clubPK;
285    }
286    
287    public void setClubPK(ClubPK clubPK)
288            throws PersistenceNotNullException {
289        checkForNull(clubPK);
290        
291        boolean update = true;
292        
293        if(this.clubPK != null) {
294            if(this.clubPK.equals(clubPK)) {
295                update = false;
296            }
297        } else if(clubPK == null) {
298            update = false;
299        }
300        
301        if(update) {
302            this.clubPK = clubPK;
303            clubPKHasBeenModified = true;
304            clearHashAndString();
305        }
306    }
307    
308    public boolean getClubPKHasBeenModified() {
309        return clubPKHasBeenModified;
310    }
311    
312    public ClubItemTypePK getClubItemTypePK() {
313        return clubItemTypePK;
314    }
315    
316    public void setClubItemTypePK(ClubItemTypePK clubItemTypePK)
317            throws PersistenceNotNullException {
318        checkForNull(clubItemTypePK);
319        
320        boolean update = true;
321        
322        if(this.clubItemTypePK != null) {
323            if(this.clubItemTypePK.equals(clubItemTypePK)) {
324                update = false;
325            }
326        } else if(clubItemTypePK == null) {
327            update = false;
328        }
329        
330        if(update) {
331            this.clubItemTypePK = clubItemTypePK;
332            clubItemTypePKHasBeenModified = true;
333            clearHashAndString();
334        }
335    }
336    
337    public boolean getClubItemTypePKHasBeenModified() {
338        return clubItemTypePKHasBeenModified;
339    }
340    
341    public ItemPK getItemPK() {
342        return itemPK;
343    }
344    
345    public void setItemPK(ItemPK itemPK)
346            throws PersistenceNotNullException {
347        checkForNull(itemPK);
348        
349        boolean update = true;
350        
351        if(this.itemPK != null) {
352            if(this.itemPK.equals(itemPK)) {
353                update = false;
354            }
355        } else if(itemPK == null) {
356            update = false;
357        }
358        
359        if(update) {
360            this.itemPK = itemPK;
361            itemPKHasBeenModified = true;
362            clearHashAndString();
363        }
364    }
365    
366    public boolean getItemPKHasBeenModified() {
367        return itemPKHasBeenModified;
368    }
369    
370    public Long getSubscriptionTime() {
371        return subscriptionTime;
372    }
373    
374    public void setSubscriptionTime(Long subscriptionTime) {
375        boolean update = true;
376        
377        if(this.subscriptionTime != null) {
378            if(this.subscriptionTime.equals(subscriptionTime)) {
379                update = false;
380            }
381        } else if(subscriptionTime == null) {
382            update = false;
383        }
384        
385        if(update) {
386            this.subscriptionTime = subscriptionTime;
387            subscriptionTimeHasBeenModified = true;
388            clearHashAndString();
389        }
390    }
391    
392    public boolean getSubscriptionTimeHasBeenModified() {
393        return subscriptionTimeHasBeenModified;
394    }
395    
396    public Long getFromTime() {
397        return fromTime;
398    }
399    
400    public void setFromTime(Long fromTime)
401            throws PersistenceNotNullException {
402        checkForNull(fromTime);
403        
404        boolean update = true;
405        
406        if(this.fromTime != null) {
407            if(this.fromTime.equals(fromTime)) {
408                update = false;
409            }
410        } else if(fromTime == null) {
411            update = false;
412        }
413        
414        if(update) {
415            this.fromTime = fromTime;
416            fromTimeHasBeenModified = true;
417            clearHashAndString();
418        }
419    }
420    
421    public boolean getFromTimeHasBeenModified() {
422        return fromTimeHasBeenModified;
423    }
424    
425    public Long getThruTime() {
426        return thruTime;
427    }
428    
429    public void setThruTime(Long thruTime)
430            throws PersistenceNotNullException {
431        checkForNull(thruTime);
432        
433        boolean update = true;
434        
435        if(this.thruTime != null) {
436            if(this.thruTime.equals(thruTime)) {
437                update = false;
438            }
439        } else if(thruTime == null) {
440            update = false;
441        }
442        
443        if(update) {
444            this.thruTime = thruTime;
445            thruTimeHasBeenModified = true;
446            clearHashAndString();
447        }
448    }
449    
450    public boolean getThruTimeHasBeenModified() {
451        return thruTimeHasBeenModified;
452    }
453    
454}